Unverified Commit 64f6f3c1 authored by Quan (Andy) Gan's avatar Quan (Andy) Gan Committed by GitHub
Browse files

[Bug?] Fix non-determinism when setting the same seed across different runs...

[Bug?] Fix non-determinism when setting the same seed across different runs with single thread (#1205)

* fix multithread random seed value

* more fix

* typo

* what did i wrote
parent 86fe58eb
......@@ -17,8 +17,16 @@ namespace dgl {
namespace {
inline uint32_t GetThreadId() {
static std::hash<std::thread::id> kThreadIdHasher;
return kThreadIdHasher(std::this_thread::get_id());
static int num_threads = 0;
static std::mutex mutex;
static thread_local int id = -1;
if (id == -1) {
std::lock_guard<std::mutex> guard(mutex);
id = num_threads;
num_threads++;
}
return id;
}
}; // namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment