diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index a0e9c002..f76c0046 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -70,7 +70,7 @@ steps: - JuliaCI/julia#v1: version: "1.10" - JuliaCI/julia-test#v1: - test_args: "--quickfail metal" + test_args: "--quickfail" # only enabled for select tests due to JuliaGPU/Metal.jl#34 - JuliaCI/julia-coverage#v1: codecov: true @@ -85,6 +85,7 @@ steps: queue: "juliaecosystem" os: "macos" arch: "aarch64" + macos_version: "15.0" if: | build.message =~ /\[only tests\]/ || build.message =~ /\[only special\]/ || diff --git a/src/memory.jl b/src/memory.jl index 2bdfbdf7..7d4890a6 100644 --- a/src/memory.jl +++ b/src/memory.jl @@ -84,22 +84,30 @@ end src::MtlPtr{T}, N::Integer; queue::MTLCommandQueue=global_queue(dev), async::Bool=false) where T - cmdbuf = MTLCommandBuffer(queue) - MTLBlitCommandEncoder(cmdbuf) do enc - MTL.append_copy!(enc, dst.buffer, dst.offset, src.buffer, src.offset, N * sizeof(T)) + if N > 0 + cmdbuf = MTLCommandBuffer(queue) + MTLBlitCommandEncoder(cmdbuf) do enc + MTL.append_copy!(enc, dst.buffer, dst.offset, src.buffer, src.offset, N * sizeof(T)) + end + commit!(cmdbuf) + async || wait_completed(cmdbuf) end - commit!(cmdbuf) - async || wait_completed(cmdbuf) + return dst end -@autoreleasepool function unsafe_fill!(dev::MTLDevice, ptr::MtlPtr{T}, - value::Union{UInt8,Int8}, N::Integer) where T - cmdbuf = MTLCommandBuffer(global_queue(dev)) - MTLBlitCommandEncoder(cmdbuf) do enc - MTL.append_fillbuffer!(enc, ptr.buffer, value, N * sizeof(T), ptr.offset) +@autoreleasepool function unsafe_fill!(dev::MTLDevice, dst::MtlPtr{T}, + value::Union{UInt8,Int8}, N::Integer; + queue::MTLCommandQueue=global_queue(dev), + async::Bool=false) where T + if N > 0 + cmdbuf = MTLCommandBuffer(queue) + MTLBlitCommandEncoder(cmdbuf) do enc + MTL.append_fillbuffer!(enc, dst.buffer, value, N * sizeof(T), dst.offset) + end + commit!(cmdbuf) + async || wait_completed(cmdbuf) end - commit!(cmdbuf) - wait_completed(cmdbuf) + return dst end # TODO: Implement generic fill since mtBlitCommandEncoderFillBuffer is limiting diff --git a/test/capturing.jl b/test/capturing.jl index d6b4a330..9408f2f2 100644 --- a/test/capturing.jl +++ b/test/capturing.jl @@ -1,5 +1,9 @@ using .MTL +if shader_validation + @warn "Skipping capturing tests; capturing is not supported with Metal Shader Validation enabled" +else + @testset "capturing" begin mktempdir() do tmpdir @@ -83,3 +87,4 @@ end end end +end diff --git a/test/execution.jl b/test/execution.jl index 30b47232..17b0c990 100644 --- a/test/execution.jl +++ b/test/execution.jl @@ -60,7 +60,7 @@ end Metal.code_warntype(devnull, dummy, Tuple{}) Metal.code_llvm(devnull, dummy, Tuple{}) if Metal.macos_version() >= v"13" - Metal.code_agx(devnull, dummy, Tuple{}) + shader_validation || Metal.code_agx(devnull, dummy, Tuple{}) end @device_code_lowered @metal dummy() @@ -68,7 +68,7 @@ end @device_code_warntype io=devnull @metal dummy() @device_code_llvm io=devnull @metal dummy() if Metal.macos_version() >= v"13" - @device_code_agx io=devnull @metal dummy() + shader_validation || @device_code_agx io=devnull @metal dummy() end mktempdir() do dir @@ -81,7 +81,7 @@ end @test occursin("dummy", sprint(io->(@device_code_llvm io=io optimize=false @metal dummy()))) @test occursin("dummy", sprint(io->(@device_code_llvm io=io @metal dummy()))) if Metal.macos_version() >= v"13" - @test occursin("dummy", sprint(io->(@device_code_agx io=io @metal dummy()))) + shader_validation || @test occursin("dummy", sprint(io->(@device_code_agx io=io @metal dummy()))) end # make sure invalid kernels can be partially reflected upon diff --git a/test/setup.jl b/test/setup.jl index 8593266a..4694234c 100644 --- a/test/setup.jl +++ b/test/setup.jl @@ -17,6 +17,7 @@ const eltypes = [Int16, Int32, Int64, TestSuite.supported_eltypes(::Type{<:MtlArray}) = eltypes const runtime_validation = get(ENV, "MTL_DEBUG_LAYER", "0") != "0" +const shader_validation = get(ENV, "MTL_SHADER_VALIDATION", "0") != "0" using Random