@@ -65,7 +65,7 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N}
6565
6666 function CuArray {T,N,M} (:: UndefInitializer , dims:: Dims{N} ) where {T,N,M}
6767 check_eltype (" CuArray" , T)
68- maxsize = prod (dims) * sizeof (T)
68+ maxsize = prod (dims) * argsize (T)
6969 bufsize = if Base. isbitsunion (T)
7070 # type tag array past the data
7171 maxsize + prod (dims)
@@ -82,7 +82,7 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N}
8282 end
8383
8484 function CuArray {T,N} (data:: DataRef{Managed{M}} , dims:: Dims{N} ;
85- maxsize:: Int = prod (dims) * sizeof (T), offset:: Int = 0 ) where {T,N,M}
85+ maxsize:: Int = prod (dims) * argsize (T), offset:: Int = 0 ) where {T,N,M}
8686 check_eltype (" CuArray" , T)
8787 obj = new {T,N,M} (data, maxsize, offset, dims)
8888 finalizer (unsafe_free!, obj)
@@ -233,7 +233,7 @@ function Base.unsafe_wrap(::Type{CuArray{T,N,M}},
233233 ptr:: CuPtr{T} , dims:: NTuple{N,Int} ;
234234 own:: Bool = false , ctx:: CuContext = context ()) where {T,N,M}
235235 check_eltype (" unsafe_wrap(CuArray, ...)" , T)
236- sz = prod (dims) * sizeof (T)
236+ sz = prod (dims) * argsize (T)
237237
238238 # create a memory object
239239 mem = if M == UnifiedMemory
@@ -288,7 +288,7 @@ supports_hmm(dev) = driver_version() >= v"12.2" &&
288288function Base. unsafe_wrap (:: Type{CuArray{T,N,M}} , p:: Ptr{T} , dims:: NTuple{N,Int} ;
289289 ctx:: CuContext = context ()) where {T,N,M<: AbstractMemory }
290290 isbitstype (T) || throw (ArgumentError (" Can only unsafe_wrap a pointer to a bits type" ))
291- sz = prod (dims) * sizeof (T)
291+ sz = prod (dims) * argsize (T)
292292
293293 data = if M == UnifiedMemory
294294 # HMM extends unified memory to include system memory
@@ -336,7 +336,7 @@ Base.unsafe_wrap(::Type{CuArray{T,N,M}}, a::Array{T,N}) where {T,N,M} =
336336
337337# # array interface
338338
339- Base. elsize (:: Type{<:CuArray{T}} ) where {T} = sizeof (T)
339+ Base. elsize (:: Type{<:CuArray{T}} ) where {T} = argsize (T)
340340
341341Base. size (x:: CuArray ) = x. dims
342342Base. sizeof (x:: CuArray ) = Base. elsize (x) * length (x)
835835# # derived arrays
836836
837837function GPUArrays. derive (:: Type{T} , a:: CuArray , dims:: Dims{N} , offset:: Int ) where {T,N}
838- offset = (a. offset * Base. elsize (a)) ÷ sizeof (T) + offset
838+ offset = (a. offset * Base. elsize (a)) ÷ argsize (T) + offset
839839 CuArray {T,N} (copy (a. data), dims; a. maxsize, offset)
840840end
841841
@@ -849,7 +849,7 @@ function Base.unsafe_convert(::Type{CuPtr{T}}, V::SubArray{T,N,P,<:Tuple{Vararg{
849849end
850850function Base. unsafe_convert (:: Type{CuPtr{T}} , V:: SubArray {T,N,P,<: Tuple{Vararg{Union{Base.RangeIndex,Base.ReshapedUnitRange}}} }) where {T,N,P}
851851 return Base. unsafe_convert (CuPtr{T}, parent (V)) +
852- (Base. first_index (V)- 1 )* sizeof (T)
852+ (Base. first_index (V)- 1 )* argsize (T)
853853end
854854
855855
@@ -872,8 +872,8 @@ function Base.resize!(A::CuVector{T}, n::Integer) where T
872872 n == length (A) && return A
873873
874874 # TODO : add additional space to allow for quicker resizing
875- maxsize = n * sizeof (T)
876- bufsize = if isbitstype (T)
875+ maxsize = n * argsize (T)
876+ bufsize = if isbitstype (T) # TODO Symbol
877877 maxsize
878878 else
879879 # type tag array past the data
0 commit comments