-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
331 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef _PAREAS_COMPILER_PROFILER_HPP | ||
#define _PAREAS_COMPILER_PROFILER_HPP | ||
|
||
#include "futhark_generated.h" | ||
|
||
#include <iosfwd> | ||
#include <chrono> | ||
#include <vector> | ||
|
||
struct Profiler { | ||
using Clock = std::chrono::high_resolution_clock; | ||
|
||
struct HistoryEntry { | ||
unsigned level; | ||
const char* name; | ||
Clock::duration elapsed; | ||
}; | ||
|
||
unsigned max_level; | ||
unsigned level; | ||
|
||
std::vector<Clock::time_point> starts; | ||
std::vector<HistoryEntry> history; | ||
|
||
Profiler(unsigned max_level); | ||
|
||
void begin(futhark_context* ctx = nullptr); | ||
void end(const char* name, futhark_context* ctx = nullptr); | ||
|
||
void dump(std::ostream& os); | ||
|
||
template <typename F> | ||
void measure(const char* name, F f) { | ||
this->begin(); | ||
f(); | ||
this->end(name); | ||
} | ||
|
||
template <typename F> | ||
void measure(const char* name, futhark_context* ctx, F f) { | ||
this->begin(ctx); | ||
f(); | ||
this->end(name, ctx); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.