Skip to content

Commit a964746

Browse files
lamb-jsearlmc1
authored andcommitted
[Comgr][SPIRV] Specify OpenCL 2.0 for SPIRV translation
The current default is OpenCL 1.2, but for now we only handle OpenCL 2.0. Also clarified that the Log output is the command line equivalent Change-Id: I674547380d838f4021b28c746b5e8780e6c43cd6
1 parent 22a74ac commit a964746

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

amd/comgr/src/comgr-compiler.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,11 @@ amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode() {
18831883
llvm::Module *M;
18841884
std::string Err;
18851885

1886-
if (!llvm::readSpirv(Context, ISS, M, Err)) {
1886+
SPIRV::TranslatorOpts Opts;
1887+
Opts.enableAllExtensions();
1888+
Opts.setDesiredBIsRepresentation(SPIRV::BIsRepresentation::OpenCL20);
1889+
1890+
if (!llvm::readSpirv(Context, Opts, ISS, M, Err)) {
18871891
LogS << "Failed to load SPIR-V as LLVM Module: " << Err << '\n';
18881892
return AMD_COMGR_STATUS_ERROR;
18891893
}
@@ -1910,8 +1914,9 @@ amd_comgr_status_t AMDGPUCompiler::translateSpirvToBitcode() {
19101914
return Status;
19111915
}
19121916

1913-
LogS << "SPIR-V Translation: amd-llvm-spirv -r " << Input->Name << " " <<
1914-
Output->Name << "\n";
1917+
LogS << " SPIR-V Translation: amd-llvm-spirv -r "
1918+
<< "--spirv-target-env=CL2.0 " << Input->Name << " -o " << Output->Name
1919+
<< " (command line equivalent)\n";
19151920
}
19161921

19171922
return AMD_COMGR_STATUS_SUCCESS;

amd/comgr/test-lit/spirv-translator.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: clang -c -emit-llvm --target=spirv64 %s -o %t.bc
66

77
// COM: Translate LLVM IR to SPIRV format
8-
// RUN: amd-llvm-spirv %t.bc -o %t.spv
8+
// RUN: amd-llvm-spirv --spirv-target-env=CL2.0 %t.bc -o %t.spv
99

1010
// COM: Run Comgr Translator to covert SPIRV back to LLVM IR
1111
// RUN: spirv-translator %t.spv -o %t.translated.bc

0 commit comments

Comments
 (0)