Repository navigation
Conversation
The device overrides of `Base.min` and `Base.max` for floats called OCML's `__ocml_min`/`__ocml_max`, which, like C's `fmin`/`fmax`, return the other argument for a NaN, while Julia's `min` and `max` return NaN. Drop them: Julia's own definitions (`llvm.minimum`/`llvm.maximum` on Julia 1.12+, arithmetic before) compile for AMDGPU. Assisted-by: Claude Code (Opus 5.5)
Contributor
There was a problem hiding this comment.
AMDGPU.jl Benchmarks
Details
| Benchmark suite | Current: a83b644 | Previous: f0d0502 | Ratio |
|---|---|---|---|
amdgpu/synchronization/context/device |
555 ns |
565 ns |
0.98 |
amdgpu/synchronization/stream/blocking |
232.5 ns |
235 ns |
0.99 |
amdgpu/synchronization/stream/nonblocking |
317.5 ns |
315 ns |
1.01 |
applications/bitonic_sort |
1150281.5 ns |
1116058.5 ns |
1.03 |
applications/convolution |
99799.25 ns |
78898.75 ns |
1.26 |
applications/floyd_warshall |
9131606.5 ns |
9110058.5 ns |
1.00 |
applications/histogram |
802578 ns |
827149.25 ns |
0.97 |
applications/prefix_sum |
187920.5 ns |
187240 ns |
1.00 |
array/accumulate/Float32/1d |
82061.75 ns |
80941.25 ns |
1.01 |
array/accumulate/Float32/dims=1 |
262242.25 ns |
279954 ns |
0.94 |
array/accumulate/Float32/dims=1L |
110482 ns |
105479 ns |
1.05 |
array/accumulate/Float32/dims=2 |
111932.25 ns |
106766.5 ns |
1.05 |
array/accumulate/Float32/dims=2L |
3025676 ns |
3030052.75 ns |
1.00 |
array/accumulate/Int64/1d |
90739.25 ns |
86061.25 ns |
1.05 |
array/accumulate/Int64/dims=1 |
244897 ns |
249656 ns |
0.98 |
array/accumulate/Int64/dims=1L |
119737.25 ns |
94328.75 ns |
1.27 |
array/accumulate/Int64/dims=2 |
96234.25 ns |
103489 ns |
0.93 |
array/accumulate/Int64/dims=2L |
3387696.75 ns |
3393328 ns |
1.00 |
array/broadcast |
29328 ns |
68516 ns |
0.43 |
array/construct |
2075 ns |
2180 ns |
0.95 |
array/copy |
38040.75 ns |
38240.5 ns |
0.99 |
array/copyto!/cpu_to_gpu |
88816.5 ns |
89121.25 ns |
1.00 |
array/copyto!/gpu_to_cpu |
89709 ns |
88303.5 ns |
1.02 |
array/copyto!/gpu_to_gpu |
33770.75 ns |
33785.5 ns |
1.00 |
array/iteration/findall/bool |
127222.25 ns |
130914.5 ns |
0.97 |
array/iteration/findall/int |
118779.75 ns |
140924.5 ns |
0.84 |
array/iteration/findfirst/bool |
151870 ns |
154504.5 ns |
0.98 |
array/iteration/findfirst/int |
187723 ns |
189135.25 ns |
0.99 |
array/iteration/findmin/1d |
114932 ns |
103571.5 ns |
1.11 |
array/iteration/findmin/2d |
100394.25 ns |
89636.25 ns |
1.12 |
array/iteration/logical |
191903.25 ns |
225498.25 ns |
0.85 |
array/iteration/scalar |
298785 ns |
296164.25 ns |
1.01 |
array/permutedims/2d |
60866.25 ns |
69475.75 ns |
0.88 |
array/permutedims/3d |
47058.25 ns |
58178.25 ns |
0.81 |
array/permutedims/4d |
62431 ns |
73456 ns |
0.85 |
array/random/rand/Float32 |
44595.75 ns |
44738 ns |
1.00 |
array/random/rand/Int64 |
43570.75 ns |
54233.5 ns |
0.80 |
array/random/rand!/Float32 |
38405.75 ns |
40805.75 ns |
0.94 |
array/random/rand!/Int64 |
43728.25 ns |
49345.75 ns |
0.89 |
array/random/randn/Float32 |
71331.25 ns |
65160.75 ns |
1.09 |
array/random/randn!/Float32 |
55183.5 ns |
56443.25 ns |
0.98 |
array/reductions/mapreduce/Float32/1d |
115112 ns |
81013.5 ns |
1.42 |
array/reductions/mapreduce/Float32/dims=1 |
87624 ns |
88001.25 ns |
1.00 |
array/reductions/mapreduce/Float32/dims=1L |
836309.75 ns |
839651.75 ns |
1.00 |
array/reductions/mapreduce/Float32/dims=2 |
93459 ns |
89701.25 ns |
1.04 |
array/reductions/mapreduce/Float32/dims=2L |
134957.25 ns |
135854.5 ns |
0.99 |
array/reductions/mapreduce/Int64/1d |
114999.5 ns |
80863.5 ns |
1.42 |
array/reductions/mapreduce/Int64/dims=1 |
88031.5 ns |
88458.75 ns |
1.00 |
array/reductions/mapreduce/Int64/dims=1L |
848372 ns |
843502 ns |
1.01 |
array/reductions/mapreduce/Int64/dims=2 |
91494 ns |
86963.75 ns |
1.05 |
array/reductions/mapreduce/Int64/dims=2L |
136214.75 ns |
136949.5 ns |
0.99 |
array/reductions/reduce/Float32/1d |
113534.5 ns |
80531.25 ns |
1.41 |
array/reductions/reduce/Float32/dims=1 |
87209 ns |
87283.75 ns |
1.00 |
array/reductions/reduce/Float32/dims=1L |
840324.25 ns |
840039.25 ns |
1.00 |
array/reductions/reduce/Float32/dims=2 |
93421.75 ns |
85036.25 ns |
1.10 |
array/reductions/reduce/Float32/dims=2L |
135189.75 ns |
135587 ns |
1.00 |
array/reductions/reduce/Int64/1d |
100361.5 ns |
80693.75 ns |
1.24 |
array/reductions/reduce/Int64/dims=1 |
87899 ns |
88476.25 ns |
0.99 |
array/reductions/reduce/Int64/dims=1L |
843064.25 ns |
841001.75 ns |
1.00 |
array/reductions/reduce/Int64/dims=2 |
72571.25 ns |
90366.25 ns |
0.80 |
array/reductions/reduce/Int64/dims=2L |
135714.75 ns |
135834.5 ns |
1.00 |
array/reverse/1d |
40220.5 ns |
41358 ns |
0.97 |
array/reverse/1dL |
52121 ns |
70341 ns |
0.74 |
array/reverse/1dL_inplace |
53273.5 ns |
54481 ns |
0.98 |
array/reverse/1d_inplace |
34648.25 ns |
35505.5 ns |
0.98 |
array/reverse/2d |
45848.25 ns |
39643 ns |
1.16 |
array/reverse/2dL |
86046.5 ns |
90556.25 ns |
0.95 |
array/reverse/2dL_inplace |
64541 ns |
65046 ns |
0.99 |
array/reverse/2d_inplace |
35475.5 ns |
36200.5 ns |
0.98 |
array/sorting/1d |
331121 ns |
326947 ns |
1.01 |
gemm/tiled |
1948859.75 ns |
2884390.75 ns |
0.68 |
gemm/tiled_unbounded |
1954799.75 ns |
2904108.5 ns |
0.67 |
integration/byval/reference |
38451 ns |
39421 ns |
0.98 |
integration/byval/slices=1 |
40511 ns |
38151 ns |
1.06 |
integration/byval/slices=2 |
158003 ns |
158542 ns |
1.00 |
integration/byval/slices=3 |
238284 ns |
241053 ns |
0.99 |
integration/volumerhs |
4888099 ns |
4873209 ns |
1.00 |
kernel/indexing |
29357.75 ns |
29223 ns |
1.00 |
kernel/indexing_checked |
36025.5 ns |
33385.5 ns |
1.08 |
kernel/launch |
1200 ns |
1160 ns |
1.03 |
kernel/rand |
73641.25 ns |
98406.25 ns |
0.75 |
latency/import |
1492585412 ns |
1462428687 ns |
1.02 |
latency/precompile |
23029244636 ns |
22794416389 ns |
1.01 |
latency/ttfp |
2224788030 ns |
2230777820 ns |
1.00 |
stencil/diffusion3d |
1626614.25 ns |
1620078 ns |
1.00 |
stencil/diffusion3d_checked |
1647839.5 ns |
1660428.5 ns |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Base.min/Base.maxon floats were overridden on the device with OCML's__ocml_min_*/__ocml_max_*. Like C'sfmin/fmax, those return the other argument when one is NaN, somax(NaN32, 1f0)gave1f0on the GPU andNaN32on the CPU.This drops the overrides. Julia's own definitions compile for AMDGPU:
llvm.minimum/llvm.maximum, which have exactly Julia's semantics;Julia's semantics here are that NaN propagates and
-0.0 < 0.0.Tests:
test/device/math.jl: NaN, ±0.0 and ±Inf, for Float16, Float32 and Float64.test/device/math.jl, including "Fast min/max", still pass.Found through KernelAbstractions' KernelInterface test suite (JuliaGPU/KernelAbstractions.jl#831), which tests sub-group reductions of
maxwith a NaN against Julia's semantics.🤖 Generated with Claude Code