Skip to content

Sum of indexed array returns incorrect values #981

@shehzan10

Description

@shehzan10

Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/arrayfire-users/MxGMBrZebzc/K6FcF5KBGAAJ

array aa = af::constant(-1, 4, 1, s32);
array a = aa(2);
af_print(aa);
af_print(a);

int sumAA = sum<int>(aa);
int sumA = sum<int>(a);
cout << sumAA << endl << sumA << endl;

Outputs:

arrayfire(devel)$ ./build/examples/helloworld/helloworld_cpu
WARNING: af_set_device not supported for CPU
ArrayFire v3.1.0 (CPU, 64-bit Linux, build 1a52ee1)
[0] Intel: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz Max threads(8)
aa
[4 1 1 1]
        -1
        -1
        -1
        -1

a
[1 1 1 1]
        -1
sum(AA) = -4
sum(A) = -1
arrayfire(devel)$ ./build/examples/helloworld/helloworld_cuda
ArrayFire v3.1.0 (CUDA, 64-bit Linux, build 1a52ee1)
Platform: CUDA Toolkit 7, Driver: 355.11
[0] Quadro K5000, 4093 MB, CUDA Compute 3.0
aa
[4 1 1 1]
        -1
        -1
        -1
        -1

a
[1 1 1 1]
        -1
sum(AA) = -4
sum(A) = 33554428
arrayfire(devel)$ ./build/examples/helloworld/helloworld_opencl
Device[1] has no support for OpenGL Interoperation
ArrayFire v3.1.0 (OpenCL, 64-bit Linux, build 1a52ee1)
[0] NVIDIA  : Quadro K5000
-1- INTEL   : Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
aa
[4 1 1 1]
        -1
        -1
        -1
        -1

a
[1 1 1 1]
        -1
sum(AA) = -4
sum(A) = -4

CPU is working fine, CUDA and OpenCL give wrong results.
I checked with a constant(1, 4, 1) as well. The results for CUDA and OpenCL are still incorrect.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions