Skip to content

Commit

Permalink
Merge pull request #8 from arhik/main
Browse files Browse the repository at this point in the history
considers input arguments and reserved keywords in kernel
  • Loading branch information
arhik authored Mar 3, 2024
2 parents 85c0356 + 01b0d60 commit eaca9d0
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 189 deletions.
7 changes: 5 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
Infiltrator = "5903a43b-9cc3-4c30-8d17-598619ec4e9b"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
Lazy = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Tracy = "e689c965-62c8-4b79-b2c5-8359227902fd"
TracyProfiler_jll = "0c351ed6-8a68-550e-8b79-de6f926da83c"
WGPUCore = "53d714bf-0d76-4802-84b4-6cb75cca55f5"
WGPUNative = "c14bfd16-04f9-4c2f-a915-b355584b5509"
WGSLTypes = "8cf5275a-6167-4820-ac24-74d7d0e6cf05"

[compat]
Adapt = "^3.7"
Adapt = "^4.0"
CodeTracking = "^1.3"
ExprTools = "^0.1"
GPUArrays = "^9.1"
GPUArrays = "^10.0"
GPUCompiler = "^0.25"
GeometryBasics = "^0.4"
LLVM = "^6.0"
Expand Down
22 changes: 22 additions & 0 deletions examples/cast_kernel.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using WGPUCompute

@wgpukernel workgroupSizes=(4, 4) workgroupCount=(2, 2) function cast_kernel(x::WgpuArray{T, N}, out::WgpuArray{S, N}) where {T, S, N}
xdim = workgroupDims.x
ydim = workgroupDims.y
gIdx = workgroupId.x*xdim + localId.x
gIdy = workgroupId.y*ydim + localId.y
gId = xDims.x*gIdy + gIdx
out[gId] = S(ceil(x[gId]))
end

function cast(S::DataType, x::WgpuArray{T, N}) where {T, N}
y = WgpuArray{S}(undef, size(x))
cast_kernel(x, y)
return y
end

x = WgpuArray{Float32}(rand(Float32, 1024, 1024) .- 0.5f0)
z = cast(UInt32, x)

# TODO Bool cast is not working yet
# y = cast(Bool, x)
2 changes: 1 addition & 1 deletion src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export WgpuArray

function getCurrentDevice()
get!(task_local_storage(), :WGPUDevice) do
WGPUCore.getDefaultDevice()
WGPUCore.getDefaultDevice(nothing)
end
end

Expand Down
Loading

0 comments on commit eaca9d0

Please sign in to comment.