- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When sourcing setvars.sh, the result sets the CPATH environment variable to all of the include directories. According to the gcc documentation:
CPATH specifies a list of directories to be searched as if specified with -I, but after any paths given with -I options on the command line.
This means they are not treated as system headers. This causes two issues:
- If I have lots of warnings turned on, the oneapi headers (in particular, MPI) cause all sorts of warnings.
- When using cmake and linking against, for example, OpenMPI, cmake will include the OpenMPI headers as system headers with -isystem. The non-system headers from CPATH will be included first by GCC (before the -isystem headers), and you end up using oneapi MPI headers when you shouldn't.
The correct place for the include directories are these three environment variables:
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
According to the gcc documentation:
The remaining environment variables apply only when preprocessing the particular language indicated. Each specifies a list of directories to be searched as if specified with -isystem, but after any paths given with -isystem options on the command line.
This fixes both of the issues above.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reaching out to us.
Could you please let us know the OS details and Intel oneAPI version?
>>When using cmake and linking against, for example, OpenMPI, cmake will include the OpenMPI headers as system headers with -isystem. The non-system headers from CPATH will be included first by GCC (before the -isystem headers), and you end up using oneapi MPI headers when you shouldn't.
Could you please elaborate more on this statement with a sample reproducer along with the steps to reproduce the issue from our end?
And also, please let us know the scenario of your use case?
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attached is a reproducer. See README.txt in the the zip file.
My use case is I have the oneapi basekit installed. I do not control this install so I cannot dictate which components are installed. I want to use the oneapi MKL but not the oneapi MPI. I build with lots of warnings turned on. The cmake build has been set up to use the openmpi3 headers as system headers. The oneapi CPATH setting overrides the cmake build and forces the build to use the oneapi MPI headers as non-system headers. Rather than setting CPATH, it should be setting the three environment variables I noted above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
>>"I want to use the oneapi MKL but not the oneapi MPI."
Could you please try to initialize only oneAPI MKL component by using the below command?
source /opt/intel/oneapi/mkl/2022.0.1/env/vars.sh
We tried the above command at our end. Please find the below screenshot for the CPATH and LD_LIBRARY_PATH, after initializing oneAPI MKL component:
We can see from the above screenshot that only MKL include and library paths have been set to the environment.
Since Intel MPI isn't initialized yet, now try to check the mpirun --version. We will get openmpi version, but not Intel MPI.
mpirun --version (or) mpiexec --version
Now, you can use oneAPI MKl and OpenMPI.
Please let us know if this resolves your issue.
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That solves one issue, but not all of the them. For example, it does not solve the first issue I noted in my original post. By putting header directories in CPATH, gcc includes them as normal headers. This is wrong. The oneapi headers are system headers. Since they are being added as non-system headers, any warnings I have turned on will generate warnings from the oneapi headers. We would like to switch to oneapi MPI, but we cannot because it generates lots of warnings due to the incorrect use of CPATH. Note that this is not constrained to just oneapi MPI. Since all of the oneapi headers are in CPATH, any warning I turn on has the potential to start generating warnings from the oneapi headers. This is only corrected by putting the header directories in the correct environment variables that I noted in my original post. Please read the gcc documentation that I linked to verify what I am saying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We are working on your issue. We will get back to you soon.
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you please let us know if your build is generating only warnings or warnings that turn into errors?
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I apologize for the delay.
When we initialize the Intel oneAPI environment all the directories will be placed in the CPATH. In case, if we want it to be added in the C_INCLUDE_PATH /CPLUS_INCLUDE_PATH we need to add them manually using the relevant options.
Please find the below equivalent options for setting the Environment Variables.
Environment Variable Equivalent option
CPATH -I
C_INCLUDE_PATH -isystem
CPLUS_INCLUDE_PATH -cxx-isystem
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know this. We work around this bug by using a wrapper script that calls setvars.sh and then sets C_INCLUDE_PATH and CPLUS_INCLUDE_PATH and unsets CPATH. If setvars.sh set these correctly rather than CPATH, we wouldn't have to use a wrapper script.
I want to note that the oneapi clck library correctly sets CPLUS_INCLUDE_PATH and not CPATH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For the Clang-based compiler, the directories will be included the CPATH environment variable. It is not because of the Intel oneAPI setvars. In case, if we want it to be added in the C_INCLUDE_PATH /CPLUS_INCLUDE_PATH we need to add them manually by using the relevant options.
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your statement doesn't make sense. Please pass this on to someone who understands what the issue is here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We are working on your issue and will get back to you soon.
Thanks & Regards,
Varsha

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page