Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

_OPENMP macro not defined?

Yo_At_Taiwan
Beginner
4,564 Views

I recently installed oneAPI DPC++ 2022.0.3 wiht Visual Studio 2022 and was trying to use OpenMP and its off-loading capability.  I have two issues:

1. Why _OPENMP macro is not defined (even though OpenMP support is turned on)?  I thought OpenMP standard says _OPENMP macro should be defined if OpenMP is supported? 

2. When I "Enable OpenMP Offloading" with "Generate device binary for Intel(R) GPUs...", I got compilation error with message: "Error: Device name missing." (In Visual studio 2022 output window) ... Any idea how to resolve this issue? 

 

Thanks,

Yo@Taiwan

0 Kudos
8 Replies
MadhuK_Intel
Moderator
4,482 Views

Hi,


Thank you for posting in Intel communities.


Could you please provide the sample reproducer code and steps to reproduce your issue at our end? If possible please attach the project file by zipping it.


Thanks and regards,

Madhu



0 Kudos
Yo_At_Taiwan
Beginner
4,370 Views

The project file is attached. 

0 Kudos
MadhuK_Intel
Moderator
4,430 Views

Hi,


We haven't heard back from you. Could you please let us know if your issue is resolved, if not could you please respond to the above-asked questions to investigate your issue further?


Best Regards,

Madhu


0 Kudos
Yo_At_Taiwan
Beginner
4,294 Views

Hi! 

The visual studio project has been uploaded. The OpenMP option is enabled in the project properties, but the program would respond with "OpenMP not supported" because _OPENMP is not defined.  Furthermore, if OpenMP offloading to Intel GPU option is turned on, the compilation fails.

 

Yo@Taiwan

0 Kudos
VarshaS_Intel
Moderator
4,214 Views

Hi,

 

>>The OpenMP option is enabled in the project properties, but the program would respond with "OpenMP not supported" because _OPENMP is not defined.

From the sample reproducer which was provided by you, we found that the OpenMP option is not enabled. We have tried enabling the OpenMP option and it displays the correct output. Please find the below screenshot:

OpenMPOutput.png

 

Please find the path for enabling the OpenMP, Project Properties-->DPC++-->Language-->OpenMP Support-->Select the "Generate Parallel Code (/Qiopenmp)" from the dropdown. 

 

>>OpenMP offloading to Intel GPU option is turned on, the compilation fails.

We are working on your issue internally, we will get back to you soon.

 

Thanks & Regards,

Varsha

 

0 Kudos
j-stephan
Beginner
4,113 Views

I'm seeing a similar issue on Linux. dpcpp fails to compile the following OpenMP code while icpx works.

#include <omp.h>
int main(void) {
#ifdef _OPENMP
  omp_get_max_threads();
  return 0;
#elif defined(__HIP_DEVICE_COMPILE__)
  return 0;
#else
  breaks_on_purpose
#endif
}

With icpx:

$ icpx --version
Intel(R) oneAPI DPC++/C++ Compiler 2022.0.0 (2022.0.0.20211123)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2022.0.2/linux/bin-llvm

$ icpx -fiopenmp -fopenmp-targets=spir64 OpenMPTryFlag.cpp
# Successfully generates a.out

With dpcpp:

$ dpcpp --version
Intel(R) oneAPI DPC++/C++ Compiler 2022.0.0 (2022.0.0.20211123)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2022.0.2/linux/bin-llvm

$ dpcpp -fiopenmp -fopenmp-targets=spir64 OpenMPTryFlag.cpp 
OpenMPTryFlag.cpp:10:3: error: use of undeclared identifier 'breaks_on_purpose'
  breaks_on_purpose
  ^
1 error generated.
0 Kudos
Ethan_F_Intel
Moderator
3,727 Views

I was able to reproduce the issue both with VS and with the command line. Seems there is not currently support for the keyword "spir64_gen" with icx or icpx. When I used "spir64" it worked fine for me though. Is this an okay workaround?

 

https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/offload-openmp-and-parallel-processing-options/fopenmp-targets-qopenmp-targets.html

0 Kudos
Ethan_F_Intel
Moderator
3,671 Views

Has your issue been resolved? If I don't hear from you within 5 business days, I will assume your support request is resolved. 

0 Kudos
Reply