Skip to content

Commit

Permalink
fixup! Add device/random.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo committed Mar 29, 2023
1 parent 3cbaab3 commit 2439b9d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/device/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ end

@inline function Base.getproperty(rng::Philox2x32, field::Symbol)
threadId = workitemIdx().x + (workitemIdx().y - Int32(1)) * workgroupDim().x +
(workitemIdx().z - Int32(1)) * workgroupDim().x * workgroupDim().y
warpId = (threadId - Int32(1)) >> 0x5 + Int32(1) # fld1
(workitemIdx().z - Int32(1)) * workgroupDim().x * workgroupDim().y
warpId = (threadId - Int32(1)) >> 0x6 + Int32(1) # fld1 by 64

if field === :seed
@inbounds global_random_seed()[1]
Expand All @@ -85,8 +85,8 @@ end

@inline function Base.setproperty!(rng::Philox2x32, field::Symbol, x)
threadId = workitemIdx().x + (workitemIdx().y - Int32(1)) * workgroupDim().x +
(workitemIdx().z - Int32(1)) * workgroupDim().x * workgroupDim().y
warpId = (threadId - Int32(1)) >> 0x5 + Int32(1) # fld1
(workitemIdx().z - Int32(1)) * workgroupDim().x * workgroupDim().y
warpId = (threadId - Int32(1)) >> 0x6 + Int32(1) # fld1 by 64

if field === :key
@inbounds global_random_keys()[warpId] = x
Expand Down

0 comments on commit 2439b9d

Please sign in to comment.