Skip to content

Commit 73e48f3

Browse files
committed
Testing
1 parent aad4eab commit 73e48f3

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

lib/mtl/command_enc/compute4.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ function MTL4ComputeCommandEncoder(cmdbuf::MTL4CommandBuffer)
1313
end
1414

1515

16-
function MTL4ComputeCommandEncoder(f::Base.Callable, cmdbuf::MTL4CommandBuffer)
16+
function MTL4ComputeCommandEncoder(f::Base.Callable, cmdbuf::MTL4CommandBuffer, sync=false)
1717
encoder = MTL4ComputeCommandEncoder(cmdbuf)
1818
try
1919
f(encoder)
2020
finally
21+
sync && barrierAfterStages!(encoder)
2122
close(encoder)
2223
end
2324
end

src/compiler/execution.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ end
308308
MTL.append_current_function!(cce, groups, threads)
309309
bufs
310310
finally
311+
use_mtl4 && barrierAfterStages!(cce)
311312
close(cce)
312313
use_mtl4 && endCommandBuffer!(cmdbuf)
313314
end

src/memory.jl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,24 @@ end
9797

9898
@autoreleasepool function unsafe_fill!(dev::MTLDevice, dst::MtlPtr{T},
9999
value::Union{UInt8,Int8}, N::Integer;
100-
queue::MTLCommandQueue=global_queue(dev),
100+
queue=use_metal4() ? global_queue4(dev) : global_queue(dev),
101101
async::Bool=false) where T
102102
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)
103+
if queue isa MTL4CommandQueue
104+
@info "4"
105+
cmdbuf = MTL4CommandBuffer(dev; queue) do cmdbuf
106+
MTL4ComputeCommandEncoder(cmdbuf, !async) do enc
107+
MTL.append_fillbuffer!(enc, dst.buffer, value, N * sizeof(T), dst.offset)
108+
end
109+
end
110+
else
111+
cmdbuf = MTLCommandBuffer(queue)
112+
MTLBlitCommandEncoder(cmdbuf) do enc
113+
MTL.append_fillbuffer!(enc, dst.buffer, value, N * sizeof(T), dst.offset)
114+
end
115+
commit!(cmdbuf)
116+
async || wait_completed(cmdbuf)
106117
end
107-
commit!(cmdbuf)
108-
async || wait_completed(cmdbuf)
109118
end
110119
return dst
111120
end
112-
113-
# TODO: Implement generic fill since mtBlitCommandEncoderFillBuffer is limiting

0 commit comments

Comments
 (0)