imate
C++/CUDA Reference
|
#include <stdint.h>
Go to the source code of this file.
Functions | |
uint64_t | get_highres_time_stamp (void) |
uint64_t get_highres_time_stamp | ( | void | ) |
This function returns a high-resolution clock counter to be used to seed a random generating function (see split_mix_64.cpp). The purpose of high-resolution counter is that if the random-generating function is called subsequently in very short intervals (about nano-second), the seed value should be distinct.
In UNIX, such distinct seed values can be generated by std::clock()
function which gives the processor counter. This function has enough resolution to generate distinct values if called subsequently. In MacOS, this function is available only after version 10.12.
In Windows, however, std::clock()
is not a process counter, rather, it measures the wall clock with resoluton of one second! Thus, this function is not suitable at all on Windows. Instead, the QueryPerformanceCounter is used.
In Case if machine is neither POSIX compilant nor Windows, this function falls back to std::time and std::clock.
Note that this function works without C++11.
An alternative approach is to use rdtsc()
, but its use is discouraged, since it is far less portable and many processors (like ARM64 archetecture) do not support it. Unlike rdtsc, this function works on both X86_64 and ARM64.
Definition at line 88 of file highres_time_stamp.cpp.
Referenced by SplitMix64::SplitMix64().