1
votes

In order to get Intel TBB (Thread Building Blocks) to work with visual studio 2015, I tried the following approach (because, by default, the built binaries are only for upto vs2013).

Compile Intel TBB with Visual Studio 2015 -

  1. Download source code of Intel TBB from Here.
  2. Extract it,
  3. Open the VS2010 Solution makefile.sln with path tbb<version>\build\VS2010
  4. Approve the conversion of project file to use Visual 2015 toolkit
  5. Select Debug Configuration and x64 Platform and buid. (note if already done previous build, then re-build (clean and build)).
  6. Copy the dll, pdb, lib, exp, def files from tbb<version>\build\VS2010\intel64\Debug to tbb<version>\lib\Debug.

Create New Empty Visual C++ Project

Make the following changes for the debug, x64 configuration

  1. Add additional include directories tbb<version>\include
  2. Add additional Library Directories tbb<version>\lib\Debug
  3. Add the following library dependencies

    tbbmalloc_debug.lib
    tbbmalloc_proxy_debug.lib
    tbb_debug.lib
    
  4. Select Debug, x64 configuration and Build. The Build was successful.

The Code used to test this is below:

#include <iostream>
#include <vector>
#include <random>

#include <tbb/parallel_for.h>

// #include "..\Headers\MexMem.hpp"

using namespace std;

int main() {

    std::vector<int> A(100, 0);
    std::vector<int> B(100, 0);
    std::vector<int> C(100, 0);

    mt19937_64 RandNoEngine;
    uniform_int_distribution<int> RandNoGenerator;

    for (int i = 0; i < A.size(); ++i) {
        A[i] = RandNoGenerator(RandNoEngine);
        B[i] = RandNoGenerator(RandNoEngine);
    }

    tbb::parallel_for(tbb::blocked_range<int>(0, 100), [&](tbb::blocked_range<int> &Range) {
        int beg = Range.begin();
        int end = Range.end();
        for (int i = beg; i < end; ++i) {
            C[i] = A[i] * B[i];
        }
    });
    cout << A[30] << " * " << B[30] << " = " << C[30] << endl;
    system("pause");
    return 0;
}

Press F5 to debug, Here I get an Error of The program can't start because MSVCP120D.dll is missing from your computer. Try reinstalling the program to fix this problem. Next message is related to MSVCR120D.dll. Note that this is occurring after building everything (including the TBB Libraries) using Visual 2015.

Additional Info

A quick analysis with Dependancy Walker (depends.exe) gives the following results:

THe dependency of tbb_debug.lib is as below

- TBB_DEBUG.dll 
   - KERNEL32.DLL
   - MSVCP140D.DLL
   - VCRUNTIME140D.DLL
   - UCRTBASED.DLL

However the Dependencies of tbb_debug.lib as shown in the Exe (exe of above program) is as below:

- TBB_EXPERIMENT.EXE
   - TBB_DEBUG.dll
      ? MSVCP120D.DLL
      ? MSVCR120D.DLL
      - KERNEL32.

Why the discrepancy? Is there any way to get more info related to this, and finally, is there a way to correctly compile and debug Intel TBB on Visual Studio 2015?

1
Have you checked the full path in Depends to the DLL? This looks like it is loading the wrong TBB_DEBUG.dll.1201ProgramAlarm
@1201ProgramAlarm Ah Yes. That indeed seems to be the case. I think this is because I recently upgraded The Visual Studio and something is still forcing Visual Studio to prod into the Composer studio Libs. I will look into what is causing this, see if i can fix it and let you know.Atimaharjun
@1201ProgramAlarm You hit the nail on the head. While working on the previous version, I had included the redistributable library folder of Intel TBB in the Path Environment Variable which causes Visual Studio to bypass the folders I had told it to look into. Please Post Your Comment as an answer, I will mark it as accepted.Atimaharjun

1 Answers

1
votes

This looks like it is loading the wrong TBB_DEBUG.DLL. Check the full path to the DLL in Dependency Walker.