Display kernel error

随声附和 提交于 2019-12-25 01:49:57

问题


I'm using GCC and the NVIDIA implementation of OpenCL, and online compilation instead of offline compilation.

I use this list to check which is the error I have. But nevertheless if I have an error inside my kernel the only information I have is an error value -48.

My question is: Is there a way to display the exact kernel compilation error?

If a semicolon is missing, or I have a wild pointer I would like to read so, instead of just a -48 error. Otherwise the development time is getting too slow.

I add also my Makefile:

CC=gcc
FILE=main

all:
    $(CC) -c -Wall -I /usr/local/cuda/include/ $(FILE).c -o $(FILE).o
    $(CC) $(FILE).o -o $(FILE) -L /usr/local/cuda/lib64/ -l OpenCL
clean:
    $(RM) $(FILE) $(FILE).o

回答1:


In C++, do something like:

int ErrorCode = 0;
cl_program P;
cl_device_id D;
size_t LogSize;
cl_build_status BuildStatus;

//Configure OpenCL 
//Load Program Here
//Compile Program here

//Check the status of compilation
ErrorCode = clGetProgramBuildInfo(P, D, CL_PROGRAM_BUILD_STATUS, NULL, NULL, &BuildStatus);

if(BuildStatus == CL_BUILD_ERROR){
     //Fetch Error
     ErrorCode = clGetProgramBuildInfo(P, D, CL_PROGRAM_BUILD_LOG, NULL, NULL, &LogSize);
     char Log = new Log[LogSize]; //Or use Malloc if in C
     ErrorCode = clGetProgramBuildInfo(P, D, CL_PROGRAM_BUILD_LOG, LogSize, Log, NULL);

     //Display Error Code here, close out OpenCL, try again, etc
}


来源:https://stackoverflow.com/questions/18232846/display-kernel-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!