Open ben-albrecht opened 4 years ago
Originally requested by @ronawho.
@ben-albrecht how we use Random.shuffle
currently?
I tried something like
use Random;
var A = ['c', 'h', 'a', 'p', 'e', 'l'];
shuffle(A, seed=10);
writeln(A);
but got this error
$CHPL_HOME/modules/packages/Sort.chpl:1415: warning: Module level symbol is hiding function argument 'A'
$CHPL_HOME/modules/packages/Sort.chpl:1415: warning: Module level symbol is hiding function argument 'A'
$CHPL_HOME/modules/packages/Sort.chpl:1415: warning: Module level symbol is hiding function argument 'A'
$CHPL_HOME/modules/packages/Sort.chpl:1415: warning: Module level symbol is hiding function argument 'A'
$CHPL_HOME/modules/packages/Sort.chpl:1415: warning: Module level symbol is hiding function argument 'A'
Random.chpl:5: error: unresolved call 'shuffle([domain(1,int(64),false)] string, seed=10)'
Random.chpl:5: note: because no functions named shuffle found in scope
Please help. Thanks!
@Aniket21mathur - what chapel version are you using? Your example compiles and runs for me on the master branch.
@ben-albrecht I am also working with the master branch, I build the sources again from master, but still getting the same error.
Which commit on master?
I am using: chpl version 1.21.0 pre-release (6051bbd358)
Is the above snippet the entire program you are compiling? Have you made any modifications to the standard modules anywhere?
You could try doing a fresh checkout and retrying.
@ben-albrecht
Which commit on master?
I am working @ https://github.com/chapel-lang/chapel/commit/2c9530a7a6bf0b67c28de2d5155749b497450374
Is the above snippet the entire program you are compiling?
Yes, this is the entire program.
Have you made any modifications to the standard modules anywhere? Does that matter if I do a fresh checkout and
make
again?
thanks!
@ben-albrecht seems like I figured it out, I was working in a directory in which I put all my test examples. In that directory, I made a file named Random.chpl
, which had some code. So on running on above code, it seems to import Random from the present directory which is the Random.chpl file I made, deleting that file fixed the problem. :smile:
@ben-albrecht I would like to work on this. Thanks!
Hi @ben-albrecht I have understood the implementation of Merge Shuffle. I would like to contribute to this. Thanks!
@Yudhishthira1406 - OK, check out #15140 for prior work. The blocker in that PR was demonstrating a performance improvement (in a new performance test) with the random implementation for large arrays over the serial implementation.
PR #17066 is @Yudhishthira1406 effort and that implements a parallel merge shuffle. But there are a few minor issues preventing it from being merged & we have closed it for the moment. If @Yudhishthira1406 or anybody else wants to complete this work, starting from PR #17066 and addressing last comment there would be the next step.
Implement a parallel random shuffle for
Random.shuffle()
.MergeShuffle seems like a good algorithm to target.
A reference MPI+python implementation is available in this SO answer.