Skip to content

Commit

Permalink
use std::call_once for initializing random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
amberhassaan committed Sep 4, 2023
1 parent 9ce51ec commit 082d166
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/gpu_reference_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <miopen/tensor_layout.hpp>
#include <miopen/bfloat16.hpp>
#include <vector>
#include <mutex>
#include <cstdlib>
#include <ctime>
#include <tuple> // std::ignore
Expand Down Expand Up @@ -73,11 +74,11 @@ std::string tensor_layout_to_string(tensor_layout_t layout)

static int gen_rand_integer()
{
static const bool once = []() {
std::srand(std::time(nullptr));
return true;
}();
std::ignore = once;
static std::once_flag f;
std::call_once(f, []() {
std::srand(std::time(nullptr));
});

return GET_RAND();
}

Expand Down

0 comments on commit 082d166

Please sign in to comment.