Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
rename allowscalar
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Oct 2, 2017
1 parent 9473414 commit 114c1c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ We welcome issues or PRs for functionality not on this list.
Note that some operations not on this list will work, but be slow, due to Base's generic implementations. This is intentional, to enable a "make it work, then make it fast" workflow. When you're ready you can disable slow fallback methods:

```julia
julia> CuArrays.allowslow(false)
julia> CuArrays.allowscalar(false)
julia> xs[5]
ERROR: getindex is disabled
```
Expand Down
12 changes: 6 additions & 6 deletions src/indexing.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const _allowslow = Ref(true)
const _allowscalar = Ref(true)

allowslow(flag = true) = (_allowslow[] = flag)
allowscalar(flag = true) = (_allowscalar[] = flag)

function assertslow(op = "Operation")
_allowslow[] || error("$op is disabled")
function assertscalar(op = "Operation")
_allowscalar[] || error("$op is disabled")
return
end

Expand All @@ -17,7 +17,7 @@ function _getindex(xs::CuArray{T}, i::Integer) where T
end

function Base.getindex(xs::CuArray{T}, i::Integer) where T
assertslow("getindex")
assertscalar("scalar getindex")
_getindex(xs, i)
end

Expand All @@ -29,7 +29,7 @@ function _setindex!(xs::CuArray{T}, v::T, i::Integer) where T
end

function Base.setindex!(xs::CuArray{T}, v::T, i::Integer) where T
assertslow("setindex!")
assertscalar("scalar setindex!")
_setindex!(xs, v, i)
end

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
using CuArrays
using Base.Test

CuArrays.allowslow(false)
CuArrays.allowscalar(false)

function testf(f, xs...)
@test collect(f(cu.(xs)...)) collect(f(xs...))
Expand Down

0 comments on commit 114c1c8

Please sign in to comment.