[Mlir-commits] [mlir] [mlir][sparse][CRunnerUtils] Add shuffle in CRunnerUtils (PR #77124)

Aart Bik llvmlistbot at llvm.org
Mon Jan 8 17:11:47 PST 2024


================
@@ -482,10 +482,16 @@ extern "C" MLIR_CRUNNERUTILS_EXPORT double rtclock();
 //===----------------------------------------------------------------------===//
 // Uses a seed to initialize a random generator and returns the generator.
 extern "C" MLIR_CRUNNERUTILS_EXPORT void *rtsrand(uint64_t s);
-// Returns a random number in the range of [0, m).
-extern "C" MLIR_CRUNNERUTILS_EXPORT uint64_t rtrand(void *, uint64_t m);
+// Uses a random number generator g and returns a random number
+// in the range of [0, m).
+extern "C" MLIR_CRUNNERUTILS_EXPORT uint64_t rtrand(void *g, uint64_t m);
 // Deletes the random number generator.
-extern "C" MLIR_CRUNNERUTILS_EXPORT void rtdrand(void *);
+extern "C" MLIR_CRUNNERUTILS_EXPORT void rtdrand(void *g);
+// Uses a random number generator g and std::shuffle to modify memref m
+// in place. m will be populated with unique and random numbers
+// in the range of [0, size of m).
----------------
aartbik wrote:

I think the only point I wanted to make is that if you say "each number is in the range [0, size of vref) " then [0,0,0,...] or any sequence with at least a few duplicates would be possible. By using permutation of the integers [0,sizeof vref) you make it more clear that every index precisely occurs once, but at a random place.

https://github.com/llvm/llvm-project/pull/77124


More information about the Mlir-commits mailing list