cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

gdebrecz
Journeyman III

Restricting OpenCL kernels to a single CPU core

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

0 Likes
3 Replies
nou
Exemplar

yes using device fission is proper way.

0 Likes

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

0 Likes

compute_units should be 1 as CL_DEVICE_PARTITION_EQUALLY specify how many compute units should each subdevice have.

0 Likes