Skip to content

Pass runtime strings in the target's global address space - #920

Merged
maleadt merged 1 commit into
mainfrom
tb/runtime_cstring_as
Sep 4, 2026
Merged

Pass runtime strings in the target's global address space#920
maleadt merged 1 commit into
mainfrom
tb/runtime_cstring_as

Conversation

@maleadt

@maleadt maleadt commented Sep 4, 2026

Copy link
Copy Markdown
Member

Exception names and backtrace strings are emitted in the target's global address space, but the runtime declarations used Ptr{Cchar} and cast them to the default address space. For SPIR-V, that does not describe the cross-workgroup storage containing the strings.

Represent runtime string arguments with a placeholder resolved per compiler job. Keep Ptr{Cchar} as the default and derive SPIR-V's pointer type from the data layout's global address space, avoiding an address-space cast. Cover both typed and opaque LLVM pointers and translate the result through both SPIR-V back-ends.

@maleadt

maleadt commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

I don't particularly like the new interface though, so I'm also going to explore getting this out of LLVM.

@vchuravy

vchuravy commented Sep 4, 2026

Copy link
Copy Markdown
Member

I thought we had already tried to fix this before?

@vchuravy

vchuravy commented Sep 4, 2026

Copy link
Copy Markdown
Member

https://github.com/JuliaGPU/OpenCL.jl/pull/302/changes

We have globalstring_ptr!(builder, String(fmt); addrspace=AS.Constant)

Edit: Ah I see the issue, we are emitting in AS.Constant, but your intrinsics would like to see AS 0

Exception names and backtrace strings are emitted in the target's global
address space, but the runtime declarations used `Ptr{Cchar}` and cast them
to the default address space. For SPIR-V, that does not describe the
cross-workgroup storage containing the strings.

Represent runtime string arguments with a placeholder resolved per compiler
job. Keep `Ptr{Cchar}` as the default and derive SPIR-V's pointer type from
the data layout's global address space, avoiding an address-space cast.
Cover both typed and opaque LLVM pointers and translate the result through
both SPIR-V back-ends.
@maleadt
maleadt force-pushed the tb/runtime_cstring_as branch from 52d6ccc to 62c0c7b Compare September 4, 2026 13:42
@maleadt maleadt changed the title Pass runtime strings in a target-specific address space Pass runtime strings in the target's global address space Sep 4, 2026
@maleadt

maleadt commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Edit: Ah I see the issue, we are emitting in AS.Constant, but your intrinsics would like to see AS 0

Yes. But in the latest version, I made it so that we respecialize the runtime functions on a different type, so they are really accepting AS1 now, i.e., what globalstring_ptr! produces.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.41%. Comparing base (19e9962) to head (62c0c7b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/rtlib.jl 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #920      +/-   ##
==========================================
+ Coverage   85.14%   85.41%   +0.27%     
==========================================
  Files          29       29              
  Lines        5566     5582      +16     
==========================================
+ Hits         4739     4768      +29     
+ Misses        827      814      -13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit 978f153 into main Sep 4, 2026
33 checks passed
@maleadt
maleadt deleted the tb/runtime_cstring_as branch September 4, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants