Pārlūkot izejas kodu

OpenCL driver : make sure the number of OpenCL devices is less than STARPU_MAXOPENCLDEVS.

The test programs used to produce lots of "oops" and to crash when we used --enable-maxopencldev.
Cyril Roelandt 13 gadi atpakaļ
vecāks
revīzija
769adacccf
1 mainītis faili ar 5 papildinājumiem un 0 dzēšanām
  1. 5 0
      src/drivers/opencl/driver_opencl.c

+ 5 - 0
src/drivers/opencl/driver_opencl.c

@@ -357,6 +357,11 @@ void _starpu_opencl_init(void)
                 // Get location of OpenCl kernel source files
                 _starpu_opencl_program_dir = getenv("STARPU_OPENCL_PROGRAM_DIR");
 
+		if (nb_devices > STARPU_MAXOPENCLDEVS) {
+			_STARPU_DISP("# Warning: %d OpenCL devices available. Only %d enabled. Use configure option --enable-maxopencldev=xxx to update the maximum value of supporter OpenCL devices?\n", nb_devices, STARPU_MAXOPENCLDEVS);
+			nb_devices = STARPU_MAXOPENCLDEVS;
+		}
+
                 // initialise internal structures
                 for(i=0 ; i<nb_devices ; i++) {
                         contexts[i] = NULL;