Skip to content

Commit 5cc8dc3

Browse files
committed
implement synchronize correctly
1 parent f2a5008 commit 5cc8dc3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/KernelAbstractions.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ end
105105
@synchronize()
106106
"""
107107
macro synchronize()
108-
@error "@synchronize not captured or used outside @kernel"
108+
quote
109+
$__synchronize()
110+
end
109111
end
110112

111113
"""
@@ -286,6 +288,10 @@ function SharedMemory(::Type{T}, ::Val{Dims}, ::Val{Id}) where {T, Dims, Id}
286288
throw(MethodError(ScratchArray, (T, Val(Dims), Val(Id))))
287289
end
288290

291+
function __synchronize()
292+
error("@synchronize used outside kernel or not captured")
293+
end
294+
289295
###
290296
# Backends/Implementation
291297
###

src/backends/cuda.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,7 @@ end
214214
@inline function Cassette.overdub(ctx::CUDACtx, ::typeof(Scratchpad), ::Type{T}, ::Val{Dims}) where {T, Dims}
215215
MArray{__size(Dims), T}(undef)
216216
end
217+
218+
@inline function Cassette.overdub(ctx::CUDACtx, ::typeof(__synchronize))
219+
CUDAnative.sync_threads()
220+
end

0 commit comments

Comments
 (0)