8000 LLVM 20 + libLLVMSPIRVLib does not work out of the box · Issue #1893 · pocl/pocl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LLVM 20 + libLLVMSPIRVLib does not work out of the box #1893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintain 8000 ers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maleadt opened this issue Apr 15, 2025 · 5 comments
Closed

LLVM 20 + libLLVMSPIRVLib does not work out of the box #1893

maleadt opened this issue Apr 15, 2025 · 5 comments
Assignees
Labels
Milestone

Comments

@maleadt
Copy link
Collaborator
maleadt commented Apr 15, 2025

I noticed #1809 (cc @franz) but I'm having a hard time switching from the translator executables to a library. I'm using LLVM 20 (with a matching libLLVMSPIRVLib for LLVM 20), which supports up to SPIR-V 1.6. However, the logic here only supports up to SPIR-V 1.1:

switch (TargetVersion.major * 100 + TargetVersion.minor) {
case 100:
TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_0;
break;
case 101:
TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_1;
break;
default:
UnrecognizedVersion = true;
POCL_FALLTHROUGH;

Worse, the TargetVersion selected by PoCL is SPIR-V 1.5, since I'm using LLVM 20:

#if LLVM_MAJOR >= 20
device->supported_spir_v_versions
= "SPIR-V_1.5 SPIR-V_1.4 SPIR-V_1.3 SPIR-V_1.2 SPIR-V_1.1 SPIR-V_1.0";

That means I always get a CL_INVALID_BINARY Translator does not recognize the SPIR-V version error.

Furthermore, LLVMSPIRVOpts.h from the LLVM 20-compatible translator defines enum values up to SPIR-V 1.6, so the following seems to work here:

SPIRV::VersionNumber TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_3;
switch (TargetVersion.major * 100 + TargetVersion.minor) {
case 100:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_0;
  break;
case 101:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_1;
  break;
case 102:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_2;
  break;
case 103:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_3;
  break;
case 104:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_4;
  break;
case 105:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_5;
  break;
case 106:
  TargetVersionEnum = SPIRV::VersionNumber::SPIRV_1_6;
  break;
default:
  UnrecognizedVersion = true;
  break;
}
@maleadt maleadt added the SPIR-V label Apr 15, 2025
@maleadt
Copy link
Collaborator Author
maleadt commented Apr 15, 2025

Note that the SPIR-V version selected by PoCL here disregards what I passed in (SPIR-V IR generated with the translator's executable passing --spirv-max-version=1.0).

@pjaaskel pjaaskel added this to the 7.0 milestone Apr 15, 2025
@franz
Copy link
Contributor
franz commented Apr 22, 2025

However, the logic here only supports up to SPIR-V 1.1:

I don't know how you came to that conclusion. The code handles up to SPIR-V 1.4 (unless the numeric case values are somehow off).

Furthermore, LLVMSPIRVOpts.h from the LLVM 20-compatible translator defines enum values up to SPIR-V 1.6, so the following seems to work here:

Yes, but as the code comment a few lines down explains, this is not the case for all existing versions of that header. But anyway this needs to be fixed.

@maleadt
Copy link
Collaborator Author
maleadt commented Apr 23, 2025

However, the logic here only supports up to SPIR-V 1.1:

I don't know how you came to that conclusion. The code handles up to SPIR-V 1.4 (unless the numeric case values are somehow off).

Yeah, I guess I got confused by the strange case ordering (with the default in the middle). Presumably to pick 1.2 as fallback, which seems redundant with the initial 1.3 value for TargetVersionEnum above.

@franz
Copy link
Contributor
franz commented May 1, 2025

@maleadt should be fixed in main, can you retest ?

@maleadt
Copy link
Collaborator Author
maleadt commented May 5, 2025

Seems to work, thanks!

@maleadt maleadt closed this as completed May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
0