Last change
on this file since d414664 was
b0b1e15,
checked in by Thierry Delisle <tdelisle@…>, 4 years ago
|
fix timestamp generation for arm inside the compiler
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[57e0289] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // ResolveTime.cc -- |
---|
| 8 | // |
---|
| 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Wed Sep 16 15:45:51 2020 |
---|
| 11 | // Last Modified By : |
---|
| 12 | // Last Modified On : |
---|
| 13 | // Update Count : |
---|
| 14 | // |
---|
| 15 | |
---|
| 16 | #include "ResolveTime.h" |
---|
| 17 | |
---|
| 18 | #include <fstream> |
---|
| 19 | #include <iomanip> |
---|
| 20 | |
---|
| 21 | #include "AST/Fwd.hpp" |
---|
| 22 | #include "AST/Expr.hpp" |
---|
| 23 | #include "AST/Print.hpp" |
---|
| 24 | #include "AST/Type.hpp" |
---|
| 25 | |
---|
| 26 | namespace Stats { |
---|
| 27 | namespace ResolveTime { |
---|
| 28 | static inline long long rdtscl(void) { |
---|
[b0b1e15] | 29 | #if defined( __i386 ) || defined( __x86_64 ) |
---|
| 30 | unsigned int lo, hi; |
---|
| 31 | __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); |
---|
| 32 | return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); |
---|
| 33 | #elif defined( __aarch64__ ) |
---|
| 34 | int64_t value; |
---|
| 35 | asm volatile("mrs %0, cntvct_el0" : "=r"(value)); |
---|
| 36 | return value; |
---|
| 37 | #else |
---|
| 38 | #error unknown hardware architecture |
---|
| 39 | #endif |
---|
[57e0289] | 40 | } |
---|
| 41 | |
---|
| 42 | extern bool enabled; |
---|
| 43 | bool started = false; |
---|
| 44 | long long before; |
---|
| 45 | std::ostream & out = std::cout; |
---|
| 46 | |
---|
| 47 | void start( const ast::Expr * expr ) { |
---|
| 48 | if(enabled) { |
---|
| 49 | assert(!started); |
---|
| 50 | started = true; |
---|
| 51 | |
---|
| 52 | out << expr->location << " : "; |
---|
| 53 | |
---|
| 54 | before = rdtscl(); |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | void stop() { |
---|
| 58 | if(enabled) { |
---|
| 59 | assert(started); |
---|
| 60 | auto after = rdtscl(); |
---|
| 61 | out << (after - before) << std::endl; |
---|
| 62 | |
---|
| 63 | started = false; |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | }; |
---|
| 67 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.