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*

SYCL example keeps crashing

JeroenBoschma
Novice
1,338 Views

After evenings of attempts, I hope someone can tell me what is wrong with my setup. The CMake files are a stripped version of a much larger project I work on, and where I wanted to integrate SYCL in. The SYCL code in this post is a simple example from the Khronos website.

Yesterday I reinstalled the newest OneAPI development kit. I just post all my files here, to be sure I do not forget an important clue. Files may have some 'legacy' contents from the larger project.

My CMakePresets.json:

{
    "version": 2,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 25,
        "patch": 0
    },

    "configurePresets": [
        {
            "name": "windows-default",
            "displayName": "Windows x64 Release",
            "description": "Sets Ninja generator, compilers, x64 architecture, build and install directory",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build/${presetName}",
            "architecture": {
                "value": "x64",
                "strategy": "external"
            },
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Debug",
                "CMAKE_BUILD_PARALLEL_LEVEL": "10",
                "CMAKE_C_COMPILER": "C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icx.exe",
                "CMAKE_CXX_COMPILER": "C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icx.exe"
            },
            "environment": {
                "PATH": "C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin;$penv{PATH}",
                "INCLUDE": "C:/Program Files (x86)/Intel/oneAPI/compiler/latest/include;$penv{INCLUDE}",
                "LIB": "C:/Program Files (x86)/Intel/oneAPI/compiler/latest/lib;$penv{LIB}"
            },
            "vendor": {
                "microsoft.com/VisualStudioSettings/CMake/1.0": {
                    "hostOS": [ "Windows" ]
                }
            }
        }
    ]
}

My top-level CMakeLists file (which now only includes the test-executable to build):

cmake_minimum_required(VERSION 3.25.0)
project(GUI LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)

if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
    find_package(IntelSYCL REQUIRED)
endif()

add_compile_definitions("CMAKE_SOURCE_ROOT=${CMAKE_SOURCE_DIR}")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

add_subdirectory(gui)

add_library(compiler_options INTERFACE)

if (CMAKE_BUILD_TYPE MATCHES Debug)
    target_compile_options(compiler_options INTERFACE
        $<$<CXX_COMPILER_ID:IntelLLVM>:
            -Wall -Wextra
            -g -Od
            -Wno-format-security
        >
    )
else()
    target_compile_options(compiler_options INTERFACE
        $<$<CXX_COMPILER_ID:IntelLLVM>:
            -Wall -Wextra
            -O3
            -Wno-format-security
        >
    )
endif()

add_link_options($<$<CXX_COMPILER_ID:IntelLLVM>:-fuse-ld=lld>)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)

My application CMakeLists:

add_executable(
    gui 
    gui.cpp
)
add_sycl_to_target(
    TARGET 
        gui
    SOURCES 
        gui.cpp
)

target_include_directories(gui PUBLIC ${CMAKE_SOURCE_DIR})
target_include_directories(gui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

find_package(OpenGL REQUIRED)

target_link_libraries(
    gui
    PRIVATE
        compiler_options
        OpenGL::GL
)
add_link_options($<$<CXX_COMPILER_ID:IntelLLVM>:-fsycl>)

And finally the SYCL code:

#include <sycl/sycl.hpp>

#include <iostream>

int main()
{
    auto platforms = sycl::platform::get_platforms();

    for (auto& platform : platforms) {
        std::cout
            << "Platform: "
            << platform.get_info<sycl::info::platform::name>()
            << std::endl;

        auto devices = platform.get_devices();
        for (auto& device : devices) {
            std::cout
                << "  Device: "
                << device.get_info<sycl::info::device::name>()
                << std::endl;
        }
    }
    return -1;
}

Crashing occurs directly on the first SYCL call, but I have also seen it crashing in the second for-loop.

I edit, compile and run from the Visual Studio 2022 IDE.

What may be a clue: I get hundreds of warnings from the OneAPI header files themselves:

C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\ext\oneapi\filter_selector.hpp(37,46): warning : 'device_selector' is deprecated: Use SYCL 2020 callable device selectors instead. [-Wdeprecated-declarations]
     37 | class __SYCL_EXPORT filter_selector : public device_selector {
        |                                              ^
  C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\device_selector.hpp(38,21): note: 'device_selector' has been explicitly marked deprecated here
     38 | class __SYCL_EXPORT __SYCL2020_DEPRECATED(
        |                     ^
  C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\detail\defines_elementary.hpp(62,40): note: expanded from macro '__SYCL2020_DEPRECATED'
     62 | #define __SYCL2020_DEPRECATED(message) __SYCL_DEPRECATED(message)
        |                                        ^
  C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\detail\defines_elementary.hpp(53,38): note: expanded from macro '__SYCL_DEPRECATED'
     53 | #define __SYCL_DEPRECATED(message) [[deprecated(message)]]
        |                                      ^
  In file included from C:\Users\boschmajj\OneDrive - TNO\SYCL\gui\gui.cpp:1:
  In file included from C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\sycl.hpp:49:
  In file included from C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\detail\core.hpp:21:
C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\accessor.hpp(1786,12): warning : 'atomic<unsigned int, sycl::access::address_space::global_space>' is deprecated: sycl::atomic is deprecated since SYCL 2020 [-Wdeprecated-declarations]
   1786 |     return atomic<DataT, AS>(multi_ptr<DataT, AS, access::decorated::yes>(
        |            ^
  C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\stream.hpp(538,21): note: in instantiation of function template specialization 'sycl::accessor<unsigned int, 1, sycl::access::mode::atomic, sycl::access::target::device>::operator[]<1>' requested here
    538 |   Cur = GlobalOffset[0].load();
        |                     ^
  C:\Program Files (x86)\Intel\oneAPI\compiler\latest\include\sycl\atomic.hpp(173,7): note: 'atomic<unsigned int, sycl::access::address_space::global_space>' has been explicitly marked deprecated here
    173 | class __SYCL2020_DEPRECATED(

 

0 Kudos
1 Solution
JeroenBoschma
Novice
1,147 Views

The backends did not show correctly with scyl-ls, but in the end it turns out to be my misstake by not looking into drivers. I had some simple SYCL try-out code running weeks ago, then updated SYCL and after that it did not run anymore. It did not cross my mind that updating SYCL a bit (I saw sycl7.dll changing into sycl8.dll) could mean that the GPU driver I had was not accepted anymore. After installing newer ones, SYCL code functioned again. Did cost me almost 2 weeks of evenings trying to find out what was going on, good lesson....

So there's not really something here to accept as a solution, other then to stress that drivers should be the first to look at (as mattewwade06 also mentioned).

View solution in original post

0 Kudos
5 Replies
mattewwade06
Beginner
1,292 Views

That sounds frustrating! One thing that sometimes helps with SYCL examples crashing is making sure your runtime and drivers are up to date and then trying a clean rebuild. If it still fails, narrowing down which part of the code triggers the crash can give clues on what’s going wrong. Hope you get it sorted soon!

0 Kudos
JeroenBoschma
Novice
1,264 Views

Frustrating is putting it mildly.. I decided to go back to an Intel basic example (base-vector-add): apart from CMake nagging that a deprecated CMake command was used (why is it then there, please update the example Intel) and after adding C++17 which apparently also was missing (why?) it compiles. But Visual Studio 2022 does not let me choose it as a startup item and running it directly outside VS does nothing more than a flash of a black terminal.... These simple examples should work out of the box. I am getting close to the decision dropping SYCL completely and start to learn CUDA.

0 Kudos
JeroenBoschma
Novice
1,244 Views

Sorry for the additional reply, I'm not allowed to edit posts. But you're probably right it is a driver issue. I work on a laptop with Intel Iris, and although Windows is convinced I have the correct/newest driver, disabling the Iris in the device manager makes the example run. At least I have a clue now where to look....

0 Kudos
yzh_intel
Moderator
1,169 Views

hi, can the sycl-ls command show the backends correctly? The compilation warnings shouldn't be a problem, but do you see any runtime errors when it crashes?

0 Kudos
JeroenBoschma
Novice
1,148 Views

The backends did not show correctly with scyl-ls, but in the end it turns out to be my misstake by not looking into drivers. I had some simple SYCL try-out code running weeks ago, then updated SYCL and after that it did not run anymore. It did not cross my mind that updating SYCL a bit (I saw sycl7.dll changing into sycl8.dll) could mean that the GPU driver I had was not accepted anymore. After installing newer ones, SYCL code functioned again. Did cost me almost 2 weeks of evenings trying to find out what was going on, good lesson....

So there's not really something here to accept as a solution, other then to stress that drivers should be the first to look at (as mattewwade06 also mentioned).

0 Kudos
Reply