Community
cancel
Showing results for 
Search instead for 
Did you mean: 
pollgreen
Beginner
42 Views

How to manage multiprocessors

I hope this is not a dumb question,so please be patient with me.
We are attempting to develop a program using Intel C++ linux compiler that will run on a dual-quad core Xeon E5430 computer running red hat linux 5.3 (RT kernel). We want to be able to specify portions (threads) of this program to run on specific processors. We do have the Intel TBB package as well. I am unsure whether this can be done from the compiler level or is this something that must be done via the kernel somehow? And if through the kernel, that would imply we would have multple executables instead of just one as we plan on doing. Any help in this area would be appreciated. I have looked all over the web for answers to this question, but have struck out. We also have tuna, but I am not exactly sure how that can be used to achieve our goal.

Simplified design of program Multi:
Multi.exe needs to contain 4 distinct threads that we can specify run specifically on 4 different processors. Ideally, we would like to set aside these 4 processors so they are ONLY processing each of these threads and nothing else. Note: some of these threads include interrupt handlers as well. Can all this be done from our source code directly or do we need to employ tuna and/or taskset to achieve our goal?

Thanks, Rick Pollgreen
0 Kudos
2 Replies
Tudor
New Contributor I
42 Views

Quoting - pollgreen
I hope this is not a dumb question,so please be patient with me.
We are attempting to develop a program using Intel C++ linux compiler that will run on a dual-quad core Xeon E5430 computer running red hat linux 5.3 (RT kernel). We want to be able to specify portions (threads) of this program to run on specific processors. We do have the Intel TBB package as well. I am unsure whether this can be done from the compiler level or is this something that must be done via the kernel somehow? And if through the kernel, that would imply we would have multple executables instead of just one as we plan on doing. Any help in this area would be appreciated. I have looked all over the web for answers to this question, but have struck out. We also have tuna, but I am not exactly sure how that can be used to achieve our goal.

Simplified design of program Multi:
Multi.exe needs to contain 4 distinct threads that we can specify run specifically on 4 different processors. Ideally, we would like to set aside these 4 processors so they are ONLY processing each of these threads and nothing else. Note: some of these threads include interrupt handlers as well. Can all this be done from our source code directly or do we need to employ tuna and/or taskset to achieve our goal?

Thanks, Rick Pollgreen

Sounds like what you are trying to do is set thread affinity to a certain core. If that is the case, try using pthread_attr_setaffinity_np. Hope this helps.

This is if you are using regular pthreads. I don't know if TBB allows you to explicitly set the affinity of the threads it creates.
Alternatively, you can set the entire process cpu affinity (this should also affect TBB-created threads) to only the 4 cores you want to use via sched_setaffinity and rely on the automatic scheduler to balance the threads.
ClayB
Black Belt
42 Views


I would also recommend that you use the non-standard affinity API functions for Pthreads if you truly must have the threads fixed to some specific core. There is no facility to do this within TBB. Threading Building Blocks is designed to consider the tasks that can be executed in parallel rather than what threads are executing what lines of code and where are those threads sitting within the cores.

As a programmer, I trust the TBB scheduler to put the tasks on the best threads on the cores in order to maximize cache reuse and throughput (even if it resorts to unfair scheduling). If you're application is a set of threads doing something, then you probably don't want to use TBB.

--clay
Reply