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

Aart Bik llvmlistbot at llvm.org
Mon Jan 8 09:56:21 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:

Using m above for [0,m) as scalar, and here as memref m is confusing. I addition using size m as the range adds to the confusion. So I would at least name the memref differently, like vref.

But also, rather than saying each number is in the range [0, size of vref) now, just say it will be a permutation of all numbers in that range, which seems more precise on what will happen?

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


More information about the Mlir-commits mailing list