Browse Source

src/drivers/opencl: return an error instead of aborting when failing to build a program

Nathalie Furmento 13 years ago
parent
commit
5c6241e2ec
1 changed files with 7 additions and 6 deletions
  1. 7 6
      src/drivers/opencl/driver_opencl_utils.c

+ 7 - 6
src/drivers/opencl/driver_opencl_utils.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2010, 2011  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Université de Bordeaux 1
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -172,6 +172,8 @@ int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, str
                 cl_program   program;
                 cl_program   program;
                 cl_int       err;
                 cl_int       err;
 
 
+                opencl_programs->programs[dev] = NULL;
+
                 starpu_opencl_get_device(dev, &device);
                 starpu_opencl_get_device(dev, &device);
                 starpu_opencl_get_context(dev, &context);
                 starpu_opencl_get_context(dev, &context);
                 if (context == NULL)
                 if (context == NULL)
@@ -180,13 +182,12 @@ int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, str
                         continue;
                         continue;
                 }
                 }
 
 
-                opencl_programs->programs[dev] = NULL;
-
-                if (context == NULL) continue;
-
                 // Create the compute program from the source buffer
                 // Create the compute program from the source buffer
                 program = clCreateProgramWithSource(context, 1, (const char **) &opencl_program_source, NULL, &err);
                 program = clCreateProgramWithSource(context, 1, (const char **) &opencl_program_source, NULL, &err);
-                if (!program || err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
+                if (!program || err != CL_SUCCESS) {
+			_STARPU_DISP("Error: Failed to load program source!\n");
+			return EXIT_FAILURE;
+		}
 
 
                 // Build the program executable
                 // Build the program executable
                 err = clBuildProgram(program, 1, &device, build_options, NULL, NULL);
                 err = clBuildProgram(program, 1, &device, build_options, NULL, NULL);