LLVM-AMDGPU-Assembler-Extra icon indicating copy to clipboard operation
LLVM-AMDGPU-Assembler-Extra copied to clipboard

Question: Running amdgcn-compiled code on a Mac

Open lancelet opened this issue 7 years ago • 0 comments

Is it possible to run code compiled with the amdgcn llvm backend on macOS?

When I use Apple's openclc compiler, I get code I can load using clCreateProgramWithBinary:

/System/Library/Frameworks/OpenCL.framework/Libraries/openclc \
    -c -emit-llvm -arch gpu_32 \
    -o <output>.bc <input>.cl

However, compiling for the amdgcn back-end using clang-5.0.0 produces a [CL_BUILD_ERROR] : OpenCL Build Error : Compiler build log:\nUnknown bitstream version!\n with clCreateProgramWithBinary:

clang -c -cl-std=CL1.2       \
    -arch amdgcn             \
    -emit-llvm               \
    -Xclang                  \
    -finclude-default-header \
    -o <output>.bc <input>.cl

The two files look somewhat similar, so I'm wondering if there's anything I'm missing, or whether it's just that there's no way to run this code on a Mac.

Hex dump of the start of the Apple <output>.bc:

00000000  de c0 17 0b 00 00 00 00  14 00 00 00 b0 04 00 00  |................|
00000010  ff ff ff ff 42 43 c0 de  21 0c 00 00 29 01 00 00  |....BC..!...)...|
...

Hex dump of the start of the amdgcn <output.bc>:

00000000  de c0 17 0b 00 00 00 00  14 00 00 00 50 0c 00 00  |............P...|
00000010  ff ff ff ff 42 43 c0 de  35 14 00 00 05 00 00 00  |....BC..5.......|
...

(BTW: I'm trying to use clCreateProgramWithBinary with an AMD Radeon Pro 460, which AFAICT, is supported by amdgcn.)

lancelet avatar Dec 31 '17 09:12 lancelet