CellularAutomata
Loading...
Searching...
No Matches
cuda.cuh File Reference
#include "../core/common.hpp"
#include "cuda.inl"

Go to the source code of this file.

Namespaces

namespace  CellularAutomata
 Main namespace.
 

Functions

void CellularAutomata::cuda::allocateCUDA (void **arrayPtr, size_t bytes)
 Allocated memory on a CUDA device.
 
void CellularAutomata::cuda::allocateHost (void **arrayPtr, size_t bytes)
 Allocated memory on the host device (CPU)
 
void CellularAutomata::cuda::freeCUDA (void *array)
 Frees memory on a CUDA device.
 
void CellularAutomata::cuda::freeHost (void *array)
 Frees memory on the host device (CPU)
 
void CellularAutomata::cuda::copyCUDA (void *src, Device from, void *dst, Device to, size_t bytes)
 Memcopy between devices and host.
 
template<typename T , typename Activation >
void CellularAutomata::cuda::epoch (T *input, T *kernel, T *output, Activation fn, const unsigned int h, const unsigned int w, const unsigned int s, const bool r)
 Call the CUDA kernel to run a single epoch on a given state using a kernel.
 

Function Documentation

◆ allocateCUDA()

void CellularAutomata::cuda::allocateCUDA ( void **  arrayPtr,
size_t  bytes 
)

Allocated memory on a CUDA device.

Parameters
arrayPtrpointer to deviceArray
bytesallocation size in bytes
Exceptions
CudaRuntime

◆ allocateHost()

void CellularAutomata::cuda::allocateHost ( void **  arrayPtr,
size_t  bytes 
)

Allocated memory on the host device (CPU)

Note
Allocates "page-locked memory" which is slower in allocation but faster in transmission between devices and host. Should be used for memory which is often transfered
Parameters
arrayPtrpointer to hostArray
bytesallocation size in bytes
Exceptions
CudaRuntime

◆ copyCUDA()

void CellularAutomata::cuda::copyCUDA ( void *  src,
Device  from,
void *  dst,
Device  to,
size_t  bytes 
)

Memcopy between devices and host.

Attention
Size is assumed to be equal
Note
Host memory can be allocated using regular allocations
Parameters
srcinput array to copy from
fromcomputational device where input lives
dstoutput array to copy to
tocomputational device where output lives
bytesallocation size in bytes
Exceptions
CudaRuntime

◆ epoch()

template<typename T , typename Activation >
void CellularAutomata::cuda::epoch ( T *  input,
T *  kernel,
T *  output,
Activation  fn,
const unsigned int  h,
const unsigned int  w,
const unsigned int  s,
const bool  r 
)

Call the CUDA kernel to run a single epoch on a given state using a kernel.

Template Parameters
Ttype
Activationfunctor
Parameters
inputcurrent state array
kernelkernel for convolution
outputnext state array
fnactivation function
hheight of state array
wwidth of state array
ssize of kernel
rgrid recursion enabled
Exceptions
CudaRuntime

◆ freeCUDA()

void CellularAutomata::cuda::freeCUDA ( void *  array)

Frees memory on a CUDA device.

Parameters
arraydeviceArray to free
Exceptions
CudaRuntime

◆ freeHost()

void CellularAutomata::cuda::freeHost ( void *  array)

Frees memory on the host device (CPU)

Attention
Do NOT use on regular allocations
Note
Frees "page-locked memory" allocated with CUDA functions
Parameters
arrayhostArray to free
Exceptions
CudaRuntime