Created
August 9, 2019 20:21
-
-
Save pentschev/5946bc72e19b6e64a8b4358f7c73fa9e to your computer and use it in GitHub Desktop.
Blog Post - Parallelizing Custom CuPy Kernels with Dask - CuPy Kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_broadcast_kernel = cupy.RawKernel( | |
r''' | |
extern "C" __global__ | |
void add_broadcast_kernel( | |
const float* x, const float* y, float* z, | |
const int xdim0, const int zdim0) | |
{ | |
int idx0 = blockIdx.x * blockDim.x + threadIdx.x; | |
int idx1 = blockIdx.y * blockDim.y + threadIdx.y; | |
z[idx1 * zdim0 + idx0] = x[idx1 * xdim0 + idx0] + y[idx0]; | |
} | |
''', | |
'add_broadcast_kernel' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment