Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

multithreading - Processor Affinity in OpenCL

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...