summaryrefslogtreecommitdiff
path: root/libopencl
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2010-08-08 04:16:35 -0800
committerTor Aamodt <[email protected]>2010-08-08 04:16:35 -0800
commit06435e77c580bf7737333929ed26d3863949bd15 (patch)
tree2aa5881d8b3cffc6e3587007da0e9556c78665b3 /libopencl
parent4d441a9746616b2e45397097e6a7600a67aa973c (diff)
add listing function for ptx debugging
print out compilation errors encountered during OpenCL to PTX conversion (still a bit cryptic) [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7162]
Diffstat (limited to 'libopencl')
-rw-r--r--libopencl/nvopencl_wrapper.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/libopencl/nvopencl_wrapper.cc b/libopencl/nvopencl_wrapper.cc
index 7c12075..6d446a4 100644
--- a/libopencl/nvopencl_wrapper.cc
+++ b/libopencl/nvopencl_wrapper.cc
@@ -65,10 +65,12 @@
#include <string.h>
#include <stdarg.h>
+#define PREAMBLE "GPGPU-Sim nvopencl_wrapper"
+
void vmyexit(int code, const char *str,va_list ap)
{
char buffer[1024];
- snprintf(buffer,1024,"GPGPU-Sim API: nvopencl_wrapper ERROR ** %s\n", str);
+ snprintf(buffer,1024,"%s: ERROR ** %s\n", PREAMBLE, str);
vprintf(buffer,ap);
fflush(stdout);
if( code )
@@ -123,9 +125,12 @@ int main(int argc, const char **argv)
if ( errcode != CL_SUCCESS ) myexit(3,"clGetPlatformIDs returned %d",errcode);
errcode = clGetPlatformInfo(platforms[0], CL_PLATFORM_NAME, 1024, &buffer, NULL);
if ( errcode != CL_SUCCESS ) myexit(3,"clGetPlatformInfo returned %d",errcode);
- printf("GPGPU-Sim OpenCL API: Generating PTX using OpenCL platform \'%s\'\n",buffer);
+ printf("%s: Generating PTX using OpenCL platform \'%s\'\n",PREAMBLE,buffer);
+
errcode = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices);
if ( errcode != CL_SUCCESS ) myexit(4,"clGetDeviceIDs returned %d",errcode);
+ printf("%s: found %u native OpenCL devices\n",PREAMBLE,num_devices);
+
cl_device_id *devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id) );
errcode = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, num_devices, devices, NULL);
if ( errcode != CL_SUCCESS ) myexit(5,"clGetDeviceIDs returned %d",errcode);
@@ -143,7 +148,19 @@ int main(int argc, const char **argv)
n+= 2;
}
errcode = clBuildProgram(pgm, 0, NULL, options, NULL, NULL);
- if ( errcode != CL_SUCCESS ) myexit(8,"clBuildProgram returned %d",errcode);
+ if ( errcode != CL_SUCCESS ) {
+ printf("%s: clBuildProgram returned %d (error) -- build log:\n\n",PREAMBLE,errcode);
+ size_t build_log_length=0;
+ errcode = clGetProgramBuildInfo(pgm,devices[0],CL_PROGRAM_BUILD_LOG,0,NULL,&build_log_length);
+ if( errcode != CL_SUCCESS ) myexit(8,"clGetProgramBuildInfo returned %d",errcode);
+ char *build_log = (char*)calloc(1,build_log_length);
+ errcode = clGetProgramBuildInfo(pgm,devices[0],CL_PROGRAM_BUILD_LOG,build_log_length,
+ build_log,&build_log_length);
+ printf("%s",build_log);
+ printf("\n\n%s: end of build log\n", PREAMBLE);
+ printf("%s: exiting early because the OpenCL code had errors (see above).\n", PREAMBLE);
+ exit(8);
+ }
size_t nbytes1=0;
errcode = clGetProgramInfo(pgm,CL_PROGRAM_NUM_DEVICES,sizeof(cl_uint),&num_devices,&nbytes1);