Skip to content

Commit a550d64

Browse files
committed
Whitespace fixes.
1 parent 204935d commit a550d64

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/indexing.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# mechanism to disallow indexing
2+
13
const _allowscalar = Ref(true)
24

35
allowscalar(flag = true) = (_allowscalar[] = flag)
46

5-
function assertscalar(op = "Operation")
6-
_allowscalar[] || error("$op is disabled")
7+
function assertscalar(op = "operation")
8+
_allowscalar[] || error("$op is disallowed")
79
return
810
end
911

@@ -17,6 +19,9 @@ macro allowscalar(ex)
1719
end
1820
end
1921

22+
23+
# basic indexing
24+
2025
Base.IndexStyle(::Type{<:GPUArray}) = Base.IndexLinear()
2126

2227
function _getindex(xs::GPUArray{T}, i::Integer) where T
@@ -26,7 +31,7 @@ function _getindex(xs::GPUArray{T}, i::Integer) where T
2631
end
2732

2833
function Base.getindex(xs::GPUArray{T}, i::Integer) where T
29-
ndims(xs) > 0 && assertscalar("scalar getindex")
34+
ndims(xs) > 0 && assertscalar("scalar getindex")
3035
_getindex(xs, i)
3136
end
3237

@@ -37,7 +42,7 @@ function _setindex!(xs::GPUArray{T}, v::T, i::Integer) where T
3742
end
3843

3944
function Base.setindex!(xs::GPUArray{T}, v::T, i::Integer) where T
40-
assertscalar("scalar setindex!")
45+
assertscalar("scalar setindex!")
4146
_setindex!(xs, v, i)
4247
end
4348

@@ -63,7 +68,6 @@ to_index(a, x::Base.LogicalIndex) = error("Logical indexing not implemented")
6368
end
6469
end
6570

66-
6771
function Base._unsafe_getindex!(dest::GPUArray, src::GPUArray, Is::Union{Real, AbstractArray}...)
6872
if length(Is) == 1 && isa(first(Is), Array) && isempty(first(Is)) # indexing with empty array
6973
return dest
@@ -73,7 +77,7 @@ function Base._unsafe_getindex!(dest::GPUArray, src::GPUArray, Is::Union{Real, A
7377
return dest
7478
end
7579

76-
# simple broadcast getindex like function... could reuse another?
80+
# FIXME: simple broadcast getindex like function... reuse from Base
7781
@inline bgetindex(x::AbstractArray, i) = x[i]
7882
@inline bgetindex(x, i) = x
7983

@@ -89,9 +93,7 @@ end
8993
end
9094
end
9195

92-
93-
#TODO this should use adapt, but I currently don't have time to figure out it's intended usage
94-
96+
# FIXME: this should use adapt
9597
gpu_convert(GPUType, x::GPUArray) = x
9698
function gpu_convert(GPUType, x::AbstractArray)
9799
isbits(x) ? x : convert(GPUType, x)

0 commit comments

Comments
 (0)