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

With CuArrays 2.0, multidimensional circshift fails for integer multiples of array size shift in one or more dimensions #657

@Sleort

Description

@Sleort

Describe the bug
Before updating CuArrays.jl to version 2, the circshift function worked as intended for all shift arguments, also for multidimensional CuArrays. Now, however, it fails for multidimensional CuArrays when the shift is an integer multiple of the size of the array in one or more of the dimensions.

To Reproduce
The Minimal Working Example (MWE) for this bug:

julia> using CuArrays
julia> b = cu(reshape(Vector(1:16), (4,4)))
4×4 CuArray{Int64,2,Nothing}:
 1  5   9  13
 2  6  10  14
 3  7  11  15
 4  8  12  16

julia> circshift(b, (1,1)) #This is okay
4×4 CuArray{Int64,2,Nothing}:
 16  4  8  12
 13  1  5   9
 14  2  6  10
 15  3  7  11

julia> circshift(b, (0,1)) #Fails when any of the shift components equal 0, 4, 8, etc.)
ERROR: DivideError: integer division error
Stacktrace:
 [1] div at ./int.jl:230 [inlined]
 [2] div at ./div.jl:215 [inlined]
 [3] div at ./div.jl:270 [inlined]
 [4] cld at ./div.jl:227 [inlined]
 [5] configurator at /home/troels/.julia/packages/CuArrays/e8PLr/src/gpuarrays.jl:27 [inlined]
 [6] #cudacall#220 at /home/troels/.julia/packages/CUDAnative/cnQli/src/execution.jl:259 [inlined]
 [7] macro expansion at /home/troels/.julia/packages/CUDAnative/cnQli/src/execution.jl:242 [inlined]
 [8] call(::CUDAnative.HostKernel{GPUArrays.copy_kernel!,Tuple{CuArrays.CuKernelContext,CuDeviceArray{Int64,2,CUDAnative.AS.Global},CartesianIndex{2},CuDeviceArray{Int64,2,CUDAnative.AS.Global},CartesianIndex{2},Tuple{Int64,Int64},Int64}}, ::CuArrays.CuKernelContext, ::CuDeviceArray{Int64,2,CUDAnative.AS.Global}, ::CartesianIndex{2}, ::CuDeviceArray{Int64,2,CUDAnative.AS.Global}, ::CartesianIndex{2}, ::Tuple{Int64,Int64}, ::Int64; call_kwargs::Base.Iterators.Pairs{Symbol,CuArrays.var"#configurator#50"{Int64},Tuple{Symbol},NamedTuple{(:config,),Tuple{CuArrays.var"#configurator#50"{Int64}}}}) at /home/troels/.julia/packages/CUDAnative/cnQli/src/execution.jl:219
 [9] (::CUDAnative.HostKernel{GPUArrays.copy_kernel!,Tuple{CuArrays.CuKernelContext,CuDeviceArray{Int64,2,CUDAnative.AS.Global},CartesianIndex{2},CuDeviceArray{Int64,2,CUDAnative.AS.Global},CartesianIndex{2},Tuple{Int64,Int64},Int64}})(::CuArrays.CuKernelContext, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Symbol,CuArrays.var"#configurator#50"{Int64},Tuple{Symbol},NamedTuple{(:config,),Tuple{CuArrays.var"#configurator#50"{Int64}}}}) at /home/troels/.julia/packages/CUDAnative/cnQli/src/execution.jl:472
 [10] macro expansion at /home/troels/.julia/packages/CUDAnative/cnQli/src/execution.jl:158 [inlined]
 [11] gpu_call(::CuArrays.CuArrayBackend, ::Function, ::Tuple{CuArray{Int64,2,Nothing},CartesianIndex{2},CuArray{Int64,2,Nothing},CartesianIndex{2},Tuple{Int64,Int64},Int64}, ::Int64; name::Nothing) at /home/troels/.julia/packages/CuArrays/e8PLr/src/gpuarrays.jl:32
 [12] #gpu_call#1 at /home/troels/.julia/packages/GPUArrays/QDGmr/src/device/execution.jl:60 [inlined]
 [13] copyto! at /home/troels/.julia/packages/GPUArrays/QDGmr/src/host/abstractarray.jl:142 [inlined]
 [14] _circshift! at ./multidimensional.jl:1052 [inlined]
 [15] _circshift! at ./multidimensional.jl:1047 [inlined] (repeats 2 times)
 [16] circshift!(::CuArray{Int64,2,Nothing}, ::CuArray{Int64,2,Nothing}, ::Tuple{Int64,Int64}) at ./multidimensional.jl:1018
 [17] circshift(::CuArray{Int64,2,Nothing}, ::Tuple{Int64,Int64}) at ./abstractarraymath.jl:183
 [18] top-level scope at REPL[22]:1
 [19] eval(::Module, ::Any) at ./boot.jl:331
 [20] eval_user_input(::Any, ::REPL.REPLBackend) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
 [21] run_backend(::REPL.REPLBackend) at /home/troels/.julia/packages/Revise/Pcs5V/src/Revise.jl:1073
 [22] top-level scope at none:0

Environment details
Details on Julia:

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

Julia packages:

(@v1.4) pkg> st CuArrays CUDAnative
Status `~/.julia/environments/v1.4/Project.toml`
  [be33ccc6] CUDAnative v3.0.2
  [3a865a2d] CuArrays v2.0.1

CUDA: toolkit and driver version

julia> using CUDAnative

julia> CUDAnative.version()
v"10.1.243"
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions