3 Replies Latest reply on Oct 21, 2012 4:48 PM by nou

    Restricting OpenCL kernels to a single CPU core

    gdebrecz

      Hello,

       

      I'd like to run my OpenCL app on a multi-core CPU but using only one of the cores.

      More precisely, I'd like the each of the thread of the multi-threaded OpenCL code

      being executed on the same core.  (I don't want completely serialize it using clEnqueTask

      but using only one of the core.)

       

      How I can reach this ? Is there some build opetion for that ? Or I have to use the

      clCreateSubDevice to get one of the core ?

       

      Currently the threads are spreading over several core and influencing other users

      jobs on a multi-core CPU batch node.

       

      thanks in advance,

      Gergely

        • Restricting OpenCL kernels to a single CPU core
          nou

          yes using device fission is proper way.

            • Re: Restricting OpenCL kernels to a single CPU core
              gdebrecz

              Thanks for the promt answer,

               

              I'm trying to do that on AMD and Intel processors i.e. to create subdevices with clCreateSubDevices

              but failed to get any result so far. I've got either CL_DEVICE_PARTITION_FAILED error or

              partition succeed on a 8 core device but only 1 subdevice is created and context creation fails

              with that subdevice with error...

                Is there any restriction on which multi-core CPU-s can be partitioned and which ones not ?

              The relevant part of my code is:

               

                /* Now creating a subdevice */

                          cl_uint sub_device_nums;

                          cl_device_partition_property partition_props[3] =  { CL_DEVICE_PARTITION_EQUALLY, compute_units, 0};

                          err = clCreateSubDevices(device_ids[0], (cl_device_partition_property *) partition_props, (cl_uint) 8, sub_device_ids, &sub_device_nums);

                          printf("clCreateSubDevices: %d\n", err);

                          switch (err) {

                              case CL_INVALID_DEVICE: printf("a\n"); break;;

                              case CL_INVALID_VALUE: printf ("b\n"); break;;

                              case CL_DEVICE_PARTITION_FAILED:  printf("c\n"); break;;

                              case CL_INVALID_DEVICE_PARTITION_COUNT: printf ("d\n"); break;;

                              case CL_OUT_OF_RESOURCES: printf("e\n"); break;;

                              case CL_OUT_OF_HOST_MEMORY: printf("f\n"); break;;

                              default: printf("x\n"); break;;

                          }

               

               

              printf("Number of subdevices :%d\n", sub_device_nums);

               

                          /* Creating the context */

                          cl_context_properties ctxProps[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties) platforms, 0};

                          myContext = clCreateContext(ctxProps, 1, sub_device_ids, NULL, NULL, &err);

                          printf("clCreateContext err: %d\n", err);

               

               

              thanks again for any answer,

              Gergely