Run-time loader

Summary

The run-time loader is a mechanism that provides additional run-time control over the version of the Intel® Threading Building Blocks (Intel® TBB) dynamic library used by an application, plug-in, or another library.

Header

#define TBB_PREVIEW_RUNTIME_LOADER 1
 #include "tbb/runtime_loader.h"

Library

OS

Release build

Debug build

Windows

tbbproxy.lib

tbbproxy_debug.lib

Description

The run-time loader consists of a class and a static library that can be linked with an application, library, or plug-in to provide better run-time control over the version of Intel TBB used. The class allows loading a desired version of the dynamic library at run time with explicit list of directories for library search. The static library provides stubs for functions and methods to resolve link-time dependencies, which are then dynamically substituted with the proper functions and methods from a loaded Intel TBB library.

All instances of class runtime loader in the same module (i.e. exe or dll) share certain global state. The most noticeable piece of this state is the loaded Intel TBB library. The implications of that are:

Only one Intel TBB library per module can be loaded.

If one runtime_loader instance has already loaded a library, another one created by the same module will not load another one. If the loaded library is suitable for the second instance, both will use it cooperatively, otherwise an error will be reported (details below).

If different versions of the library are requested by different modules, those can be loaded, but may result in processor oversubscription.

runtime_loader objects are not thread-safe and may work incorrectly if used concurrently.

  • If an application or a library uses runtime_loader, it should be linked with one of the above specified libraries instead of a normal Intel TBB library.

Example

#define TBB_PREVIEW_RUNTIME_LOADER 1
 #include "tbb/runtime_loader.h"
 #include "tbb/parallel_for.h"
 #include <iostream>
 char const * path[] = { "c:\\myapp\\lib\\ia32", NULL };
 int main() {
 tbb::runtime_loader loader( path );
 if( loader.status()!=tbb::runtime_loader::ec_ok )
 return -1;
 // The loader does not impact how the library is used
 tbb::parallel_for(0, 10, ParallelForBody());
 return 0;
 }

In this example, the Intel TBB library will be loaded from the c:\myapp\lib\ia32 directory. No explicit requirements for a version are specified, so the minimal suitable version is the version used to compile the example, and any higher version is suitable as well. If the library is successfully loaded, it can be used in the normal way.

For more complete information about compiler optimizations, see our Optimization Notice.