A Python tool for quick and dirty translation of CUDA kernels to OpenCL
You could include a link to the full documentation of your project here.
As a command-line tool:
cutocl vector_add.cu
Or use from Python:
from cutocl import cutocl
kernel_string = """
__global__ void vector_add(float *c, float *a, float *b, int n) {
int i = blockIdx.x * block_size_x + threadIdx.x;
if (i<n) {
c[i] = a[i] + b[i];
}
}
"""
opencl_kernel = cutocl.translate(kernel_string)
print(opencl_kernel)
This should produce:
__kernel void vector_add(__global float *c, __global float *a, __global float *b, int n) {
int i = get_group_id(0) * block_size_x + get_local_id(0);
if (i<n) {
c[i] = a[i] + b[i];
}
}
clone the repository
git clone [email protected]:benvanwerkhoven/cutocl.git
change into the top-level directory
cd cutocl
install using
pip install .
- Python 3
Copyright (c) 2016, Ben van Werkhoven
Apache Software License 2.0
Contributing authors so far:
- Ben van Werkhoven