-
Notifications
You must be signed in to change notification settings - Fork 0
Arm #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arm #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,21 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||
| #pragma once | ||||||||||||||||||||||||||||||||||||||||
| #include <cstdint> | ||||||||||||||||||||||||||||||||||||||||
| #include <chrono> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| #if defined(__x86_64__) || defined(_M_X64) | ||||||||||||||||||||||||||||||||||||||||
| #ifdef _MSC_VER | ||||||||||||||||||||||||||||||||||||||||
| #include <intrin.h> | ||||||||||||||||||||||||||||||||||||||||
| static inline uint64_t rdtsc() | ||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||
| return __rdtsc(); | ||||||||||||||||||||||||||||||||||||||||
| inline uint64_t now_ns() { | ||||||||||||||||||||||||||||||||||||||||
| return std::chrono::duration_cast<std::chrono::nanoseconds>( | ||||||||||||||||||||||||||||||||||||||||
| std::chrono::steady_clock::now().time_since_epoch() | ||||||||||||||||||||||||||||||||||||||||
| ).count(); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||
| static inline uint64_t rdtsc() | ||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||
| uint32_t lo, hi; | ||||||||||||||||||||||||||||||||||||||||
| asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); | ||||||||||||||||||||||||||||||||||||||||
| return (static_cast<uint64_t>(hi) << 32) | lo; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||
| #error "rdtsc only supported on x86_64" | ||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // #if defined(__x86_64__) || defined(_M_X64) | ||||||||||||||||||||||||||||||||||||||||
| // #ifdef _MSC_VER | ||||||||||||||||||||||||||||||||||||||||
| // #include <intrin.h> | ||||||||||||||||||||||||||||||||||||||||
| // static inline uint64_t rdtsc() | ||||||||||||||||||||||||||||||||||||||||
| // { | ||||||||||||||||||||||||||||||||||||||||
| // return __rdtsc(); | ||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||
| // #else | ||||||||||||||||||||||||||||||||||||||||
| // static inline uint64_t rdtsc() | ||||||||||||||||||||||||||||||||||||||||
| // { | ||||||||||||||||||||||||||||||||||||||||
| // uint32_t lo, hi; | ||||||||||||||||||||||||||||||||||||||||
| // asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); | ||||||||||||||||||||||||||||||||||||||||
| // return (static_cast<uint64_t>(hi) << 32) | lo; | ||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||
| // #endif | ||||||||||||||||||||||||||||||||||||||||
| // #else | ||||||||||||||||||||||||||||||||||||||||
| // #error "rdtsc only supported on x86_64" | ||||||||||||||||||||||||||||||||||||||||
| // #endif | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+28
|
||||||||||||||||||||||||||||||||||||||||
| // #if defined(__x86_64__) || defined(_M_X64) | |
| // #ifdef _MSC_VER | |
| // #include <intrin.h> | |
| // static inline uint64_t rdtsc() | |
| // { | |
| // return __rdtsc(); | |
| // } | |
| // #else | |
| // static inline uint64_t rdtsc() | |
| // { | |
| // uint32_t lo, hi; | |
| // asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); | |
| // return (static_cast<uint64_t>(hi) << 32) | lo; | |
| // } | |
| // #endif | |
| // #else | |
| // #error "rdtsc only supported on x86_64" | |
| // #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README still labels these results as "Latency (cycles)", but the code now uses
std::chrono::steady_clocknanoseconds (vianow_ns()). Please update the unit label (and ideally note the timing source) so the published benchmark numbers are interpretable and comparable.