Merge pull request #872 from yxsamliu/chrono
Use chrono instead of sys/time.h in test
This commit is contained in:
@@ -19,7 +19,11 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#if __CUDACC__
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#else
|
||||||
|
#include <chrono>
|
||||||
|
#endif
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "hip/hip_runtime.h"
|
#include "hip/hip_runtime.h"
|
||||||
@@ -105,9 +109,14 @@ namespace HipTest {
|
|||||||
|
|
||||||
// Returns the current system time in microseconds
|
// Returns the current system time in microseconds
|
||||||
inline long long get_time() {
|
inline long long get_time() {
|
||||||
|
#if __CUDACC__
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
return (tv.tv_sec * 1000000) + tv.tv_usec;
|
return (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||||
|
#else
|
||||||
|
return std::chrono::high_resolution_clock::now().time_since_epoch()
|
||||||
|
/std::chrono::microseconds(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
double elapsed_time(long long startTimeUs, long long stopTimeUs);
|
double elapsed_time(long long startTimeUs, long long stopTimeUs);
|
||||||
|
|||||||
Reference in New Issue
Block a user