arrayfire / arrayfire

ArrayFire: a general purpose GPU library.

Home Page:https://arrayfire.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG, CUDA backend] af::shift cannot shift an array with one row

FloopCZ opened this issue · comments

af::shift produces invalid result (a single repeating value) when shifting an array made of a single row on CUDA backend. On CPU backend, it works correctly.

#include <arrayfire.h>

int main() {
    af::info();

    af::array A = af::randu(1, 10);
    af::print("A", A);

    af::array A_shifted = af::shift(A, 0, 1);
    af::print("A shifted", A_shifted);

    A_shifted = af::shift(A, 1, 0);
    af::print("A shifted", A_shifted);
}

Compile and run:

$ g++ -lafcuda bug.cpp && ./a.out

Output:

ArrayFire v3.8.3 (CUDA, 64-bit Linux, build default)
Platform: CUDA Runtime 12.0, Driver: 545.29.06
[0] NVIDIA RTX A500 Laptop GPU, 3905 MB, CUDA Compute 8.6
A
[1 10 1 1]
   Offset: 0
   Strides: [1 1 10 10]
    0.6010     0.0278     0.9806     0.2126     0.0655     0.5497     0.2864     0.3410     0.7509     0.4105
A shifted
[1 10 1 1]
   Offset: 0
   Strides: [1 1 10 10]
    0.4105     0.4105     0.4105     0.4105     0.4105     0.4105     0.4105     0.4105     0.4105     0.4105
A shifted
[1 10 1 1]
   Offset: 0
   Strides: [1 1 10 10]
    0.6010     0.6010     0.6010     0.6010     0.6010     0.6010     0.6010     0.6010     0.6010     0.6010

System:

Linux pine 6.7.2-arch1-2 #1 SMP PREEMPT_DYNAMIC Wed, 31 Jan 2024 09:22:15 +0000 x86_64 GNU/Linux
ArrayFire v3.8.3 (CUDA, 64-bit Linux, build default)
Platform: CUDA Runtime 12.0, Driver: 545.29.06
NVIDIA RTX A500 Laptop GPU, 3905 MB, CUDA Compute 8.6

Nice catch, that was a tricky one, thanks! Let's hope the PR will get a review from one of the maintainers soon.

Seems to be fixed in 3.9.0 indeed, thanks for testing!