diff options
author | Martin Kroeker <martin@ruby.chemie.uni-freiburg.de> | 2021-03-02 17:50:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 17:50:55 +0100 |
commit | 38dcf3454bf4d3a4b5b470791277904c025d7369 (patch) | |
tree | bb78e328a35de6cb661679521d2a02e335c3874b /benchmark | |
parent | 93843c55b68f420bbce896153ec8673a5c2d4e5b (diff) | |
download | openblas-38dcf3454bf4d3a4b5b470791277904c025d7369.tar.gz openblas-38dcf3454bf4d3a4b5b470791277904c025d7369.tar.bz2 openblas-38dcf3454bf4d3a4b5b470791277904c025d7369.zip |
Support timing Apple M1
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/bench.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/benchmark/bench.h b/benchmark/bench.h index 1f9b8986c..83de8ab2b 100644 --- a/benchmark/bench.h +++ b/benchmark/bench.h @@ -74,6 +74,9 @@ static void *huge_malloc(BLASLONG size){ #if defined(__WIN32__) || defined(__WIN64__) || !defined(_POSIX_TIMERS) struct timeval start, stop; +#elif defined(__APPLE__) + mach_timebase_info_data_t info; + uint64_t start = 0, stop = 0; #else struct timespec start = { 0, 0 }, stop = { 0, 0 }; #endif @@ -82,6 +85,9 @@ double getsec() { #if defined(__WIN32__) || defined(__WIN64__) || !defined(_POSIX_TIMERS) return (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6; +#elif defined(__APPLE__) + mach_timebase_info(&info); + return (double)(((stop - start) * info.numer)/info.denom) * 1.e-9; #else return (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_nsec - start.tv_nsec)) * 1.e-9; #endif @@ -90,6 +96,8 @@ double getsec() void begin() { #if defined(__WIN32__) || defined(__WIN64__) || !defined(_POSIX_TIMERS) gettimeofday( &start, (struct timezone *)0); +#elif defined(__APPLE__) + start = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); #else clock_gettime(CLOCK_REALTIME, &start); #endif @@ -98,7 +106,9 @@ void begin() { void end() { #if defined(__WIN32__) || defined(__WIN64__) || !defined(_POSIX_TIMERS) gettimeofday( &stop, (struct timezone *)0); +#elif defined(__APPLE__) + stop = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); #else clock_gettime(CLOCK_REALTIME, &stop); #endif -}
\ No newline at end of file +} |