Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel ICX Compiler , Intel® DPC++ Compatibility Tool, and GDB*

Cmake OpenMP not found with dpcpp.

Dmitry_Savin
New Contributor I
9,909 Views

I'm porting an OpenMP-based program to the OneAPI. To make an incremental transition I try to compile the existing program with dpcpp. The minimal CMakeLists.txt reproducing the problem in the DevCloud is attached. With the default compiler it works fine. However, if invoked with -DCMAKE_CXX_COMPILER=`which dpcpp`, it fails at the cmake configuration step with an error: > CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message): > Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)

0 Kudos
1 Solution
Dmitry_Savin
New Contributor I
9,909 Views
Hi all, I found that passing the path to the library to cmake explicitly tricks it into "finding" OpenMP. Also it is not recommended to mix different OpenMP implementations, so libiomp5 Intel implementation should be used. The working cmake command line arguments for me are: -DCMAKE_CXX_COMPILER=dpcpp -DOpenMP_CXX_FLAGS="-qopenmp" -DOpenMP_CXX_LIB_NAMES="libiomp5" -DOpenMP_libiomp5_LIBRARY=/opt/intel/inteloneapi/compiler/2021.1-beta03/linux/compiler/lib/intel64_lin/libiomp5.so Tested in the DevCloud with the default cmake.

View solution in original post

0 Kudos
12 Replies
GouthamK_Intel
Moderator
9,909 Views

Hi Dmitry,

Thanks for reaching out to us.

We are working on it and will get back to you.

 

Goutham

0 Kudos
GouthamK_Intel
Moderator
9,909 Views

Hi Dmitry,

Can you please try compiling your code after setting OpenMP_CXX_FLAGS  to -qopenmp

Please let us know if you are facing any issues.

 

Regards

Goutham

0 Kudos
Dmitry_Savin
New Contributor I
9,909 Views

Now only OpenMP_CXX_LIB_NAMES is missing:

CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find OpenMP_CXX (missing: OpenMP_CXX_LIB_NAMES)

0 Kudos
GouthamK_Intel
Moderator
9,909 Views

Hi,

Please try setting the OpenMP lib path in your CMake file.

For your reference: 

set(OpenMP_CXX_LIB_NAMES "libiomp5" "libomp" "libgomp")

Please let us know if this resolves your issue. 

 

Thanks 

Goutham

0 Kudos
Dmitry_Savin
New Contributor I
9,909 Views

Hi Goutham,

It does not. Now it fails with:

> Could NOT find OpenMP_CXX (missing: OpenMP_libiomp5_LIBRARY OpenMP_libomp_LIBRARY OpenMP_libgomp_LIBRARY)

Also manually modifying the source of each project using OpenMP does not seem scalable.

cmake merge request 3916 might be related to this issue, I'll try the latest version and get back.

 

Thanks

Dmitry

 

 

0 Kudos
Dmitry_Savin
New Contributor I
9,909 Views

I found a combination that works:

set(OpenMP_CXX_LIB_NAMES "libiomp5" "libomp" "libgomp") # in CMakeLists.txt

Invoke the latest cmake with

-DOpenMP_CXX_FLAGS="-qopenmp" -DCMAKE_LIBRARY_PATH="$(llvm-config --libdir)" -DCMAKE_CXX_COMPILER=`which dpcpp`

Passing -DOpenMP_CXX_LIB_NAMES="libiomp5;libomp;libgomp" does not work.

Need to study the matter a bit more, so far this workaround can be used.

 

- Dmitry

 

0 Kudos
Dmitry_Savin
New Contributor I
9,910 Views
Hi all, I found that passing the path to the library to cmake explicitly tricks it into "finding" OpenMP. Also it is not recommended to mix different OpenMP implementations, so libiomp5 Intel implementation should be used. The working cmake command line arguments for me are: -DCMAKE_CXX_COMPILER=dpcpp -DOpenMP_CXX_FLAGS="-qopenmp" -DOpenMP_CXX_LIB_NAMES="libiomp5" -DOpenMP_libiomp5_LIBRARY=/opt/intel/inteloneapi/compiler/2021.1-beta03/linux/compiler/lib/intel64_lin/libiomp5.so Tested in the DevCloud with the default cmake.
0 Kudos
GouthamK_Intel
Moderator
9,909 Views

Hi Dmitry,

We tried compiling our sample application with dpcpp using -qopenmp flag alone and we don't see any errors during compilation.

We couldn't reproduce your error as we don't have access to your source code. So, kindly if you can share your source code along with the CMake file we will try to reproduce the same error that you are facing. Please share the steps to reproduce document also.

 

Thanks

Goutham

0 Kudos
Dmitry_Savin
New Contributor I
9,909 Views

Hi Goutham,

The error emerges before the compilation, at the cmake step. The minimal CMakeLists.txt is attached to the original post. The contents of the script submitted to theDevCloud  queue is straightforward:

#!/bin/bash
source /opt/intel/inteloneapi/setvars.sh

cd <a working directory, choose yours>

cmake -DCMAKE_CXX_COMPILER=dpcpp -DOpenMP_CXX_FLAGS="-qopenmp" <path to the directory containing CMakeLists.txt, choose yours>

Substitute the paths in the angle brackets accordingly.

Thanks

Dmitry

UPD: I'll prepare a single-script reproduction when I get to the laptop.

0 Kudos
Dmitry_Savin
New Contributor I
9,909 Views
Attached a script to reproduce. Run it in the DevCloud in a directory where you can write.
0 Kudos
GouthamK_Intel
Moderator
9,909 Views

Hi Dmitry,

Thank you for providing all the required information. we are able to reproduce the same error which you are facing, we found out that CMake is working fine with icpc/icc/icx/icpx compilers but not with dpcpp. 

We will forward this issue to the concerned team to further investigate on this. 

We are glad to see that your issue is resolved with workarounds, Please let us know whether we can close this thread.

 

Thanks

Goutham

 

 

0 Kudos
Dmitry_Savin
New Contributor I
9,909 Views

Hi Goutham,

You can close this thread.

Please let me know if a relevant cmake or llvm issue is opened.

- Dmitry

0 Kudos
Reply