From 114c1c82523d140060277ac5760e72408fde234d Mon Sep 17 00:00:00 2001 From: Mike J Innes Date: Mon, 2 Oct 2017 14:53:42 +0100 Subject: [PATCH] rename allowscalar --- README.md | 2 +- src/indexing.jl | 12 ++++++------ test/runtests.jl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 972620d1..1a6c1fbc 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/src/indexing.jl b/src/indexing.jl index d7088900..dc2282bd 100644 --- a/src/indexing.jl +++ b/src/indexing.jl @@ -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 @@ -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 @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index b9d5b34a..0d337008 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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...))