Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Using TBB in a dll

Daniel_D
Beginner
258 Views

Is it a problem if I compile an application without TBB that uses a dll that is linked with the TBB libraries? Or is it necessary that all parts of an application is set to use TBB if a single parts needs that?

0 Kudos
1 Solution
TimP
Black Belt
258 Views
TBB may conflict with use of OpenMP or /Qparallel (and libraries such as mkl_thread which incorporate those). Other than that, I don't see a concern.

View solution in original post

6 Replies
TimP
Black Belt
259 Views
TBB may conflict with use of OpenMP or /Qparallel (and libraries such as mkl_thread which incorporate those). Other than that, I don't see a concern.
Daniel_D
Beginner
258 Views
Thanks for the insights.
Vladimir_P_Intel2
258 Views
there won't be 'conflict'. there might be oversubscription when there are heavy calculation at the same time in code using openmp and tbb.
--Vladimir
SergeyKostrov
Valued Contributor II
258 Views
Answer on the1st Question:

I don'texpect any problems. If a DLL with TBB has some functions declared as exported any applications could call these functions.

The only difference between an application with integrated TBB functionalityvs. an application that uses a DLLwith TBB functionality is that in the 2nd caseTBB functionality will be loaded by OS loaderin a different address space.

You understand the main idea of aDLL, right? That is,a DLLcould beloaded by an application andthe DLL's functionality ( codes, data, etc )could be shared between different applications.

Answer on the 2nd Question:

In case of template-based libraries it is a common approach to includea template-based librarycompletely. Let's say a template-based library has classes A, B and C, and only class B is used in some application. In that case only codes for the class B will be compiled andused inthe application! Codes for classes A and C won't be included inthe application.It makes theapplication more compact.

I don'tknow if somebody uses an STL library througha DLL,but it is possible.
Daniel_D
Beginner
258 Views

Hi Sergey,

Thanks for your answer. Yes I understand the main idea of a DLL that is the reason why I use them. I would not recommended using STL over DLL boundaries since you can never be sure that the same version of the STL library is used or that the DLL uses a custom allocator. That might end up with some resource leaks.

SergeyKostrov
Valued Contributor II
258 Views
>>...I would not recommended using STL over DLL boundaries since you can never be sure that the same version of the STL library is used...

Hi Daniel, I agree with you regarding anSTL in a DLL. That breaks amain idea oftemplate based programming.

>>...That might end up with some resource leaks...

Yes, especially when a developer creates an object with 'new' C++ operator and never calls 'delete' C++ operator... :)

Best regards,
Sergey
Reply