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

Yinying Li llvmlistbot at llvm.org
Mon Jan 8 10:15:49 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).
----------------
yinying-lisa-li wrote:

The reason why I chose "unique and random numbers" is I would like to emphasize the uniqueness of the numbers generated as it was the main reason why I couldn't use the existing rng (it doesn't guarantee unique numbers). But if you think permutation is more precise, I could change it to that. 

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


More information about the Mlir-commits mailing list