Skip to content

using dpc++ in cmake projects #1427

@hiaselhans

Description

@hiaselhans

I tried to use the dpc++ in a cmake environment with llvm in a submodule and configured set(CMAKE_CXX_COMPILER "${LLVM_PATH}/bin/clang++") and a few more.

now, cmake seems to split the linking and building process and that opens for some troubles. the program builds fine, but fails to execute due to the device code missing..?

terminate called after throwing an instance of 'cl::sycl::runtime_error'
  what():  No kernel named _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10FillBuffer was found -46 (CL_INVALID_KERNEL_NAME)

CMake seems to invoke:

  • clang++ -fsycl -o sycl.o -c sycl.cpp
  • clang++ -fsycl -rdynamic sycl.cpp.o -o sycl -lsycl

manual compilation works fine using clang++ -fsycl -o sycl sycl.cpp.
seems like the -c -> Only run preprocess, compile, and assemble steps and the separate linking target is missing device code / fat object creation.

I can read into CMake more and find a way if you point me to some starter.
computecpp's FindComputeCPP is providing a add_sycl_to_target function for this. I couldn't get my head around how this is working in the tests yet but it's probably a good place to start?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions