Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidimensional reverse #1126

Closed
piever opened this issue Sep 3, 2021 · 5 comments
Closed

Multidimensional reverse #1126

piever opened this issue Sep 3, 2021 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@piever
Copy link
Contributor

piever commented Sep 3, 2021

Describe the bug

The reverse! API supports both a single value or a tuple, eg reverse!(A, dims=(1, 2)). I've noticed that CUDA errors for the tuple case.

To reproduce

julia> using CUDA

julia> A = CUDA.rand(3, 3, 3);

julia> reverse!(A, dims=(1, 2))
ERROR: TypeError: in keyword argument dims, expected Integer, got a value of type Tuple{Int64, Int64}
Stacktrace:
 [1] top-level scope
   @ REPL[37]:1
 [2] top-level scope
   @ C:\Users\pietro\.julia\packages\CUDA\9T5Sq\src\initialization.jl:66

I'm on CUDA v3.4.2 (latest release), but it seems that even on the master branch this problem exists.

Relevant version info:

[052768ef] CUDA v3.4.2
[0c68f7d7] GPUArrays v8.0.2
[61eb1bfa] GPUCompiler v0.12.9
[929cbde3] LLVM v4.4.0

Expected behavior

I imagined that reverse!(A, dims::Tuple{Vararg{Int}}) would work. I suspect a simple solution would be to just define it by calling the single dimension method for each dimension in dims, but I'm not sure how wasteful this would be.

Version info

Details on Julia:

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

Details on CUDA:

julia> CUDA.versioninfo()
CUDA toolkit 11.4.1, artifact installation
CUDA driver 11.2.0
NVIDIA driver 462.30.0

Libraries:
- CUBLAS: 11.5.4
- CURAND: 10.2.5
- CUFFT: 10.5.1
- CUSOLVER: 11.2.0
- CUSPARSE: 11.6.0
- CUPTI: 14.0.0
- NVML: 11.0.0+462.30
- CUDNN: 8.20.2 (for CUDA 11.4.0)
- CUTENSOR: 1.3.0 (for CUDA 11.2.0)

Toolchain:
- Julia: 1.6.2
- LLVM: 11.0.1
- PTX ISA support: 3.2, 4.0, 4.1, 4.2, 4.3, 5.0, 6.0, 6.1, 6.3, 6.4, 6.5, 7.0
- Device capability support: sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80

1 device:
  0: Quadro M1200 (sm_50, 2.307 GiB / 4.000 GiB available)

@piever piever added the bug Something isn't working label Sep 3, 2021
@maleadt maleadt changed the title reverse! errors when dims is a tuple reverse only supports reversing a single dimension Sep 6, 2021
@maleadt maleadt added enhancement New feature or request good first issue Good for newcomers and removed bug Something isn't working labels Sep 6, 2021
@maleadt
Copy link
Member

maleadt commented Sep 6, 2021

Yeah, the kernel is currently written with only a single dimension in mind, and would need to be adapted. Reversing multiple times is pretty wasteful, and we should just need to update the index calculation in the current kernels.

@maleadt maleadt changed the title reverse only supports reversing a single dimension Multidimensional reverse Sep 6, 2021
@RainerHeintzmann
Copy link
Contributor

... just ran into the same issue. Any progress on this?

@maleadt
Copy link
Member

maleadt commented May 3, 2023

No. Feel free to take a stab at it! Happy to help you with any issues.

@RainerHeintzmann
Copy link
Contributor

I made a revised version, which now should be able to handle this. Also found a way to kick out the empty threads. Should I make a pull request?

@maleadt
Copy link
Member

maleadt commented May 10, 2023

#1899

@maleadt maleadt closed this as completed May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants