Browse Source

socl/examples: skip examples when no opencl platform is found

Nathalie Furmento 13 years ago
parent
commit
2acb7ed687
2 changed files with 5 additions and 1 deletions
  1. 1 1
      socl/examples/basic/basic.c
  2. 4 0
      socl/examples/clinfo/clinfo.c

+ 1 - 1
socl/examples/basic/basic.c

@@ -73,7 +73,7 @@ int main(int UNUSED(argc), char** UNUSED(argv)) {
    err = clGetPlatformIDs(0, NULL, &num_platforms);
    if (num_platforms == 0) {
       printf("No OpenCL platform found. If you use SOCL, this could mean StarPU wasn't configured for OpenCL. Try disabling CUDA support in StarPU (export STARPU_NCUDA=0).\n");
-      exit(0);
+      exit(77);
    }
    err = clGetPlatformIDs(sizeof(platforms)/sizeof(cl_platform_id), platforms, NULL);
    check(err, "clGetPlatformIDs");

+ 4 - 0
socl/examples/clinfo/clinfo.c

@@ -36,6 +36,10 @@ main(void) {
 
    // Plaform info
    err = clGetPlatformIDs(0, NULL, &num_platforms);
+   if (num_platforms == 0) {
+      printf("No OpenCL platform found. If you use SOCL, this could mean StarPU wasn't configured for OpenCL. Try disabling CUDA support in StarPU (export STARPU_NCUDA=0).\n");
+      exit(77);
+   }
    checkErr(err, "Unable to get platform count");
 
    platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id)*num_platforms);