Skip to content

Commit dff7afe

Browse files
authored
Fix docs and test for unsafe_indicies=true (#566)
1 parent f35d7b6 commit dff7afe

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Since this transformation can be disruptive, user can now opt out of the implici
118118
but users must avoid the use of `@index(Global)` and instead use their own derivation based on `@index(Group)` and `@index(Local)`.
119119

120120
```julia
121-
@kernel unsafe_indicies=false function localmem(A)
121+
@kernel unsafe_indicies=true function localmem(A)
122122
N = @uniform prod(@groupsize())
123123
gI = @index(Group, Linear)
124124
i = @index(Local, Linear)

src/KernelAbstractions.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ macro kernel(ex...)
8787
else
8888
error(
8989
"Configuration should be of form:\n" *
90-
"* `cpu=true`\n" *
91-
"* `inbounds=false`\n" *
92-
"* `unsafe_indicies=false`\n" *
90+
"* `cpu=false`\n" *
91+
"* `inbounds=true`\n" *
92+
"* `unsafe_indicies=true`\n" *
9393
"got `", ex[i], "`",
9494
)
9595
end

src/macros.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function find_return(stmt)
1010
end
1111

1212
# XXX: Proper errors
13-
function __kernel(expr, generate_cpu = true, force_inbounds = false, unsafe_indicies = true)
13+
function __kernel(expr, generate_cpu = true, force_inbounds = false, unsafe_indicies = false)
1414
def = splitdef(expr)
1515
name = def[:name]
1616
args = def[:args]
@@ -88,9 +88,10 @@ function transform_gpu!(def, constargs, force_inbounds, unsafe_indicies)
8888
pushfirst!(def[:args], :__ctx__)
8989
new_stmts = Expr[]
9090
body = MacroTools.flatten(def[:body])
91-
stmts = body.args
9291
push!(new_stmts, Expr(:aliasscope))
93-
push!(new_stmts, :(__active_lane__ = $__validindex(__ctx__)))
92+
if !unsafe_indicies
93+
push!(new_stmts, :(__active_lane__ = $__validindex(__ctx__)))
94+
end
9495
if force_inbounds
9596
push!(new_stmts, Expr(:inbounds, true))
9697
end

test/localmem.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
end
3535
end
3636

37-
@kernel unsafe_indicies = false function localmem_unsafe_indicies(A)
37+
@kernel unsafe_indicies = true function localmem_unsafe_indicies(A)
3838
N = @uniform prod(@groupsize())
3939
gI = @index(Group, Linear)
4040
i = @index(Local, Linear)

0 commit comments

Comments
 (0)