JuliaGPU / JuliaGPU/AMDGPU.jl

@inbounds not propagating correctly

Open
#342 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug performance speculative
Dominant language
Julia
Stars
344
Forks
79
Avg merge
2d 23h
Merged PRs (30d)
27

Description

@inbounds applied against the kernel function definition has no effect.

Additionally, @inbounds does not propagate through function calls within a kernel, for example by calling zip().

The following benchmarks from https://github.com/torrance/AMDGPU-MWE/blob/main/inbounds.jl demonstrate the performance penalty. Note that the 3rd benchmark is likely doubly penalised since the call to zip() isn't inlined.

function @inbounds => @inbounds annotated at function definition
internal @inbounds => @inbounds annotated at lines with indexing operations
using zip() => using a zip() to iterate and index into arrays

Function @inbounds
BenchmarkTools.Trial: 18 samples with 1 evaluation.
 Range (min … max):  283.219 ms … 287.235 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     283.964 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   284.278 ms ± 874.447 μs  ┊ GC (mean ± σ):  0.10% ± 0.29%

            ▁█                                                   
  ▄▁▁▁▁▁▁▁▄▄██▁▁▁▁▄▄▁▁▄▁▁▁▄▁▁▁▁▁▁▁▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄ ▁
  283 ms           Histogram: frequency by time          287 ms <

 Memory estimate: 6.21 MiB, allocs estimate: 406760.

Internal @inbounds
BenchmarkTools.Trial: 36 samples with 1 evaluation.
 Range (min … max):  141.340 ms … 141.616 ms  ┊ GC (min … max): 1.78% … 0.00%
 Time  (median):     141.471 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   141.469 ms ±  69.181 μs  ┊ GC (mean ± σ):  0.10% ± 0.42%

           ▃      ▃▃ ▃        ▃▃ █        ▃                      
  ▇▁▁▁▁▁▁▇▇█▁▇▇▁▁▁██▇█▁▁▇▇▁▁▁▁██▇█▇▁▁▁▁▇▁▁█▇▁▇▇▁▁▁▇▁▇▁▇▁▁▁▁▇▁▁▇ ▁
  141 ms           Histogram: frequency by time          142 ms <

 Memory estimate: 3.06 MiB, allocs estimate: 200490.

Using zip()
BenchmarkTools.Trial: 16 samples with 1 evaluation.
 Range (min … max):  318.848 ms … 319.049 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     318.942 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   318.950 ms ±  61.016 μs  ┊ GC (mean ± σ):  0.10% ± 0.28%

  ▁       ▁    ▁   █▁   ▁ ▁       ▁  ▁       ▁█        ▁     ▁▁  
  █▁▁▁▁▁▁▁█▁▁▁▁█▁▁▁██▁▁▁█▁█▁▁▁▁▁▁▁█▁▁█▁▁▁▁▁▁▁██▁▁▁▁▁▁▁▁█▁▁▁▁▁██ ▁
  319 ms           Histogram: frequency by time          319 ms <

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the benchmarks in the linked inbounds.jl example and compare function-level, internal, and zip() cases. Trace how @inbounds is handled for kernel definitions and calls; done means the annotation propagates through both cases without requiring annotations at each indexing operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.