The reindex function seems to be broken when an array with domain like {2..8 by -2} is given as an input. The expected output of the below code was 2 4 6 8 but we are getting 0 0 0 0 or 0 32 0 0 sometimes.
Source Code:
use Random;
var D = {2..8 by -2},
A : [D] int;
for i in D {
A[i] = i;
}
var B = A.reindex(1..A.size);
writeln(B);
chpl --version: chpl version 1.21.0 pre-release (2c9530a7a6)$CHPL_HOME/util/printchplenv --anonymize:CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native
CHPL_LOCALE_MODEL: flat
CHPL_COMM: none
CHPL_TASKS: qthreads
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
CHPL_GMP: gmp
CHPL_HWLOC: hwloc
CHPL_REGEXP: re2
CHPL_LLVM: none
CHPL_AUX_FILESYS: none
gcc --version or clang --version: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0Hi @Aniket21mathur —
Thanks for filing this. We have some known issues with arrays with negative stride, such as #13174. Is this an issue that is holding you up in some way, or something you stumbled across and filed to make sure it wasn't lost?
Thanks!
this an issue that is holding you up in some way,
@bradcray I am trying to implement a parallel merge shuffle in #15140 and I am using reindex to handle cases with strided arrays, so the shuffle does not work for negative strides.
Thanks :smile:
OK, thanks for the context. I would not get hung up on the case of arrays with negative strides for now if it's not holding up the rest of your work. Independently of this issue, I'd already been thinking of them potentially giving a "this may not work out well..." warning given the other issue(s) that have been reported with them (we haven't been able to allocate time to improve them because other priorities have dominated, and they aren't all that used/useful/necessary in practice).
Hi @Aniket21mathur — Following up, I added a --warn-unstable warnings for arrays of negative strides in #15180. This is not a perfect solution in that most users will probably not think to compile with --warn-unstable by default, but I'll feel better at least knowing that it's there. Thanks again for filing this issue.
Hi @Aniket21mathur — Following up, I added a
--warn-unstablewarnings for arrays of negative strides in #15180
Thanks @bradcray :smile:
Most helpful comment
OK, thanks for the context. I would not get hung up on the case of arrays with negative strides for now if it's not holding up the rest of your work. Independently of this issue, I'd already been thinking of them potentially giving a "this may not work out well..." warning given the other issue(s) that have been reported with them (we haven't been able to allocate time to improve them because other priorities have dominated, and they aren't all that used/useful/necessary in practice).