I'm trying to port the CUDA code to OpenCL. I'm using "AMD-APP-SDK-v2.8-lnx32" for compiling my host code. As per my understanding I have made the changes to run it on OpenCL. The host code compiles fine, but when I run the binary created, it tries to compile the kernel code and it fails saying
ERROR: Failed to build executable
"/tmp/OCLoPv5RX.cl", line 1: error: unrecognized token
"/tmp/OCLoPv5RX.cl", line 1: error: expected a declaration
2 errors detected in the compilation of "/tmp/OCLoPv5RX.cl".
Frontend phase failed compilation.
How to debug these type of errors - any pointers? I'm trying to learn OpenCl now, please help.
The changes I made from CUDA to Open CL
__global void draw_gpu(unsigned char *buf, scene_gpu *myScene)
__kernel void draw_gpu(__global unsigned char *buf,__global scene_gpu *myScene)
int j= blockIdx.x;
int i= threadIdx.x;
int j= get_group_id(0);
int i= get_local_id(0);
__device__ bool hitSphere_d(const ray &r, const sphere &s, float &t)
bool hitSphere_d(const ray &r, const sphere &s, float &t)
__device__ float min_d (float a, float b)
float min_d (float a, float b)
Please note that here I had __device__ qualified functions, ie these functions are called by device(GPU) from the kernel function. Whereas in OpenCl I read giving extra qualifier is not necessary. Is this if fine ?
I have attached the cuda kernel and OpenCl kernel code, please have a look and suggest any changes.