-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SYCL support discovery to check for -fsycl
flag.
#450
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix! I have one minor comment but overall looks good to me.
if(C_COMPILER_NAME MATCHES "^clang" OR CXX_COMPILER_NAME MATCHES "^clang") | ||
set(CLANG_COMPILER ON) | ||
|
||
if(NOT DEFINED SYCL_COMPILER OR SYCL_COMPILER MATCHES OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach could not work correctly for case when MKLConfig is used for building non-SYCL app with clang compiler that supports SYCL, but I believe this fix is enough for oneMKL project build. We can update this part later with more general fix from Intel oneMKL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! I have some suggestions.
include(CMakePackageConfigHelpers) | ||
include(CheckCXXCompilerFlag) | ||
include(CheckIncludeFileCXX) | ||
include(GNUInstallDirs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include(CMakePackageConfigHelpers) | |
include(CheckCXXCompilerFlag) | |
include(CheckIncludeFileCXX) | |
include(GNUInstallDirs) | |
include(CheckCXXCompilerFlag) | |
include(CheckIncludeFileCXX) |
I think we can delete the first line include(CMakePackageConfigHelpers)
and the fourth line include(GNUInstallDirs)
. CheckCXXCompilerFlag
is needed for check_cxx_compiler_flag()
, and CheckIncludeFileCXX
is needed for CHECK_INCLUDE_FILE_CXX()
.
set(SYCL_COMPILER ON) | ||
|
||
include(CMakePackageConfigHelpers) | ||
include(CheckCXXCompilerFlag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put this block in a condition please?
if("CXX" IN_LIST CURR_LANGS)
include(CheckCXXCompilerFlag)
include(CheckIncludeFileCXX)
check_cxx_compiler_flag("-fsycl" _fsycl_option)
...
if (_sycl_header OR _sycl_header_old)
set(SYCL_COMPILER ON)
endif()
endif()
endif()
Although only CXX is used in oneMKL interfaces, oneMKL also needs to support C and Fortran. There is a possibility that users would use MKLConfig.cmake
here with oneMKL.
if(C_COMPILER_NAME MATCHES "^clang" OR CXX_COMPILER_NAME MATCHES "^clang") | ||
set(CLANG_COMPILER ON) | ||
|
||
if(NOT DEFINED SYCL_COMPILER OR SYCL_COMPILER MATCHES OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean
if(NOT DEFINED SYCL_COMPILER OR SYCL_COMPILER MATCHES OFF) | |
if(NOT SYCL_COMPILER) |
check_cxx_compiler_flag("-fsycl" _fsycl_option) | ||
if (_fsycl_option) | ||
CHECK_INCLUDE_FILE_CXX("sycl/sycl.hpp" _sycl_header "-fsycl") | ||
if (NOT _sycl_header) | ||
CHECK_INCLUDE_FILE_CXX("CL/sycl.hpp" _sycl_header_old "-fsycl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SYCL_SYCL_HPP
and CL_SYCL_HPP
might be more expressive than _sycl_header
and _sycl_header_old
. It would be great if you also use COMPILER_FSYCL_SUPPORT
instead of _fsycl_option
. Please note that the convention in MKLConfig.cmake
is to use all caps for variable names.
In addition, please consider removing the space after if
to match the style in the file:
if(<condition>)
Description
oneMKL's CMake currently checks
CXX_COMPILER_NAME
and uses that to determine whether SYCL is supported. This prevents SYCL support from being detected if the user compiles with their own build ofintel/llvm
(see issue #449).This is a first stab at modifying
MKLConfig.cmake
to check for-fsycl
support directly instead of inferring from the compiler name. It is based on how oneDPL checks for SYCL support, which works for both release builds of IntelLLVM and custom builds ofintel/llvm
.I have also modified the CMake to avoid setting
CLANG_COMPILER
ifSYCL_COMPILER
is set, as this is the behavior when using IntelLLVM. I assume open-source DPC++ builds should behave similarly.Fixes #449
Checklist
All Submissions
New interfaces
it was accepted? # (RFC)
New features
Bug fixes
GitHub issue or in this PR)?