summaryrefslogtreecommitdiff
path: root/src/routine.cpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-07-06 21:50:12 +0200
committerCedric Nugteren <web@cedricnugteren.nl>2016-07-06 21:50:12 +0200
commit27854070b4f9ba1d58ccd7189032e56325506597 (patch)
treea2e1b393ad06668f00ac7f5701d53df10a97fb4c /src/routine.cpp
parent77325b8974e19188fc5afad1447d4df4f9ae30fd (diff)
Added a VERBOSE mode to debug performance: now prints details about compilation and kernel execution to screen
Diffstat (limited to 'src/routine.cpp')
-rw-r--r--src/routine.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/routine.cpp b/src/routine.cpp
index d3590896..3c3343da 100644
--- a/src/routine.cpp
+++ b/src/routine.cpp
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
+#include <chrono>
#include "routine.hpp"
@@ -103,6 +104,13 @@ StatusCode Routine::SetUp() {
// Combines everything together into a single source string
const auto source_string = defines + common_header + source_string_;
+ // Prints details of the routine to compile in case of debugging in verbose mode
+ #ifdef VERBOSE
+ printf("[DEBUG] Compiling routine '%s-%s' for device '%s'\n",
+ routine_name_.c_str(), ToString(precision_).c_str(), device_name_.c_str());
+ const auto start_time = std::chrono::steady_clock::now();
+ #endif
+
// Compiles the kernel
try {
auto program = Program(context_, source_string);
@@ -123,6 +131,13 @@ StatusCode Routine::SetUp() {
StoreProgramToCache(program, context_, precision_, routine_name_);
} catch (...) { return StatusCode::kBuildProgramFailure; }
+ // Prints the elapsed compilation time in case of debugging in verbose mode
+ #ifdef VERBOSE
+ const auto elapsed_time = std::chrono::steady_clock::now() - start_time;
+ const auto timing = std::chrono::duration<double,std::milli>(elapsed_time).count();
+ printf("[DEBUG] Completed compilation in %.2lf ms\n", timing);
+ #endif
+
// No errors, normal termination of this function
return StatusCode::kSuccess;
}