Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to emit SPIRV and how to emit LLVM? #5608

Answered by MrSidims
seanbaxter asked this question in Q&A
Discussion options

--emit-llvm doesn't work in dcpp. Don't understand why. Also, how do I emit the SPIRV module to file instead of linking it to the .o?

You must be logged in to vote

Hi, I usually use:
clang++ -fsycl -fsycl-device-only test.cpp - to emit .bc file
and
clang++ -fsycl -fsycl-device-only -fno-sycl-use-bitcode test.cpp to emit .spv file

I'm unsure, if -fno-sycl-use-bitcode option works with dpcpp, so in this case I would suggest:
dpcpp -fsycl-device-only test.cpp - this alone will emit .bc file
llvm-spirv --spirv-ext=+all test.bc - this will translate it to .spv file

and llvm-dis / llvm-spirv --to-text are used to emit test formats for IR and SPV

Replies: 3 comments 2 replies

Comment options

Hi, I usually use:
clang++ -fsycl -fsycl-device-only test.cpp - to emit .bc file
and
clang++ -fsycl -fsycl-device-only -fno-sycl-use-bitcode test.cpp to emit .spv file

I'm unsure, if -fno-sycl-use-bitcode option works with dpcpp, so in this case I would suggest:
dpcpp -fsycl-device-only test.cpp - this alone will emit .bc file
llvm-spirv --spirv-ext=+all test.bc - this will translate it to .spv file

and llvm-dis / llvm-spirv --to-text are used to emit test formats for IR and SPV

You must be logged in to vote
2 replies
Comment options

warning: option '-fno-sycl-use-bitcode' is deprecated and will be removed in a future release [-Wdeprecated]

This option is removed.

Comment options

@alanzhai219, it is not yet removed, but it will be.

-fsycl-device-obj=<value>
 Specify format of device code stored in the resulting object. Valid values are: spirv, llvmir (default)

Is a replacement you are looking for

Answer selected by alexbatashev
Comment options

When I invoke clang++ directly I get "kernel name is missing" errors. When I use dpcpp with these commands, it does generate a .spv, but it's broken:

sean@zenbook:~/mandelbrot/src$ dpcpp -fsycl -fsycl-device-only main.cpp
In file included from main.cpp:14:
./mandel.hpp:240:44: warning: loop not unrolled: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Wpass-failed=transform-warning]
 h.parallel_for(range<2>(rows, cols), [=](auto index) {
 ^
1 warning generated.
sean@zenbook:~/mandelbrot/src$ llvm-spirv --spirv-ext=+all main.bc
sean@zenbook:~/mandelbrot/src$ spirv-dis main.spv
; SPIR-V
; Version: 1.0
; Generator: Khronos LLVM/SPIR-V Translator; 14
; Bound: 237
; Schema: 0
 OpCapability Addresses
 OpCapability Linkage
 OpCapability Kernel
 OpCapability Int64
 OpCapability GenericPointer
 OpCapability Int8
error: 7: Invalid capability operand: 5629

This is the mandelbrot test that ships with oneAPI. llvm-spirv --to-text does produce a form of disassembly, but I'm hoping to use the regular SPIRV-Tools with this.

You must be logged in to vote
0 replies
Comment options

When I invoke clang++ directly I get "kernel name is missing" errors.

I see. dpcpp binary includes several extensions. Addition of -fsycl-unnamed-lambda to clang++ shall work.

but I'm hoping to use the regular SPIRV-Tools with this

KhronosGroup/SPIRV-Headers#176 and KhronosGroup/SPIRV-Headers#177 are addressing this problem, when they merged - this capability will become known for SPIR-V tools.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #2889 on February 18, 2022 06:46.

AltStyle によって変換されたページ (->オリジナル) /