Skip to content

GPU cleanup improvements#20

Merged
Keluaa merged 52 commits intomainfrom
gpu_cleanup
Jun 26, 2025
Merged

GPU cleanup improvements#20
Keluaa merged 52 commits intomainfrom
gpu_cleanup

Conversation

@Keluaa
Copy link
Owner

@Keluaa Keluaa commented Dec 17, 2024

Fix for #19

  • Demangling of LLVM names
  • Demangling on Windows?
  • Demangling LLVM names in PTX and SASS
    • the names are still very long, it might be preferable to detect the mangled function name and replace it with <current_function> or something else
    • kernel parameters are named with mangled_name followed by _param_<idx>, messing up the demangling, this should be replaced easily
    • extern functions in the form .extern .func (.param .b64 func_retval0) overflow_case are not sorted deterministically
    • There is sometimes a missing newline between the ret; and the closing }
  • Demangling LLVM names in GCN
    • update AMDGPU compat
    • same names, no parameters (unlike with CUDA)
  • Demangling LLVM names in SPIR-V
  • debuginfo alternative for all code types
  • Get rid of ; Location comments in SASS (as an option)
  • Cleanup LLVM IR generated by the GPU backends
    • with cuda_llvm, the function name is still mangled
  • Improve PTX display (colors?)
    • Pygmentize v2.16 supports PTX
    • Pygmentize v2.8 supports AMDGPU
    • GPUCompiler v1.2 now supports highlighting of PTX and GCN
      • Add Pygmentize in CI
      • Test highlighting of PTX (without CUDA.jl)
  • Support for Cthulhu.jl, especially for GPU kernels
  • Inline LLVM calls in typed IR
    • Having some compound types in arguments messes up the extraction of the LLVM function body
  • Nit: fix the alignment of predicates in PTX (@%p1 bra %L1 is aligned with other instruction at @, but doing it at bra would match how nsys does it) (read the PTX spec to match predicates correctly)
  • Option to remove loop comments in PTX, e.g. // Parent Loop BB0_8 Depth=1, // => This Loop Header: Depth=4, // Child Loop BB0_265 Depth 5, or // in Loop: Header=BB0_17 Depth=3
  • Indenting disparity on PTX between @code_for and @code_diff
  • Update docs
    • Docs for cleanup options
    • Docs for stats

Kernel test case:

@kernel function test_copy(a, b)
    i = @index(Global, Linear)
    b[i] = a[i]
end

@codecov
Copy link

codecov bot commented Mar 29, 2025

Codecov Report

Attention: Patch coverage is 83.91720% with 101 lines in your changes missing coverage. Please review.

Project coverage is 81.40%. Comparing base (730b5c9) to head (68a3e3f).
Report is 51 commits behind head on main.

Files with missing lines Patch % Lines
ext/CodeDiffsCUDA.jl 0.00% 19 Missing ⚠️
src/cleanup/ptx.jl 80.00% 18 Missing ⚠️
ext/CodeDiffsAMDGPU.jl 0.00% 15 Missing ⚠️
src/stats/ptx.jl 92.75% 10 Missing ⚠️
src/get_code.jl 68.00% 8 Missing ⚠️
src/cleanup/typed_ir.jl 81.57% 7 Missing ⚠️
ext/CodeDiffsMetal.jl 0.00% 4 Missing ⚠️
ext/gpu_common.jl 0.00% 4 Missing ⚠️
src/cleanup/llvm_ir.jl 20.00% 4 Missing ⚠️
ext/CodeDiffsOneAPI.jl 0.00% 3 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #20      +/-   ##
==========================================
+ Coverage   75.37%   81.40%   +6.02%     
==========================================
  Files          13       25      +12     
  Lines         670     1242     +572     
==========================================
+ Hits          505     1011     +506     
- Misses        165      231      +66     

☔ View full report in Codecov by Sentry.
📢 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.

@Keluaa Keluaa linked an issue Apr 6, 2025 that may be closed by this pull request
@Keluaa
Copy link
Owner Author

Keluaa commented Apr 24, 2025

Example code for missing newline between ret; and the last }:

@kernel inbounds=true unsafe_indices=true function sync_shared(x)
   is_main = @index(Local, Linear) == 1
   
   shrd = KernelAbstractions.@localmem Int (1,)
   
   if is_main
       shrd[1] = 42
   end

   KernelAbstractions.@synchronize()
   val = shrd[1]
   
   i = @index(Local, Linear)
   x[i] = val
end

@Keluaa Keluaa marked this pull request as ready for review June 11, 2025 11:56
@Keluaa Keluaa merged commit ee0b853 into main Jun 26, 2025
6 checks passed
@Keluaa Keluaa deleted the gpu_cleanup branch June 26, 2025 06:48
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.

Some improvements to code display

1 participant