Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brycelelbach/601f9faf9228264dfbc598f44c368414 to your computer and use it in GitHub Desktop.
Save brycelelbach/601f9faf9228264dfbc598f44c368414 to your computer and use it in GitHub Desktop.
`/opt/intel/oneapi/tbb/latest/env/vars.sh` doesn't set the proper CMake variables

/opt/intel/oneapi/tbb/latest/env/vars.sh doesn't setup CMake variables in a way that will lead to TBB being successfully detected.

In the latest OneAPI Debian packages (as of today 2020-12-21), the TBB shared libraries are located in /opt/intel/oneapi/tbb/2021.1.1/lib/intel64/gcc4.8/*.

/opt/intel/oneapi/tbb/latest/env/vars.sh sets CMAKE_PREFIX_PATH to ${TBBROOT}, aka /opt/intel/oneapi/tbb/2021.1.1. That's not helpful - here's how CMake's find_library uses CMAKE_PREFIX_PATH:

[...] 2. Search paths specified in cmake-specific environment variables. These are intended to be set in the user’s shell configuration, and therefore use the host’s native path separator (; on Windows and : on UNIX). This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed or by setting the CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PAT to FALSE.

  • <prefix>/lib/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and <prefix>/lib for each <prefix> in CMAKE_PREFIX_PATH
  • CMAKE_LIBRARY_PATH
  • CMAKE_FRAMEWORK_PATH

By setting CMAKE_PREFIX_PATH to /opt/intel/oneapi/tbb/2021.1.1, you're telling CMake to search in /opt/intel/oneapi/tbb/2021.1.1/lib, but TBB is not there.

Instead you shoulkd probably be setting CMAKE_LIBRARY_PATH, which should be a semicolon or colon separated list of paths. The OneAPI vars.sh scripts already correctly setup LIBRARY_PATH in this format - for example, for me, it's:

LIBRARY_PATH=/opt/intel/oneapi/tbb/2021.1.1/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin:/opt/intel/oneapi/compiler/2021.1.1/linux/lib:/usr/local/cuda/lib64/stubs

which, as you can see, has the correct path to the TBB libraries in there.

If you just set CMAKE_LIBRARY_PATH to the same thing, everything would work fine.

Alternatively, it would be very nice if y'all could provide a CMake package configuration and find script for TBB. @allisonvacanti from my team can give you some advice on how to do that.

  • The TBB libraries being in a directory called gcc4.8 seems odd in and of itself. Why aren't they just in lib/intel64? That's what a lot of tools expect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment