Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling device functions on CPU #144

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/device/intrinsics/arguments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ for (intr, offset) in nodim_intr
@eval begin
export $(Symbol(intr))

$(Symbol(intr))() = ccall($"extern julia.air.$intr.i32", llvmcall, UInt32, ()) + UInt32($offset)
@device_function $(Symbol(intr))() = ccall($"extern julia.air.$intr.i32", llvmcall, UInt32, ()) + UInt32($offset)
end
end

Expand All @@ -45,13 +45,13 @@ for (intr, offset) in dim_intr
export $(Symbol(intr * "_2d"))
export $(Symbol(intr * "_3d"))

$(Symbol(intr * "_1d"))() =
@device_function $(Symbol(intr * "_1d"))() =
ccall($"extern julia.air.$intr.i32", llvmcall, UInt32, ()) + UInt32($offset)

$(Symbol(intr * "_2d"))() =
@device_function $(Symbol(intr * "_2d"))() =
NamedTuple{(:x,:y)}(ccall($"extern julia.air.$intr.v2i32", llvmcall, NTuple{2, UInt32}, ()) .+ UInt32($offset))

$(Symbol(intr * "_3d"))() =
@device_function $(Symbol(intr * "_3d"))() =
NamedTuple{(:x,:y,:z)}(ccall($"extern julia.air.$intr.v3i32", llvmcall, NTuple{3, UInt32}, ()) .+ UInt32($offset))
end
end
Expand Down
50 changes: 50 additions & 0 deletions test/device/intrinsics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,56 @@
@on_device threads_per_threadgroup_1d()
@on_device threads_per_threadgroup_2d()
@on_device threads_per_threadgroup_3d()

global const CPU_ONLY_ERR = "This function is not intended for use on the CPU"

@test_throws CPU_ONLY_ERR dispatch_quadgroups_per_threadgroup()
@test_throws CPU_ONLY_ERR dispatch_simdgroups_per_threadgroup()
@test_throws CPU_ONLY_ERR quadgroup_index_in_threadgroup()
@test_throws CPU_ONLY_ERR quadgroups_per_threadgroup()
@test_throws CPU_ONLY_ERR simdgroup_index_in_threadgroup()
@test_throws CPU_ONLY_ERR simdgroups_per_threadgroup()
@test_throws CPU_ONLY_ERR thread_index_in_quadgroup()
@test_throws CPU_ONLY_ERR thread_index_in_simdgroup()
@test_throws CPU_ONLY_ERR thread_index_in_threadgroup()
@test_throws CPU_ONLY_ERR thread_execution_width()
@test_throws CPU_ONLY_ERR threads_per_simdgroup()

@test_throws CPU_ONLY_ERR dispatch_threads_per_threadgroup_1d()
@test_throws CPU_ONLY_ERR dispatch_threads_per_threadgroup_2d()
@test_throws CPU_ONLY_ERR dispatch_threads_per_threadgroup_3d()

@test_throws CPU_ONLY_ERR grid_origin_1d()
@test_throws CPU_ONLY_ERR grid_origin_2d()
@test_throws CPU_ONLY_ERR grid_origin_3d()

@test_throws CPU_ONLY_ERR grid_size_1d()
@test_throws CPU_ONLY_ERR grid_size_2d()
@test_throws CPU_ONLY_ERR grid_size_3d()

@test_throws CPU_ONLY_ERR thread_position_in_grid_1d()
@test_throws CPU_ONLY_ERR thread_position_in_grid_2d()
@test_throws CPU_ONLY_ERR thread_position_in_grid_3d()

@test_throws CPU_ONLY_ERR thread_position_in_threadgroup_1d()
@test_throws CPU_ONLY_ERR thread_position_in_threadgroup_2d()
@test_throws CPU_ONLY_ERR thread_position_in_threadgroup_3d()

@test_throws CPU_ONLY_ERR threadgroup_position_in_grid_1d()
@test_throws CPU_ONLY_ERR threadgroup_position_in_grid_2d()
@test_throws CPU_ONLY_ERR threadgroup_position_in_grid_3d()

@test_throws CPU_ONLY_ERR threadgroups_per_grid_1d()
@test_throws CPU_ONLY_ERR threadgroups_per_grid_2d()
@test_throws CPU_ONLY_ERR threadgroups_per_grid_3d()

@test_throws CPU_ONLY_ERR threads_per_grid_1d()
@test_throws CPU_ONLY_ERR threads_per_grid_2d()
@test_throws CPU_ONLY_ERR threads_per_grid_3d()

@test_throws CPU_ONLY_ERR threads_per_threadgroup_1d()
@test_throws CPU_ONLY_ERR threads_per_threadgroup_2d()
@test_throws CPU_ONLY_ERR threads_per_threadgroup_3d()
end

############################################################################################
Expand Down