3

Can we impose procssor affinity in OpenCl? For example thread# 1 executes on procesor# 5,
thread# 2 executes on procesor# 6, thread# 3 executes on procesor# 7, and so on ?

Thanks

talonmies
  • 70,661
  • 34
  • 192
  • 269
gpuguy
  • 4,607
  • 17
  • 67
  • 125

1 Answers1

7

You can't specify affinity at that low level with OpenCL as far as I know. But, starting with OpenCL 1.2 have some control over affinity by partitioning into subdevices using clCreateSubDevices (possibly with one processor in each subdevice by using CL_DEVICE_PARTITION_BY_COUNTS, 1) and running separate kernel executions on each subdevice.

This would very likely run poorly on anything other than a CPU-based OpenCL implementation, and I'd have to question why you would want to do such a thing. If you want to limit CPU usage for an OpenCL-CPU implementation, you could use clCreateSubDevices to portion off some of your computing resources.

A PDF describing 'device fission' from Intel is here, and it has lots of info on how to use device partitioning and clCreateSubDevices effectively.

prunge
  • 22,460
  • 3
  • 73
  • 80
  • 6
    Being able to specify thread affinity in OpenCL is not as useless as it looks. On NUMA systems (e.g. multisocket Nehalem or AMD systems) thread migration from one NUMA node to another will almost certainly lead to non-local memory access and this would hurt the performance. It should be up to a good CPU OpenCL run-time to deal with core affinity. – Hristo Iliev May 07 '12 at 07:35