Skip to content

Commit 35189d9

Browse files
Run more tests under API validation testing (#447)
[only special]
1 parent 711758d commit 35189d9

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

.buildkite/pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ steps:
7070
- JuliaCI/julia#v1:
7171
version: "1.10"
7272
- JuliaCI/julia-test#v1:
73-
test_args: "--quickfail metal"
73+
test_args: "--quickfail"
7474
# only enabled for select tests due to JuliaGPU/Metal.jl#34
7575
- JuliaCI/julia-coverage#v1:
7676
codecov: true
@@ -85,6 +85,7 @@ steps:
8585
queue: "juliaecosystem"
8686
os: "macos"
8787
arch: "aarch64"
88+
macos_version: "15.0"
8889
if: |
8990
build.message =~ /\[only tests\]/ ||
9091
build.message =~ /\[only special\]/ ||

src/memory.jl

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,30 @@ end
8484
src::MtlPtr{T}, N::Integer;
8585
queue::MTLCommandQueue=global_queue(dev),
8686
async::Bool=false) where T
87-
cmdbuf = MTLCommandBuffer(queue)
88-
MTLBlitCommandEncoder(cmdbuf) do enc
89-
MTL.append_copy!(enc, dst.buffer, dst.offset, src.buffer, src.offset, N * sizeof(T))
87+
if N > 0
88+
cmdbuf = MTLCommandBuffer(queue)
89+
MTLBlitCommandEncoder(cmdbuf) do enc
90+
MTL.append_copy!(enc, dst.buffer, dst.offset, src.buffer, src.offset, N * sizeof(T))
91+
end
92+
commit!(cmdbuf)
93+
async || wait_completed(cmdbuf)
9094
end
91-
commit!(cmdbuf)
92-
async || wait_completed(cmdbuf)
95+
return dst
9396
end
9497

95-
@autoreleasepool function unsafe_fill!(dev::MTLDevice, ptr::MtlPtr{T},
96-
value::Union{UInt8,Int8}, N::Integer) where T
97-
cmdbuf = MTLCommandBuffer(global_queue(dev))
98-
MTLBlitCommandEncoder(cmdbuf) do enc
99-
MTL.append_fillbuffer!(enc, ptr.buffer, value, N * sizeof(T), ptr.offset)
98+
@autoreleasepool function unsafe_fill!(dev::MTLDevice, dst::MtlPtr{T},
99+
value::Union{UInt8,Int8}, N::Integer;
100+
queue::MTLCommandQueue=global_queue(dev),
101+
async::Bool=false) where T
102+
if N > 0
103+
cmdbuf = MTLCommandBuffer(queue)
104+
MTLBlitCommandEncoder(cmdbuf) do enc
105+
MTL.append_fillbuffer!(enc, dst.buffer, value, N * sizeof(T), dst.offset)
106+
end
107+
commit!(cmdbuf)
108+
async || wait_completed(cmdbuf)
100109
end
101-
commit!(cmdbuf)
102-
wait_completed(cmdbuf)
110+
return dst
103111
end
104112

105113
# TODO: Implement generic fill since mtBlitCommandEncoderFillBuffer is limiting

test/capturing.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using .MTL
22

3+
if shader_validation
4+
@warn "Skipping capturing tests; capturing is not supported with Metal Shader Validation enabled"
5+
else
6+
37
@testset "capturing" begin
48

59
mktempdir() do tmpdir
@@ -83,3 +87,4 @@ end
8387
end
8488

8589
end
90+
end

test/execution.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ end
6060
Metal.code_warntype(devnull, dummy, Tuple{})
6161
Metal.code_llvm(devnull, dummy, Tuple{})
6262
if Metal.macos_version() >= v"13"
63-
Metal.code_agx(devnull, dummy, Tuple{})
63+
shader_validation || Metal.code_agx(devnull, dummy, Tuple{})
6464
end
6565

6666
@device_code_lowered @metal dummy()
6767
@device_code_typed @metal dummy()
6868
@device_code_warntype io=devnull @metal dummy()
6969
@device_code_llvm io=devnull @metal dummy()
7070
if Metal.macos_version() >= v"13"
71-
@device_code_agx io=devnull @metal dummy()
71+
shader_validation || @device_code_agx io=devnull @metal dummy()
7272
end
7373

7474
mktempdir() do dir
@@ -81,7 +81,7 @@ end
8181
@test occursin("dummy", sprint(io->(@device_code_llvm io=io optimize=false @metal dummy())))
8282
@test occursin("dummy", sprint(io->(@device_code_llvm io=io @metal dummy())))
8383
if Metal.macos_version() >= v"13"
84-
@test occursin("dummy", sprint(io->(@device_code_agx io=io @metal dummy())))
84+
shader_validation || @test occursin("dummy", sprint(io->(@device_code_agx io=io @metal dummy())))
8585
end
8686

8787
# make sure invalid kernels can be partially reflected upon

test/setup.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const eltypes = [Int16, Int32, Int64,
1717
TestSuite.supported_eltypes(::Type{<:MtlArray}) = eltypes
1818

1919
const runtime_validation = get(ENV, "MTL_DEBUG_LAYER", "0") != "0"
20+
const shader_validation = get(ENV, "MTL_SHADER_VALIDATION", "0") != "0"
2021

2122
using Random
2223

0 commit comments

Comments
 (0)