DepSpawn 1.2
 
Loading...
Searching...
No Matches
Compiling and running

Once we have installed DepSpawn, we are ready to test it in an application. For this purpose we will use the simple example code found in examples/test_subobject.cpp. In order to compile a DepSpawn application, we need to:

  1. If you want to use the TBB, make sure its environment is correctly set up, which is achieved following the steps described in TBB configuration
  2. Since DepSpawn relies on C++11, if our compiler requires some flag to support it (typically -std=c++0x or -std=c++11), we must apply it
  3. Tell the compiler where to find the DepSpawn headers using the -I flag
  4. Tell the compiler where to find the DepSpawn library using the -L flag
  5. Link with DepSpawn (-ldepspawn) and, if desired, with the TBB (-ltbb)
  6. If the DEPSPAWN_SCALABLE_POOL was set to ON when the library was compiled (see Installing DepSpawn), link also with -ltbbmalloc

So if for example DepSpawn has been installed in /usr/local and our compiler does not automatically use /usr/local/include and /usr/local/lib to find header files and libraries, respectively, then test_subobject.cpp would be compiled using g++ with the command

 g++ -std=c++11 -I/usr/local/include -o test_subobject test_subobject.cpp -L/usr/local/lib -ldepspawn -ltbb

If DepSpawn relies on the TBB, the execution of our application requires that the TBB environment is correctly set up, as some TBB components are dynamically linked, and the TBB configuration allows to find them.

The DepSpawn runtime recognizes the following environment variables:

  • DEPSPAWN_NUM_THREADS defines the number of threads to use in the execution.
  • DEPSPAWN_TASK_QUEUE_LIMIT defines the task queue limit as indicated by set_task_queue_limit(), described in Interface.
  • DEPSPAWN_ENQUEUE_TASKS, when defined, commands DepSpawn to launch tasks to execution using tbb::task::enqueue() instead of tbb::task::spawn() when the TBB is used. Please read the TBB manual on the differences between these task spawning methods.