gem5-dev@gem5.org

The gem5 Developer List

View all threads

[S] Change in gem5/gem5[hotfix-v23-0-0-1]: gpu-compute: Remove use of 'std::random_shuffle'

BB
Bobby Bruce (Gerrit)
Mon, Jul 10, 2023 10:52 PM

Bobby Bruce has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/72223?usp=email )

Change subject: gpu-compute: Remove use of 'std::random_shuffle'
......................................................................

gpu-compute: Remove use of 'std::random_shuffle'

This was deprecated in C++14 and removed in C++17. This has been
replaced with std::random. This has been implemented to ensure
reproducible results despite (pseudo)random behavior.

Change-Id: Idd52bc997547c7f8c1be88f6130adff8a37b4116

M src/cpu/testers/gpu_ruby_test/address_manager.cc
1 file changed, 9 insertions(+), 2 deletions(-)

Approvals:
Bobby Bruce: Looks good to me, approved

diff --git a/src/cpu/testers/gpu_ruby_test/address_manager.cc
b/src/cpu/testers/gpu_ruby_test/address_manager.cc
index 37f7420..049ba86 100644
--- a/src/cpu/testers/gpu_ruby_test/address_manager.cc
+++ b/src/cpu/testers/gpu_ruby_test/address_manager.cc
@@ -32,6 +32,8 @@
#include "cpu/testers/gpu_ruby_test/address_manager.hh"

#include <algorithm>
+#include <climits>
+#include <random>

#include "base/intmath.hh"
#include "base/logging.hh"
@@ -58,8 +60,13 @@
randAddressMap[i] = (Addr)((i + 128) << floorLog2(sizeof(Value)));
}

  • // randomly shuffle randAddressMap
  • std::random_shuffle(randAddressMap.begin(), randAddressMap.end());
  • // randomly shuffle randAddressMap. The seed is determined by the
    random_mt

  • // gem5 rng. This allows for deterministic randomization.

  • std::shuffle(

  •    randAddressMap.begin(),
    
  •    randAddressMap.end(),
    
  •    std::default_random_engine(random_mt.random<unsigned>(0,UINT_MAX))
    
  • );

    // initialize atomic locations
    // first and last normal location per atomic location

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/72223?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: hotfix-v23-0-0-1
Gerrit-Change-Id: Idd52bc997547c7f8c1be88f6130adff8a37b4116
Gerrit-Change-Number: 72223
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby Bruce bbruce@ucdavis.edu
Gerrit-Reviewer: Bobby Bruce bbruce@ucdavis.edu
Gerrit-Reviewer: Matthew Poremba matthew.poremba@amd.com
Gerrit-CC: kokoro noreply+kokoro@google.com

Bobby Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/72223?usp=email ) Change subject: gpu-compute: Remove use of 'std::random_shuffle' ...................................................................... gpu-compute: Remove use of 'std::random_shuffle' This was deprecated in C++14 and removed in C++17. This has been replaced with std::random. This has been implemented to ensure reproducible results despite (pseudo)random behavior. Change-Id: Idd52bc997547c7f8c1be88f6130adff8a37b4116 --- M src/cpu/testers/gpu_ruby_test/address_manager.cc 1 file changed, 9 insertions(+), 2 deletions(-) Approvals: Bobby Bruce: Looks good to me, approved diff --git a/src/cpu/testers/gpu_ruby_test/address_manager.cc b/src/cpu/testers/gpu_ruby_test/address_manager.cc index 37f7420..049ba86 100644 --- a/src/cpu/testers/gpu_ruby_test/address_manager.cc +++ b/src/cpu/testers/gpu_ruby_test/address_manager.cc @@ -32,6 +32,8 @@ #include "cpu/testers/gpu_ruby_test/address_manager.hh" #include <algorithm> +#include <climits> +#include <random> #include "base/intmath.hh" #include "base/logging.hh" @@ -58,8 +60,13 @@ randAddressMap[i] = (Addr)((i + 128) << floorLog2(sizeof(Value))); } - // randomly shuffle randAddressMap - std::random_shuffle(randAddressMap.begin(), randAddressMap.end()); + // randomly shuffle randAddressMap. The seed is determined by the random_mt + // gem5 rng. This allows for deterministic randomization. + std::shuffle( + randAddressMap.begin(), + randAddressMap.end(), + std::default_random_engine(random_mt.random<unsigned>(0,UINT_MAX)) + ); // initialize atomic locations // first and last normal location per atomic location -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/72223?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: public/gem5 Gerrit-Branch: hotfix-v23-0-0-1 Gerrit-Change-Id: Idd52bc997547c7f8c1be88f6130adff8a37b4116 Gerrit-Change-Number: 72223 Gerrit-PatchSet: 1 Gerrit-Owner: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-Reviewer: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-Reviewer: Matthew Poremba <matthew.poremba@amd.com> Gerrit-CC: kokoro <noreply+kokoro@google.com>