Skip to content
Draft
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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,34 @@ jobs:
-DTBB_CPF=${{ matrix.preview }} -DTBB_TEST=OFF -DTBB_EXAMPLES=ON ..
cmake --build . -v --target light_test_examples

linux-examples-testing-docker:
name: examples_${{ matrix.container_name }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}_preview=${{ matrix.preview }}
runs-on: ['ubuntu-latest']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runs-on: ['ubuntu-latest']
runs-on: ['uxl-gpu-xlarge']

might as well run it on a GPU if available. Note this change should cause the issue #1760 for the cpu examples.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uxl-gpu-large has been removed from the pool.

container:
image: ${{ matrix.container_name }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- container_name: intel/oneapi-basekit:latest
c_compiler: icx
cxx_compiler: icpx
std: 17
build_type: relwithdebinfo
preview: 'OFF'
steps:
- uses: actions/checkout@v4
- name: Run testing
shell: bash
run: |
set -x
mkdir build && cd build
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DTBB_CPF=${{ matrix.preview }} -DTBB_TEST=OFF -DTBB_EXAMPLES=ON ..
cmake --build . -v --target light_test_examples

macos-examples-testing:
name: examples_${{ matrix.os }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}_preview=${{ matrix.preview }}
runs-on: ['${{ matrix.os }}']
Expand Down
8 changes: 8 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,11 @@ tbb_add_example(task_group sudoku)
tbb_add_example(test_all fibonacci)

tbb_add_example(migration recursive_fibonacci)

if (${CMAKE_CXX_COMPILER_ID} MATCHES "IntelLLVM")
tbb_add_example(sycl tbb-task-sycl)
tbb_add_example(sycl tbb-async-sycl)
tbb_add_example(sycl tbb-resumable-tasks-sycl)
else ()
message(WARNING "Intel(R) oneAPI DPC++/C++ Compiler is not used, sycl examples are excluded from the build.")
endif()
1 change: 0 additions & 1 deletion examples/common/cmake/modules/FindTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ if (_tbb_include_dir)
)
else()
find_library(${_tbb_component_lib_name}_so ${_tbb_component_lib_name} PATHS ${ADDITIONAL_LIB_DIRS})

set_target_properties(TBB::${_tbb_component} PROPERTIES
IMPORTED_LOCATION_${_TBB_BUILD_MODE} "${${_tbb_component_lib_name}_so}"
)
Expand Down
12 changes: 6 additions & 6 deletions examples/sycl/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code Samples of Intel(r) oneAPI Threading Building Blocks (oneAPI TBB)
# Code Samples demonstrating interoperability of oneAPI Threading Building Blocks with SYCL

| Code sample name | Supported Intel(r) Architecture(s) | Description
|:--- |:--- |:---
| tbb-async-sycl | GPU, CPU | The calculations are split between TBB Flow Graph asynchronous node that calls SYCL* kernel on GPU while TBB functional node does CPU part of calculations.
| tbb-task-sycl | GPU, CPU | One TBB task executes SYCL code on GPU while another TBB task performs calculations using TBB parallel_for.
| tbb-resumable-tasks-sycl | GPU, CPU | The calculations are split between TBB resumable task that calls SYCL kernel on GPU while TBB parallel_for does CPU part of calculations.
| Code sample name | Description
|:--- |:---
| tbb-async-sycl | The calculations are split between TBB Flow Graph asynchronous node that calls SYCL* kernel on GPU while TBB functional node does CPU part of calculations.
| tbb-task-sycl | One TBB task executes SYCL code on GPU while another TBB task performs calculations using TBB parallel_for.
| tbb-resumable-tasks-sycl | The calculations are split between TBB resumable task that calls SYCL kernel on GPU while TBB parallel_for does CPU part of calculations.
49 changes: 41 additions & 8 deletions examples/sycl/tbb-async-sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required (VERSION 3.4)
cmake_minimum_required(VERSION 3.5.0...3.31.3)

if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(CMAKE_CXX_COMPILER "icx-cl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl")
set(sycl_sample_name tbb-async-sycl)
project(${sycl_sample_name} CXX)

include(../../common/cmake/common.cmake)

set_common_project_settings(tbb)

add_executable(${sycl_sample_name} ${sycl_sample_name}.cpp)
set_target_properties(${sycl_sample_name} PROPERTIES CXX_STANDARD 17)

get_target_property(is_tbb_imported TBB::tbb IMPORTED)
if (is_tbb_imported)
get_target_property(tbb_imported_configurations TBB::tbb IMPORTED_CONFIGURATIONS)
if (NOT tbb_imported_configurations MATCHES "RELEASE")
set(should_issue_warning TRUE)
target_link_libraries(${sycl_sample_name} PRIVATE TBB::tbb)
else()
target_link_libraries(${sycl_sample_name} PRIVATE "$<TARGET_PROPERTY:TBB::tbb,IMPORTED_LOCATION_RELEASE>")
endif()
else()
set(CMAKE_CXX_COMPILER "icpx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl")
if (CMAKE_BUILD_TYPE MATCHES "debug")
set(should_issue_warning TRUE)
endif()
target_link_libraries(${sycl_sample_name} PRIVATE TBB::tbb)
endif()

project (TBB-ASYNC-SYCL LANGUAGES CXX)
add_subdirectory (src)

if (should_issue_warning AND NOT TBB_SYCL_SAMPLES_WARNING_SHOWN)
message( WARNING
"Using Debug version of TBB in SYCL application may cause crashes due to conflicts \
between Release and Debug version of TBB within the same application."
)
set(TBB_SYCL_SAMPLES_WARNING_SHOWN TRUE CACHE BOOL "")
endif()

target_compile_options(${sycl_sample_name} PRIVATE -fsycl)
target_link_options(${sycl_sample_name} PRIVATE -fsycl)

add_execution_target(run_${sycl_sample_name} ${sycl_sample_name} "$<TARGET_FILE:${sycl_sample_name}>" "")
add_execution_target(light_test_${sycl_sample_name} ${sycl_sample_name} "$<TARGET_FILE:${sycl_sample_name}>" "")

unset(sycl_sample_name)
unset(should_issue_warning)
34 changes: 0 additions & 34 deletions examples/sycl/tbb-async-sycl/src/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@
#include <tbb/flow_graph.h>
#include <tbb/global_control.h>
#include <tbb/parallel_for.h>
// dpc_common.hpp can be found in the dev-utilities include folder.
// e.g., $ONEAPI_ROOT/dev-utilities//include/dpc_common.hpp
#include "dpc_common.hpp"

static auto exception_handler = [](sycl::exception_list eList) {
for (std::exception_ptr const& e : eList) {
try {
std::rethrow_exception(e);
}
catch (std::exception const& e) {
#if _DEBUG
std::cout << "Failure" << std::endl;
#endif
std::terminate();
}
}
};

struct done_tag {};

Expand Down Expand Up @@ -80,7 +91,7 @@ class AsyncActivity {
sycl::buffer b_buffer(b_array);
sycl::buffer c_buffer(c_array);

sycl::queue q(sycl::default_selector_v, dpc_common::exception_handler);
sycl::queue q(sycl::default_selector_v, exception_handler);
q.submit([&](sycl::handler& h) {
sycl::accessor a_accessor(a_buffer, h, sycl::read_only);
sycl::accessor b_accessor(b_buffer, h, sycl::read_only);
Expand Down
48 changes: 40 additions & 8 deletions examples/sycl/tbb-resumable-tasks-sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required (VERSION 3.4)
cmake_minimum_required(VERSION 3.5.0...3.31.3)

if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(CMAKE_CXX_COMPILER "icx-cl")
set(CMAKE_CXX_FLAGS "fsycl")
set(sycl_sample_name tbb-resumable-tasks-sycl)
project(${sycl_sample_name} CXX)

include(../../common/cmake/common.cmake)

set_common_project_settings(tbb)

add_executable(${sycl_sample_name} ${sycl_sample_name}.cpp)
set_target_properties(${sycl_sample_name} PROPERTIES CXX_STANDARD 17)

get_target_property(is_tbb_imported TBB::tbb IMPORTED)
if (is_tbb_imported)
get_target_property(tbb_imported_configurations TBB::tbb IMPORTED_CONFIGURATIONS)
if (NOT tbb_imported_configurations MATCHES "RELEASE")
set(should_issue_warning TRUE)
target_link_libraries(${sycl_sample_name} PRIVATE TBB::tbb)
else()
target_link_libraries(${sycl_sample_name} PRIVATE "$<TARGET_PROPERTY:TBB::tbb,IMPORTED_LOCATION_RELEASE>")
endif()
else()
set(CMAKE_CXX_COMPILER "icpx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl")
if (CMAKE_BUILD_TYPE MATCHES "debug")
set(should_issue_warning TRUE)
endif()
target_link_libraries(${sycl_sample_name} PRIVATE TBB::tbb)
endif()


if (should_issue_warning AND NOT TBB_SYCL_SAMPLES_WARNING_SHOWN)
message( WARNING
"Using Debug version of TBB in SYCL application may cause crashes due to conflicts \
between Release and Debug version of TBB within the same application."
)
set(TBB_SYCL_SAMPLES_WARNING_SHOWN TRUE CACHE BOOL "")
endif()

project (TBB-RESUMABLE-TASKS-SYCL LANGUAGES CXX)
add_subdirectory (src)
target_compile_options(${sycl_sample_name} PRIVATE -fsycl)
target_link_options(${sycl_sample_name} PRIVATE -fsycl)

add_execution_target(run_${sycl_sample_name} ${sycl_sample_name} "$<TARGET_FILE:${sycl_sample_name}>" "")
add_execution_target(light_test_${sycl_sample_name} ${sycl_sample_name} "$<TARGET_FILE:${sycl_sample_name}>" "")

unset(sycl_sample_name)
unset(should_issue_warning)
35 changes: 0 additions & 35 deletions examples/sycl/tbb-resumable-tasks-sycl/src/CMakeLists.txt

This file was deleted.

48 changes: 40 additions & 8 deletions examples/sycl/tbb-task-sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required (VERSION 3.4)
cmake_minimum_required(VERSION 3.5.0...3.31.3)

if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(CMAKE_CXX_COMPILER "icx-cl")
set(CMAKE_CXX_FLAGS "fsycl")
set(sycl_sample_name tbb-task-sycl)
project(${sycl_sample_name} CXX)

include(../../common/cmake/common.cmake)

set_common_project_settings(tbb)

add_executable(${sycl_sample_name} ${sycl_sample_name}.cpp)
set_target_properties(${sycl_sample_name} PROPERTIES CXX_STANDARD 17)

get_target_property(is_tbb_imported TBB::tbb IMPORTED)
if (is_tbb_imported)
get_target_property(tbb_imported_configurations TBB::tbb IMPORTED_CONFIGURATIONS)
if (NOT tbb_imported_configurations MATCHES "RELEASE")
set(should_issue_warning TRUE)
target_link_libraries(${sycl_sample_name} PRIVATE TBB::tbb)
else()
target_link_libraries(${sycl_sample_name} PRIVATE "$<TARGET_PROPERTY:TBB::tbb,IMPORTED_LOCATION_RELEASE>")
endif()
else()
set(CMAKE_CXX_COMPILER "icpx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl")
if (CMAKE_BUILD_TYPE MATCHES "debug")
set(should_issue_warning TRUE)
endif()
target_link_libraries(${sycl_sample_name} PRIVATE TBB::tbb)
endif()


if (should_issue_warning AND NOT TBB_SYCL_SAMPLES_WARNING_SHOWN)
message( WARNING
"Using Debug version of TBB in SYCL application may cause crashes due to conflicts \
between Release and Debug version of TBB within the same application."
)
set(TBB_SYCL_SAMPLES_WARNING_SHOWN TRUE CACHE BOOL "")
endif()

project (TBB-TASK-SYCL LANGUAGES CXX)
add_subdirectory (src)
target_compile_options(${sycl_sample_name} PRIVATE -fsycl)
target_link_options(${sycl_sample_name} PRIVATE -fsycl)

add_execution_target(run_${sycl_sample_name} ${sycl_sample_name} "$<TARGET_FILE:${sycl_sample_name}>" "")
add_execution_target(light_test_${sycl_sample_name} ${sycl_sample_name} "$<TARGET_FILE:${sycl_sample_name}>" "")

unset(sycl_sample_name)
unset(should_issue_warning)
Loading