Last change
on this file since 4dab7e8 was
c92bdcc,
checked in by Andrew Beach <ajbeach@…>, 6 months ago
|
Updated the rest of the names in src/ (except for the generated files).
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
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.cpp -- |
---|
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.hpp" |
---|
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) { |
---|
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 |
---|
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.