Skip to content

Fix docs and test for unsafe_indicies=true #566

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

Merged
merged 1 commit into from
Feb 14, 2025
Merged
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
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ Since this transformation can be disruptive, user can now opt out of the implici
but users must avoid the use of `@index(Global)` and instead use their own derivation based on `@index(Group)` and `@index(Local)`.

```julia
@kernel unsafe_indicies=false function localmem(A)
@kernel unsafe_indicies=true function localmem(A)
N = @uniform prod(@groupsize())
gI = @index(Group, Linear)
i = @index(Local, Linear)
6 changes: 3 additions & 3 deletions src/KernelAbstractions.jl
Original file line number Diff line number Diff line change
@@ -87,9 +87,9 @@ macro kernel(ex...)
else
error(
"Configuration should be of form:\n" *
"* `cpu=true`\n" *
"* `inbounds=false`\n" *
"* `unsafe_indicies=false`\n" *
"* `cpu=false`\n" *
"* `inbounds=true`\n" *
"* `unsafe_indicies=true`\n" *
"got `", ex[i], "`",
)
end
7 changes: 4 additions & 3 deletions src/macros.jl
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ function find_return(stmt)
end

# XXX: Proper errors
function __kernel(expr, generate_cpu = true, force_inbounds = false, unsafe_indicies = true)
function __kernel(expr, generate_cpu = true, force_inbounds = false, unsafe_indicies = false)
def = splitdef(expr)
name = def[:name]
args = def[:args]
@@ -88,9 +88,10 @@ function transform_gpu!(def, constargs, force_inbounds, unsafe_indicies)
pushfirst!(def[:args], :__ctx__)
new_stmts = Expr[]
body = MacroTools.flatten(def[:body])
stmts = body.args
push!(new_stmts, Expr(:aliasscope))
push!(new_stmts, :(__active_lane__ = $__validindex(__ctx__)))
if !unsafe_indicies
push!(new_stmts, :(__active_lane__ = $__validindex(__ctx__)))
end
if force_inbounds
push!(new_stmts, Expr(:inbounds, true))
end
2 changes: 1 addition & 1 deletion test/localmem.jl
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ end
end
end

@kernel unsafe_indicies = false function localmem_unsafe_indicies(A)
@kernel unsafe_indicies = true function localmem_unsafe_indicies(A)
N = @uniform prod(@groupsize())
gI = @index(Group, Linear)
i = @index(Local, Linear)
Loading