Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2467 Discussions

Is there a way to limit the number of cores used by a call to a parallel function?

Victor_D_
New Contributor I
1,322 Views

For example fill(dpl:) does not scale in parallel well, and I'd like to limit it to using 2 or 4 cores, while sort(dpl:) scales better and I'd like to let it use more cores within the same application.

Thank you,

-Victor

0 Kudos
5 Replies
SeshaP_Intel
Moderator
1,299 Views

Hi,

 

Thank you for posting in Intel Communities.

 

Could you please provide the following details you were using so that we can investigate the issue more from our end?

1. oneTBB version you are using?

2. Operating system and Hardware details

3. Complete reproducer code and steps(if you have followed any)

 

Thanks and Regards,

Pendyala Sesha Srinivas

 

0 Kudos
SeshaP_Intel
Moderator
1,237 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue?


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
SeshaP_Intel
Moderator
1,196 Views

Hi,


I have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.


Thanks and Regards,

Pendyala Sesha Srinivas


0 Kudos
Pavel_K_Intel1
Employee
1,186 Views

Hi,
There are several approaches in oneTBB.  However, based on your description task_arena should be appropriate solution. 
You can wrap particular algorithm into task_arena::execute.

#include "tbb/task_arena.h"

int main() {
    tbb::task_arena sort_arena(concurrency);

    sort_arena.execute([] {
        // call sort function
    }
    );
}
0 Kudos
Victor_D_
New Contributor I
1,173 Views

Thank you Pavel for your suggestion. I'll give task arena a try.

0 Kudos
Reply