From 0a90fd1a250a040c793d6cc4120defa8832fb2cf Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 23 Apr 2024 22:24:07 +0100 Subject: [PATCH] [*] Force compile time optimizations under RNG --- Source/RNG/AuRandomDevice.cpp | 80 +++++++++++++++++------------------ Source/RNG/AuWELL.cpp | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Source/RNG/AuRandomDevice.cpp b/Source/RNG/AuRandomDevice.cpp index 2c35b27a..e3fbb2de 100644 --- a/Source/RNG/AuRandomDevice.cpp +++ b/Source/RNG/AuRandomDevice.cpp @@ -189,7 +189,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a32Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a32Runtime(&uMassiveWord); } return iMin + uNext; } @@ -202,7 +202,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a32Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a32Runtime(&uMassiveWord); } return uMin + uNext; } @@ -313,7 +313,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a32Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a32Runtime(&uMassiveWord); } ret[uIndex] = iMin + uNext; @@ -336,10 +336,10 @@ namespace Aurora::RNG { AuUInt32 uNext {}; - uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a32Runtime(&uSeed); while ((uNext = (uSeed & (uUpperBound - 1))) > uRange) { - uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a32Runtime(&uSeed); } ret[uIndex] = iMin + uNext; @@ -366,7 +366,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a32Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a32Runtime(&uMassiveWord); } ret[uIndex] = uMin + uNext; @@ -389,10 +389,10 @@ namespace Aurora::RNG { AuUInt32 uNext {}; - uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a32Runtime(&uSeed); while ((uNext = (uSeed & (uUpperBound - 1))) > uRange) { - uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a32Runtime(&uSeed); } ret[uIndex] = uMin + uNext; @@ -450,7 +450,7 @@ namespace Aurora::RNG dValue *= dRange; dValue += dMin; ret[uIndex] = dValue; - uSeed = AuFnv1a64Runtime(&uSeed, 8); + uSeed = AuFnv1a64Runtime<8>(&uSeed); } return ret; @@ -480,7 +480,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a64Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a64Runtime(&uMassiveWord); } return uMin + uNext; } @@ -493,7 +493,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a64Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a64Runtime(&uMassiveWord); } return iMin + uNext; } @@ -512,10 +512,10 @@ namespace Aurora::RNG { AuUInt64 uNext {}; - uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a64Runtime(&uSeed); while ((uNext = (uSeed & (uUpperBound - 1))) > uRange) { - uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a64Runtime(&uSeed); } ret[uIndex] = iMin + uNext; @@ -538,10 +538,10 @@ namespace Aurora::RNG { AuUInt64 uNext {}; - uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a64Runtime(&uSeed); while ((uNext = (uSeed & (uUpperBound - 1))) > uRange) { - uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed)); + uSeed = AuFnv1a64Runtime(&uSeed); } ret[uIndex] = uMin + uNext; @@ -568,7 +568,7 @@ namespace Aurora::RNG auto uSeed = this->NextU64(); auto uComponentA = RngConvertToDecimal(uSeed); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); return AuVec2 { (uComponentA * range[0]) + min[0], @@ -597,8 +597,8 @@ namespace Aurora::RNG auto uSeed = this->NextU64(); auto uComponentA = RngConvertToDecimal(uSeed); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); return AuVec3 { (uComponentA * range[0]) + min[0], @@ -631,9 +631,9 @@ namespace Aurora::RNG auto uSeed = this->NextU64(); auto uComponentA = RngConvertToDecimal(uSeed); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentD = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentD = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); return AuVec4 { (uComponentA * range[0]) + min[0], @@ -661,7 +661,7 @@ namespace Aurora::RNG AuUInt64 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a64Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a64Runtime(&uMassiveWord); } ret[uIndex] = iMin + uRange; @@ -688,7 +688,7 @@ namespace Aurora::RNG AuUInt64 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) > uRange) { - uMassiveWord = AuFnv1a64Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a64Runtime(&uMassiveWord); } ret[uIndex] = uMin + uNext; @@ -764,7 +764,7 @@ namespace Aurora::RNG { auto uSeed = rngBytes[uIndex]; auto uComponentA = RngConvertToDecimal(uSeed); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); ret[uIndex] = AuVec2 { (uComponentA * range[0]) + min[0], @@ -789,8 +789,8 @@ namespace Aurora::RNG for (AU_ITERATE_N(uIndex, uCount)) { - auto uComponentA = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentA = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); ret[uIndex] = AuVec2 { (uComponentA * range[0]) + min[0], @@ -831,8 +831,8 @@ namespace Aurora::RNG { auto uSeed = rngBytes[uIndex]; auto uComponentA = RngConvertToDecimal(uSeed); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); ret[uIndex] = AuVec3 { (uComponentA * range[0]) + min[0], @@ -859,9 +859,9 @@ namespace Aurora::RNG for (AU_ITERATE_N(uIndex, uCount)) { - auto uComponentA = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentA = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); ret[uIndex] = AuVec3 { (uComponentA * range[0]) + min[0], @@ -906,9 +906,9 @@ namespace Aurora::RNG { auto uSeed = rngBytes[uIndex]; auto uComponentA = RngConvertToDecimal(uSeed); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentD = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentD = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); ret[uIndex] = AuVec4 { (uComponentA * range[0]) + min[0], @@ -937,10 +937,10 @@ namespace Aurora::RNG for (AU_ITERATE_N(uIndex, uCount)) { - auto uComponentA = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); - auto uComponentD = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime(&uSeed, 8))); + auto uComponentA = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentB = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentC = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); + auto uComponentD = RngConvertToDecimal(uSeed = (AuFnv1a64Runtime<8>(&uSeed))); ret[uIndex] = AuVec4 { (uComponentA * range[0]) + min[0], @@ -1000,7 +1000,7 @@ namespace Aurora::RNG for (AU_ITERATE_N(uIndex, uCount)) { ret[uIndex] = RngConvertToDecimal(uSeed); - uSeed = AuFnv1a64Runtime(&uSeed, 8); + uSeed = AuFnv1a64Runtime<8>(&uSeed); } return ret; @@ -1026,7 +1026,7 @@ namespace Aurora::RNG AuUInt32 uNext {}; while ((uNext = (uMassiveWord & (uUpperBound - 1))) >= uCount) { - uMassiveWord = AuFnv1a32Runtime(&uMassiveWord, sizeof(uMassiveWord)); + uMassiveWord = AuFnv1a32Runtime(&uMassiveWord); } return uNext; } diff --git a/Source/RNG/AuWELL.cpp b/Source/RNG/AuWELL.cpp index ef34b62c..8f8db29b 100644 --- a/Source/RNG/AuWELL.cpp +++ b/Source/RNG/AuWELL.cpp @@ -89,7 +89,7 @@ auline AuUInt32 WELL_NextLong_Unlocked(WELLRand *rand) a = rand->state[rand->index]; rand->state[rand->index] = a ^ b ^ d ^ (a << 2) ^ (b << 18) ^ (c << 28); ret = rand->state[rand->index]; - return AuFnv1a32Runtime(&ret, sizeof(ret)); + return AuFnv1a32Runtime(&ret); } /**