Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ jobs:
if [[ "${{ matrix.cxx_compiler }}" == "icpx" ]]; then
warning_flags="${warning_flags} -Wno-error=recommended-option"
fi

cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DONEDPL_DEVICE_TYPE=${{ matrix.device_type }} -DCMAKE_CXX_FLAGS="${warning_flags}" ..
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DCMAKE_CXX_FLAGS="${warning_flags}" ..
make VERBOSE=1 -j${BUILD_CONCURRENCY} ${make_targets} |& tee build.log
ONEAPI_DEVICE_SELECTOR=*:${{ matrix.device_type }}
ctest --timeout ${TEST_TIMEOUT} --output-on-failure ${ctest_flags} |& tee ctest.log

# Generate a summary
Expand Down Expand Up @@ -341,12 +341,13 @@ jobs:
set warning_flags=-Wall -Werror -Wno-error=sign-compare -Wno-error=pass-failed
)

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DONEDPL_DEVICE_TYPE=${{ matrix.device_type }} -DCMAKE_CXX_FLAGS="%warning_flags%" ..
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DONEDPL_BACKEND=${{ matrix.backend }} -DCMAKE_CXX_FLAGS="%warning_flags%" ..
if !errorlevel! neq 0 set exit_code=!errorlevel!
for %%t in (%ninja_targets%) do (
ninja -j 2 -v "%%t" >> build.log 2>&1
if !errorlevel! neq 0 set exit_code=!errorlevel!
)
set ONEAPI_DEVICE_SELECTOR=*:${{ matrix.device_type }}
ctest --timeout %TEST_TIMEOUT% -C ${{ matrix.build_type }} --output-on-failure %ctest_flags% > ctest.log 2>&1
if !errorlevel! neq 0 set exit_code=!errorlevel!
type ctest.log
Expand Down
115 changes: 18 additions & 97 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ get_directory_property(_onedpl_is_subproject PARENT_DIRECTORY)
include(CMakeDependentOption)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

option(ONEDPL_FPGA_STATIC_REPORT "Enable the static report generation for the FPGA device" OFF)
option(ONEDPL_USE_AOT_COMPILATION "Enable ahead of time compilation (deprecated)" OFF)
option(ONEDPL_ENABLE_SIMD "Enable SIMD vectorization by passing an OpenMP SIMD flag to the compiler if supported" ON)
cmake_dependent_option(ONEDPL_TEST_WIN_ICX_FIXES "Enable icx workarounds for Windows" ON "CMAKE_HOST_WIN32;NOT _onedpl_is_subproject" OFF)

Expand Down Expand Up @@ -209,95 +207,29 @@ if (ONEDPL_BACKEND MATCHES "^(tbb|dpcpp|dpcpp_only)$")
$<$<BOOL:${SET_BACKEND_TBB}>:ONEDPL_USE_DPCPP_BACKEND=0>
)

if (ONEDPL_BACKEND MATCHES "^(dpcpp|dpcpp_only)$")
# check device type for oneDPL test targets
if (ONEDPL_DEVICE_TYPE MATCHES "^(CPU|GPU|FPGA_EMU|FPGA_HW)$")
if (NOT _ONEDPL_PSTL_OFFLOAD STREQUAL off)
message(FATAL_ERROR "PSTL offload does device selection on its own, ONEDPL_DEVICE_TYPE ${ONEDPL_DEVICE_TYPE} is useless.")
endif()
message(STATUS "Using ${ONEDPL_DEVICE_TYPE} device type")
set(ONEDPL_USE_DEVICE_${ONEDPL_DEVICE_TYPE} TRUE)
elseif (DEFINED ONEDPL_DEVICE_BACKEND)
message(FATAL_ERROR "Unsupported device type: ${ONEDPL_DEVICE_TYPE}.\n"
"Select one of the following devices: CPU, GPU, FPGA_EMU or FPGA_HW")
elseif (NOT _ONEDPL_PSTL_OFFLOAD STREQUAL off)
# PSTL offload does device selection on its own
else()
set(ONEDPL_DEVICE_TYPE "GPU")
message(STATUS "Using a default device type (GPU)")
# Add error for removed feature ONEDPL_DEVICE_TYPE if used
if (DEFINED ONEDPL_DEVICE_TYPE OR DEFINED ONEDPL_DEVICE_BACKEND)
set(device_backend "*")
set(device_type "*")
if (DEFINED ONEDPL_DEVICE_TYPE)
string(TOLOWER "${ONEDPL_DEVICE_TYPE}" device_type)
endif()

# check device backend
if (ONEDPL_DEVICE_BACKEND MATCHES "^(opencl|level_zero|cuda|hip|\\*)$")
message(STATUS "Using ${ONEDPL_DEVICE_BACKEND} device backend")
elseif (DEFINED ONEDPL_DEVICE_BACKEND)
message(FATAL_ERROR "Unsupported device backend: ${ONEDPL_DEVICE_BACKEND}.\n"
"Select one of the following device backends: opencl, level_zero, cuda, hip or *")
else()
set(ONEDPL_DEVICE_BACKEND "*")
message(STATUS "Using a default device backend (*)")
if (DEFINED ONEDPL_DEVICE_BACKEND)
string(TOLOWER "${ONEDPL_DEVICE_BACKEND}" device_backend)
endif()
message(FATAL_ERROR "ONEDPL_DEVICE_TYPE and ONEDPL_DEVICE_BACKEND cmake settings have been removed.\nUse environment variable \"ONEAPI_DEVICE_SELECTOR=${device_backend}:${device_type}\" before running instead for the same effect.")
endif()

if (INTEL_LLVM_COMPILER AND INTEL_LLVM_COMPILER_VERSION VERSION_LESS 2023.1)
set(DEVICE_SELECTION_VARIABLE "SYCL_DEVICE_FILTER")
set(FPGA_DEVICE_TYPE "acc")
else()
set(DEVICE_SELECTION_VARIABLE "ONEAPI_DEVICE_SELECTOR")
set(FPGA_DEVICE_TYPE "fpga")
endif()
if (DEFINED ONEDPL_USE_AOT_COMPILATION)
message(FATAL_ERROR "ONEDPL_USE_AOT_COMPILATION is has been removed, instead use -fsycl-targets directly to CMAKE_CXX_FLAGS to specify ahead-of-time compilation targets.")
endif()

# set up device selection line basing on ONEDPL_DEVICE_BACKEND and ONEDPL_DEVICE_TYPE values
if (DEFINED ONEDPL_DEVICE_BACKEND AND DEFINED ONEDPL_DEVICE_TYPE)
if (ONEDPL_DEVICE_TYPE MATCHES "FPGA")
set(DEVICE_SELECTION_LINE "${DEVICE_SELECTION_VARIABLE}=${ONEDPL_DEVICE_BACKEND}:${FPGA_DEVICE_TYPE}")
else()
string(TOLOWER ${ONEDPL_DEVICE_TYPE} ONEDPL_DEVICE_TYPE)
set(DEVICE_SELECTION_LINE "${DEVICE_SELECTION_VARIABLE}=${ONEDPL_DEVICE_BACKEND}:${ONEDPL_DEVICE_TYPE}")
endif()
endif()

# Check correctness of STATIC_REPORT
if (ONEDPL_FPGA_STATIC_REPORT)
if (NOT ONEDPL_USE_DEVICE_FPGA_HW)
message(FATAL_ERROR "Static report can only be generated for FPGA hardware")
else()
message(STATUS "Static report will be generated")
endif()
endif()

# settings for the specific compilation type
if (NOT ONEDPL_USE_AOT_COMPILATION)
message(STATUS "Using just-in-time compilation")
else()
message(WARNING "ONEDPL_USE_AOT_COMPILATION is deprecated and will be removed in a future release")
if (NOT ONEDPL_AOT_ARCH)
if (ONEDPL_USE_DEVICE_GPU)
set(ONEDPL_AOT_ARCH "*")
endif()
if (ONEDPL_USE_DEVICE_CPU)
set(ONEDPL_AOT_ARCH "avx")
endif()
else()
message(WARNING "ONEDPL_AOT_ARCH is deprecated and will be removed in a future release")
endif()
message(STATUS "Using ahead-of-time compilation for \"${ONEDPL_AOT_ARCH}\" architecture(s)")
if (ONEDPL_BACKEND MATCHES "^(dpcpp|dpcpp_only)$")

if (ONEDPL_USE_DEVICE_GPU)
# -cl-kernel-debug-enable is not needed since https://github.com/intel/compute-runtime/commit/9c237d99ec49ceb3678c815314bc7c745226e4a2
# TODO: remove that option when older driver versions are not expected to be used
set(ONEDPL_AOT_EXTRA_BACKEND_OPTIONS "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-internal_options -cl-kernel-debug-enable>")
set(ONEDPL_AOT_OPTIONS "-fsycl-targets=spir64_gen -Xs \"-device ${ONEDPL_AOT_ARCH} ${ONEDPL_AOT_EXTRA_BACKEND_OPTIONS}\"")
endif()
if (ONEDPL_USE_DEVICE_CPU)
set(ONEDPL_AOT_OPTIONS "-fsycl-targets=spir64_x86_64 -Xs \"-march=${ONEDPL_AOT_ARCH}\"")
endif()
endif()
#DPC++ specific compiler options
target_compile_options(oneDPL INTERFACE ${FSYCL_OPTION_IF_SUPPORTED})

# DPC++ specific compiler options
target_compile_options(oneDPL INTERFACE
${FSYCL_OPTION_IF_SUPPORTED}
$<$<OR:$<BOOL:${ONEDPL_USE_DEVICE_FPGA_HW}>,$<BOOL:${ONEDPL_USE_DEVICE_FPGA_EMU}>>:-fintelfpga>
)
if (DEFINED ONEDPL_USE_UNNAMED_LAMBDA)
if(ONEDPL_USE_UNNAMED_LAMBDA)
message(STATUS "Adding -fsycl-unnamed-lambda option")
Expand All @@ -318,20 +250,9 @@ if (ONEDPL_BACKEND MATCHES "^(tbb|dpcpp|dpcpp_only)$")
endif()
endif()

# DPC++ specific macro
target_compile_definitions(oneDPL INTERFACE
$<$<OR:$<BOOL:${ONEDPL_USE_DEVICE_FPGA_HW}>,$<BOOL:${ONEDPL_USE_DEVICE_FPGA_EMU}>>:ONEDPL_FPGA_DEVICE>
$<$<BOOL:${ONEDPL_USE_DEVICE_FPGA_EMU}>:ONEDPL_FPGA_EMULATOR>
)

# DPC++ specific link options
target_link_libraries(oneDPL INTERFACE
${FSYCL_OPTION_IF_SUPPORTED}
$<$<OR:$<BOOL:${ONEDPL_USE_DEVICE_FPGA_HW}>,$<BOOL:${ONEDPL_USE_DEVICE_FPGA_EMU}>>:-fintelfpga>
$<$<BOOL:${ONEDPL_USE_DEVICE_FPGA_HW}>:-Xshardware>
$<$<AND:$<BOOL:${ONEDPL_USE_DEVICE_FPGA_HW}>,$<BOOL:${ONEDPL_FPGA_STATIC_REPORT}>>:-fsycl-link>
${ONEDPL_AOT_OPTIONS}
)
target_link_libraries(oneDPL INTERFACE ${FSYCL_OPTION_IF_SUPPORTED})

endif()

elseif(ONEDPL_BACKEND MATCHES "^(serial)$")
Expand Down
15 changes: 13 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,27 @@ using the GPU on your local system using the Intel® oneAPI DPC++ Compiler.

1. Configure the build files by running the following command that creates a build directory named `build_gpu_tests`.
```
cmake -DCMAKE_CXX_COMPILER=icpx -DCMAKE_CXX_STANDARD=17 -DONEDPL_BACKEND=dpcpp -DONEDPL_DEVICE_TYPE=gpu -DCMAKE_BUILD_TYPE=release -B build_gpu_tests
cmake -DCMAKE_CXX_COMPILER=icpx -DCMAKE_CXX_STANDARD=17 -DONEDPL_BACKEND=dpcpp -DCMAKE_BUILD_TYPE=release -B build_gpu_tests
```

2. Build the tests
```
cmake --build build_gpu_tests --target build-onedpl-tests # specify a specific test name (e.g., reduce.pass) to build a single test
```

3. Run the tests from the `build_gpu_tests` directory
3. Select GPU device target
* Windows:
```
set ONEAPI_DEVICE_SELECTOR=*:gpu
```
* Linux:
```
ONEAPI_DEVICE_SELECTOR=*:gpu
```

4. Run the tests from the `build_gpu_tests` directory targeting a gpu device
```
cd build_gpu_tests
ctest --output-on-failure --timeout 1200 -R ^reduce.pass$ # Add -R testname (e.g., -R ^reduce.pass$) to run just one test.
```

Expand Down
5 changes: 0 additions & 5 deletions cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ The following variables are provided for oneDPL configuration:
| Variable | Type | Description | Default value |
|------------------------------------------|--------|-----------------------------------------------------------------------------------------------|---------------|
| ONEDPL_BACKEND | STRING | Threading backend; supported values: tbb, dpcpp, dpcpp_only, serial, ...; the default value is defined by compiler: dpcpp for DPC++ and tbb for others | tbb/dpcpp |
| ONEDPL_DEVICE_TYPE | STRING | Select device type for oneDPL test targets; affects only DPC++ backends; supported values: GPU, CPU, FPGA_HW, FPGA_EMU | GPU |
| ONEDPL_DEVICE_BACKEND | STRING | Select device backend type for oneDPL test targets; affects only oneDPL DPC++ backends; supported values: opencl, level_zero, cuda, hip or * (the best backend as per DPC++ runtime heuristics). | * |
| ONEDPL_USE_UNNAMED_LAMBDA | BOOL | Pass `-fsycl-unnamed-lambda`, `-fno-sycl-unnamed-lambda` compile options or nothing | |
| ONEDPL_FPGA_STATIC_REPORT | BOOL | Enable the static report generation for the FPGA_HW device type | OFF |
| ONEDPL_USE_AOT_COMPILATION (deprecated) | BOOL | Enable ahead-of-time compilation for the GPU or CPU device types. Deprecated, use standard CMake means such as `CMAKE_CXX_FLAGS` | OFF |
| ONEDPL_ENABLE_SIMD | BOOL | Enable SIMD vectorization by passing an OpenMP SIMD flag to the compiler if supported; the flag is passed to user project compilation string if enabled | ON |
| ONEDPL_AOT_ARCH (deprecated) | STRING | Architecture options for ahead-of-time compilation, supported values can be found [here](https://software.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html). Deprecated, use standard CMake means such as `CMAKE_CXX_FLAGS` | "*" for GPU device and "avx" for CPU device |
| ONEDPL_TEST_EXPLICIT_KERNEL_NAMES | STRING | Control kernel naming. Affects only oneDPL test targets. Supported values: AUTO, ALWAYS. AUTO: rely on the compiler if "Unnamed SYCL lambda kernels" feature is on, otherwise provide kernel names explicitly; ALWAYS: provide kernel names explicitly | AUTO |
| ONEDPL_TEST_WIN_ICX_FIXES | BOOL | Affects only oneDPL test targets. Enable icx, icx-cl workarounds to fix issues in CMake for Windows. | ON |
| ONEDPL_WORKAROUND_FOR_IGPU_64BIT_REDUCTION | BOOL | Use as a workaround for incorrect results, which may be produced by reduction algorithms with 64-bit data types compiled by the Intel&reg; oneAPI DPC++/C++ Compiler and executed on GPU devices. | |
Expand Down
4 changes: 3 additions & 1 deletion documentation/library_guide/introduction/onedpl_gsg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ the random numbers themselves. Random number generation is performed in a vector
to improve the speed of your computations.

This example performs its computations on your default SYCL device. You can set the
``SYCL_DEVICE_TYPE`` environment variable to CPU or GPU.
``ONEAPI_DEVICE_SELECTOR`` environment variable to control
`device selection <https://www.intel.com/content/www/us/en/docs/oneapi/programming-guide/current/device-selection.html>`_.


.. code:: cpp

Expand Down
3 changes: 2 additions & 1 deletion documentation/library_guide/onedpl_gsg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ the random numbers themselves. Random number generation is performed in a vector
to improve the speed of your computations.

This example performs its computations on your default SYCL device. You can set the
``SYCL_DEVICE_TYPE`` environment variable to CPU or GPU.
``ONEAPI_DEVICE_SELECTOR`` environment variable to control
`device selection <https://www.intel.com/content/www/us/en/docs/oneapi/programming-guide/current/device-selection.html>`_.

.. code:: cpp

Expand Down
15 changes: 0 additions & 15 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,6 @@ macro(onedpl_construct_exec test_source_file _test_name switch_off_checked_itera

set_tests_properties(${_test_name} PROPERTIES SKIP_RETURN_CODE 77)

if (NOT _ONEDPL_PSTL_OFFLOAD STREQUAL off)
if (DEFINED DEVICE_SELECTION_LINE)
message(FATAL_ERROR "PSTL offload tests ${_test_name} don't need ${DEVICE_SELECTION_LINE} variable, so one should be not set.")
endif()
# This test is only one requiring device selection environment, set it manually.
if ("${_test_name}" STREQUAL selected_different_device.pass AND _ONEDPL_PSTL_OFFLOAD MATCHES "(cpu|gpu)")
set_tests_properties(${_test_name} PROPERTIES ENVIRONMENT "${DEVICE_SELECTION_VARIABLE}=${ONEDPL_DEVICE_BACKEND}:${_ONEDPL_PSTL_OFFLOAD}")
endif()
elseif (DEFINED DEVICE_SELECTION_LINE)
file(GLOB_RECURSE DS_TESTS "parallel_api/dynamic_selection/*.cpp")
if (NOT "${DS_TESTS}" MATCHES "${_test_name}") # do not set SYCL_DEVICE_FILTER for dynamic selection tests
set_tests_properties(${_test_name} PROPERTIES ENVIRONMENT ${DEVICE_SELECTION_LINE})
endif()
endif()

add_custom_target(run-${_test_name}
COMMAND "${CMAKE_CTEST_COMMAND}" -R ^${_test_name}$$ --output-on-failure --no-label-summary
USES_TERMINAL
Expand Down
3 changes: 0 additions & 3 deletions test/kt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ function(_generate_test _target_name _test_path)

add_test(NAME ${_target_name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${_target_name})
set_tests_properties(${_target_name} PROPERTIES SKIP_RETURN_CODE 77)
if (DEFINED DEVICE_SELECTION_LINE)
set_tests_properties(${_target_name} PROPERTIES ENVIRONMENT ${DEVICE_SELECTION_LINE})
endif()

add_custom_target(run-${_target_name}
COMMAND "${CMAKE_CTEST_COMMAND}" -R ^${_target_name}$$ --output-on-failure --no-label-summary
Expand Down