Working Notes: a commonplace notebook for recording & exploring ideas.
Home. Site Map. Subscribe. More at expLog.

Cuda

// For all CUDA calls
void e(cudaError_t result) {
  if (result != cudaSuccess) {
    printf("%s\n", cudaGetErrorString(result));
  }
}

// Sanity checks after running a kernel
e(cudaGetLastError()); 
e(cudaDeviceSynchronize());

// Common functions
cudaMemcpy(dest, source, size, cudaMemcpyHostToDevice | cudaMemcpyDeviceToHost)
cudaMalloc(&<pointer>, size)
  
// Calling a kernel
kernel<<<blocks, threadsinblock>>>()
threadIdx.x
blockDim.x // threads in a block in that direction
gridDim.x // blocks in a grid in that direction

// Shared memory
 __shared__ int s[]; <- size defined by parameter to the kernel

Kunal