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

Static linking tbb

superstatic
Beginner
533 Views

Hi,

I'm writing a library where I'm linking to the open source version of tbb built as a static lib. This works fine but when I static link my library into a program it asks for the tbb library and I want my library to be self contained so people can use it without needing to link against tbb themselves. I've had a similar thing with boost where you can use a preprocessor definition to make your library self contained. I'm wondering how I can achieve this with tbb? 


Thanks a lot!

0 Kudos
3 Replies
RafSchietekat
Valued Contributor III
533 Views

You shouldn't try to do that, unless you want to do your users a great disservice. Oversubscription hurts performance, so TBB is presented as a dynamically linked library partly to get all parts of a program to coordinate through shared constructs and thus help achieve composability.

0 Kudos
superstatic
Beginner
533 Views

I'm aware of the issue of multiple tbb schedulers being active and my thought was to let the user disable the scheduler in the library and supply their own if they are using tbb themselves (although I admit I haven't looked into that possibility yet). Would that not work? 

I don't see how having tbb as a dynamic library would stop an oversubscription situation if the user is managing threads themselves or using something like openmp in their program?

0 Kudos
RafSchietekat
Valued Contributor III
533 Views

I'm sorry, but I don't see the point of that.

And TBB indeed can't magically cure externally caused oversubscription.

0 Kudos
Reply