Skip to content

Translate SPIR-V to OpenCL C in-process - #576

Open
maleadt wants to merge 1 commit into
mainfrom
tb/added-c-api-spirv2clc-0d4beb01
Open

maleadt wants to merge 1 commit into
mainfrom
tb/added-c-api-spirv2clc-0d4beb01

Conversation

@maleadt

@maleadt maleadt commented Oct 20, 2026

Copy link
Copy Markdown
Member

Use the C API added in JuliaGPU/spirv2clc#27 to translate SPIR-V in-process, replacing the temporary input file and per-kernel subprocess. Requires spirv2clc_jll 0.2.6.

The wrapper preserves the SPIR-V and OpenCL C target versions and failure dumps, copies the returned source into Julia, and frees both library-owned strings in finally. Diagnostics are collected separately from source; warnings and remarks are logged after the C call returns, and errors appear in the translation exception.

Validated on macOS arm64 with Julia 1.13.2 and PoCL 7.2: all 80 assertions in poclc/execution and poclc/translation pass, plus a kernel execution smoke test with program_backend!(:opencl). The new tests compare source with the CLI for OpenCL C 1.2, 2.0 and 3.0 and cover malformed input, unsupported versions, translator diagnostics and failure dumps. Other platforms and the full suite remain for CI.

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.88%. Comparing base (f43c7bf) to head (cc99cd7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler/compilation.jl 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #576      +/-   ##
==========================================
+ Coverage   87.73%   88.88%   +1.15%     
==========================================
  Files          18       18              
  Lines        1737     1746       +9     
==========================================
+ Hits         1524     1552      +28     
+ Misses        213      194      -19     

☔ 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.

On devices without SPIR-V support, every kernel was translated by writing
the module to a temporary file and running the spirv2clc tool on it. Call
the C API that spirv2clc_jll 0.2.6 provides in libspirv2clc instead, which
avoids a process spawn per kernel. Diagnostics are delivered through a
callback and logged once the call has returned, and errors keep the
existing failure message with a dump of the offending module.
@maleadt
maleadt force-pushed the tb/added-c-api-spirv2clc-0d4beb01 branch from c19b785 to cc99cd7 Compare October 21, 2026 05:02

This branch has not been deployed

No deployments
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.

1 participant