-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC] Indentation consistency #545
Merged
Conversation
This file contains 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
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/device/array.jl b/src/device/array.jl
index ff5c52c2..25ff2f8b 100644
--- a/src/device/array.jl
+++ b/src/device/array.jl
@@ -169,7 +169,7 @@ end
# create a derived device array (reinterpreted or reshaped) that's still a MtlDeviceArray
@inline function _derived_array(::Type{T}, N::Int, a::MtlDeviceArray{T,M,A},
osize::Dims) where {T, M, A}
- return MtlDeviceArray{T,N,A}(osize, a.ptr)
+ return MtlDeviceArray{T, N, A}(osize, a.ptr)
end
function Base.reinterpret(::Type{T}, a::MtlDeviceArray{S,N,A}) where {T,S,N,A}
@@ -177,13 +177,13 @@ function Base.reinterpret(::Type{T}, a::MtlDeviceArray{S,N,A}) where {T,S,N,A}
err === nothing || throw(err)
if sizeof(T) == sizeof(S) # fast case
- return MtlDeviceArray{T,N,A}(size(a), reinterpret(LLVMPtr{T,A}, a.ptr))
+ return MtlDeviceArray{T, N, A}(size(a), reinterpret(LLVMPtr{T, A}, a.ptr))
end
isize = size(a)
- size1 = div(isize[1]*sizeof(S), sizeof(T))
+ size1 = div(isize[1] * sizeof(S), sizeof(T))
osize = tuple(size1, Base.tail(isize)...)
- return MtlDeviceArray{T,N,A}(osize, reinterpret(LLVMPtr{T,A}, a.ptr))
+ return MtlDeviceArray{T, N, A}(osize, reinterpret(LLVMPtr{T, A}, a.ptr))
end
function Base.reshape(a::MtlDeviceArray{T,M}, dims::NTuple{N,Int}) where {T,N,M}
@@ -193,5 +193,5 @@ function Base.reshape(a::MtlDeviceArray{T,M}, dims::NTuple{N,Int}) where {T,N,M}
if N == M && dims == size(a)
return a
end
- _derived_array(T, N, a, dims)
+ return _derived_array(T, N, a, dims)
end
diff --git a/src/device/intrinsics/memory.jl b/src/device/intrinsics/memory.jl
index 5ba2c511..6ef2475b 100644
--- a/src/device/intrinsics/memory.jl
+++ b/src/device/intrinsics/memory.jl
@@ -68,7 +68,7 @@ Base.pointer(x::MtlLargerDeviceArray{T,<:Any,A}) where {T,A} =
end
Base.unsafe_convert(::Type{Core.LLVMPtr{T,A}}, x::MtlLargerDeviceArray{T,<:Any,A}) where {T,A} =
- reinterpret(Core.LLVMPtr{T,A}, Base.unsafe_convert(Core.LLVMPtr{UInt32,A}, x.x))
+ reinterpret(Core.LLVMPtr{T, A}, Base.unsafe_convert(Core.LLVMPtr{UInt32, A}, x.x))
Base.@propagate_inbounds Base.getindex(A::MtlLargerDeviceArray{T}, i1::Integer) where {T} =
arrayref(A, i1)
diff --git a/src/pool.jl b/src/pool.jl
index 0522a452..a19a4a53 100644
--- a/src/pool.jl
+++ b/src/pool.jl
@@ -131,24 +131,24 @@ macro time(ex)
if bytes != 0 || allocs != 0
allocs, ma = Base.prettyprint_getunits(allocs, length(Base._cnt_units), Int64(1000))
if ma == 1
- Printf.@printf(" (%d%s %s allocation%s: ", allocs, Base._cnt_units[ma], typ, allocs==1 ? "" : "s")
+ Printf.@printf(" (%d%s %s allocation%s: ", allocs, Base._cnt_units[ma], typ, allocs == 1 ? "" : "s")
else
Printf.@printf(" (%.2f%s %s allocations: ", allocs, Base._cnt_units[ma], typ)
end
print(Base.format_bytes(bytes))
if gctime > 0
- Printf.@printf(", %.2f%% gc time", 100*gctime/cpu_time)
+ Printf.@printf(", %.2f%% gc time", 100 * gctime / cpu_time)
end
if memtime > 0
- Printf.@printf(", %.2f%% memmgmt time", 100*memtime/cpu_time)
+ Printf.@printf(", %.2f%% memmgmt time", 100 * memtime / cpu_time)
end
print(")")
else
if gctime > 0
- Printf.@printf(", %.2f%% %s gc time", 100*gctime/cpu_time, typ)
+ Printf.@printf(", %.2f%% %s gc time", 100 * gctime / cpu_time, typ)
end
if memtime > 0
- Printf.@printf(", %.2f%% %s memmgmt time", 100*memtime/cpu_time, typ)
+ Printf.@printf(", %.2f%% %s memmgmt time", 100 * memtime / cpu_time, typ)
end
end
end
diff --git a/test/array.jl b/test/array.jl
index a8bd4c22..a2c6218e 100644
--- a/test/array.jl
+++ b/test/array.jl
@@ -311,39 +311,39 @@ end
# https://github.com/JuliaGPU/CUDA.jl/issues/2191
@testset "preserving storage mode" begin
- a = mtl([1]; storage=Metal.SharedStorage)
- @test Metal.storagemode(a) == Metal.SharedStorage
-
- # storage mode should be preserved
- b = a .+ 1
- @test Metal.storagemode(b) == Metal.SharedStorage
-
- # when there's a conflict, we should defer to shared memory
- c = mtl([1]; storage=Metal.PrivateStorage)
- d = mtl([1]; storage=Metal.SharedStorage)
- e = c .+ d
- @test Metal.storagemode(e) == Metal.SharedStorage
+ a = mtl([1]; storage = Metal.SharedStorage)
+ @test Metal.storagemode(a) == Metal.SharedStorage
+
+ # storage mode should be preserved
+ b = a .+ 1
+ @test Metal.storagemode(b) == Metal.SharedStorage
+
+ # when there's a conflict, we should defer to shared memory
+ c = mtl([1]; storage = Metal.PrivateStorage)
+ d = mtl([1]; storage = Metal.SharedStorage)
+ e = c .+ d
+ @test Metal.storagemode(e) == Metal.SharedStorage
end
@testset "resizing" begin
- a = MtlArray([1,2,3])
+ a = MtlArray([1, 2, 3])
- resize!(a, 3)
- @test length(a) == 3
- @test Array(a) == [1,2,3]
+ resize!(a, 3)
+ @test length(a) == 3
+ @test Array(a) == [1, 2, 3]
- resize!(a, 5)
- @test length(a) == 5
- @test Array(a)[1:3] == [1,2,3]
+ resize!(a, 5)
+ @test length(a) == 5
+ @test Array(a)[1:3] == [1, 2, 3]
- resize!(a, 2)
- @test length(a) == 2
- @test Array(a)[1:2] == [1,2]
+ resize!(a, 2)
+ @test length(a) == 2
+ @test Array(a)[1:2] == [1, 2]
- b = MtlArray{Int}(undef, 0)
- @test length(b) == 0
- resize!(b, 1)
- @test length(b) == 1
+ b = MtlArray{Int}(undef, 0)
+ @test length(b) == 0
+ resize!(b, 1)
+ @test length(b) == 1
end
function _alignedvec(::Type{T}, n::Integer, alignment::Integer=16384) where {T}
@@ -448,10 +448,10 @@ end
# ND
let x = rand(Bool, 1000, 1000)
- @test findall(x) == Array(findall(MtlArray(x)))
+ @test findall(x) == Array(findall(MtlArray(x)))
end
let x = rand(Float32, 1000, 1000)
- @test findall(y->y>Float32(0.5), x) == Array(findall(y->y>Float32(0.5), MtlArray(x)))
+ @test findall(y -> y > Float32(0.5), x) == Array(findall(y -> y > Float32(0.5), MtlArray(x)))
end
end
diff --git a/test/runtests.jl b/test/runtests.jl
index b46c4ee7..56bab4ae 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -90,7 +90,7 @@ for (rootpath, dirs, files) in walkdir(@__DIR__)
# strip extension
files = map(files) do file
- file[1:end-3]
+ file[1:(end - 3)]
end
# prepend subdir
@@ -103,7 +103,7 @@ for (rootpath, dirs, files) in walkdir(@__DIR__)
append!(tests, files)
for file in files
- test_runners[file] = ()->include("$(@__DIR__)/$file.jl")
+ test_runners[file] = () -> include("$(@__DIR__)/$file.jl")
end
end
## GPUArrays testsuite
@@ -135,7 +135,7 @@ end
## the remaining args filter tests
if !isempty(ARGS)
filter!(tests) do test
- any(arg->startswith(test, arg), ARGS)
+ any(arg -> startswith(test, arg), ARGS)
end
end
|
Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metal Benchmarks
Benchmark suite | Current: eaf5dab | Previous: 4324871 | Ratio |
---|---|---|---|
private array/construct |
24843.75 ns |
24639 ns |
1.01 |
private array/broadcast |
463584 ns |
465708 ns |
1.00 |
private array/random/randn/Float32 |
924021 ns |
830416 ns |
1.11 |
private array/random/randn!/Float32 |
594791 ns |
632792 ns |
0.94 |
private array/random/rand!/Int64 |
556500 ns |
557083 ns |
1.00 |
private array/random/rand!/Float32 |
560104.5 ns |
600125 ns |
0.93 |
private array/random/rand/Int64 |
867771 ns |
766062.5 ns |
1.13 |
private array/random/rand/Float32 |
847167 ns |
634208 ns |
1.34 |
private array/copyto!/gpu_to_gpu |
580562.5 ns |
664208 ns |
0.87 |
private array/copyto!/cpu_to_gpu |
654354 ns |
773250 ns |
0.85 |
private array/copyto!/gpu_to_cpu |
656249.5 ns |
699709 ns |
0.94 |
private array/accumulate/1d |
1423458 ns |
1339667 ns |
1.06 |
private array/accumulate/2d |
1494917 ns |
1386666.5 ns |
1.08 |
private array/iteration/findall/int |
2311853.5 ns |
2103625 ns |
1.10 |
private array/iteration/findall/bool |
2030000 ns |
1839124.5 ns |
1.10 |
private array/iteration/findfirst/int |
1839584 ns |
1695250 ns |
1.09 |
private array/iteration/findfirst/bool |
1723395.5 ns |
1666458 ns |
1.03 |
private array/iteration/scalar |
2740792 ns |
3433416 ns |
0.80 |
private array/iteration/logical |
3513458 ns |
3197875 ns |
1.10 |
private array/iteration/findmin/1d |
1882937.5 ns |
1765958 ns |
1.07 |
private array/iteration/findmin/2d |
1405250 ns |
1344812.5 ns |
1.04 |
private array/reductions/reduce/1d |
963937.5 ns |
1043625 ns |
0.92 |
private array/reductions/reduce/2d |
691417 ns |
661229 ns |
1.05 |
private array/reductions/mapreduce/1d |
1007292 ns |
1014646 ns |
0.99 |
private array/reductions/mapreduce/2d |
695125.5 ns |
666687.5 ns |
1.04 |
private array/permutedims/4d |
2663166 ns |
2533875 ns |
1.05 |
private array/permutedims/2d |
1076729 ns |
1025083.5 ns |
1.05 |
private array/permutedims/3d |
1792167 ns |
1582229 ns |
1.13 |
private array/copy |
891500 ns |
579250 ns |
1.54 |
latency/precompile |
9178061250 ns |
9071946333 ns |
1.01 |
latency/ttfp |
3725373042 ns |
3672313458 ns |
1.01 |
latency/import |
1261021729 ns |
1239159916 ns |
1.02 |
integration/metaldevrt |
751541 ns |
723334 ns |
1.04 |
integration/byval/slices=1 |
1673417 ns |
1627542 ns |
1.03 |
integration/byval/slices=3 |
20759208 ns |
10224103.5 ns |
2.03 |
integration/byval/reference |
1663292 ns |
1593833 ns |
1.04 |
integration/byval/slices=2 |
2823875 ns |
2576042 ns |
1.10 |
kernel/indexing |
456541 ns |
459437.5 ns |
0.99 |
kernel/indexing_checked |
459687.5 ns |
464146 ns |
0.99 |
kernel/launch |
9167 ns |
8000 ns |
1.15 |
metal/synchronization/stream |
15291 ns |
14709 ns |
1.04 |
metal/synchronization/context |
15958.5 ns |
14834 ns |
1.08 |
shared array/construct |
24279.1 ns |
24382 ns |
1.00 |
shared array/broadcast |
465583 ns |
459666.5 ns |
1.01 |
shared array/random/randn/Float32 |
931916 ns |
841104 ns |
1.11 |
shared array/random/randn!/Float32 |
594333.5 ns |
640708 ns |
0.93 |
shared array/random/rand!/Int64 |
555375 ns |
571334 ns |
0.97 |
shared array/random/rand!/Float32 |
561208 ns |
596354.5 ns |
0.94 |
shared array/random/rand/Int64 |
868000 ns |
774333 ns |
1.12 |
shared array/random/rand/Float32 |
837500 ns |
644416 ns |
1.30 |
shared array/copyto!/gpu_to_gpu |
82292 ns |
82959 ns |
0.99 |
shared array/copyto!/cpu_to_gpu |
82000 ns |
83750 ns |
0.98 |
shared array/copyto!/gpu_to_cpu |
81583.5 ns |
82583.5 ns |
0.99 |
shared array/accumulate/1d |
1406374.5 ns |
1341375 ns |
1.05 |
shared array/accumulate/2d |
1495000 ns |
1394854 ns |
1.07 |
shared array/iteration/findall/int |
2008334 ns |
1790000 ns |
1.12 |
shared array/iteration/findall/bool |
1733875 ns |
1571083 ns |
1.10 |
shared array/iteration/findfirst/int |
1503667 ns |
1381542 ns |
1.09 |
shared array/iteration/findfirst/bool |
1420291.5 ns |
1367708 ns |
1.04 |
shared array/iteration/scalar |
162708 ns |
157917 ns |
1.03 |
shared array/iteration/logical |
3235666 ns |
2978354.5 ns |
1.09 |
shared array/iteration/findmin/1d |
1550083 ns |
1465666.5 ns |
1.06 |
shared array/iteration/findmin/2d |
1427604 ns |
1367417 ns |
1.04 |
shared array/reductions/reduce/1d |
682875 ns |
733625 ns |
0.93 |
shared array/reductions/reduce/2d |
684042 ns |
661083 ns |
1.03 |
shared array/reductions/mapreduce/1d |
721020.5 ns |
735437.5 ns |
0.98 |
shared array/reductions/mapreduce/2d |
690292 ns |
665875 ns |
1.04 |
shared array/permutedims/4d |
2635458 ns |
2500209 ns |
1.05 |
shared array/permutedims/2d |
1086833 ns |
1022354 ns |
1.06 |
shared array/permutedims/3d |
1797709 ns |
1576083 ns |
1.14 |
shared array/copy |
209584 ns |
239334 ns |
0.88 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Fixes lines where indents are 2 spaces instead of 4.
This also fixes the REPL docstring highlighting for
resize!
andmtlconvert
.Closes #543