From 4e0d08c3bcf1816984934fcb211355590564615f Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sun, 19 Nov 2017 16:58:13 +0100 Subject: Added compilation timing and better compilation error reporting --- src/tuning/tuning.cpp | 2 +- src/tuning/tuning.hpp | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/tuning') diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp index 6804fbce..0af17a6f 100644 --- a/src/tuning/tuning.cpp +++ b/src/tuning/tuning.cpp @@ -81,7 +81,7 @@ void PrintTimingsToFileAsJSON(const std::string &filename, void print_separator(const size_t parameters_size) { printf("x------x-------x"); for (auto i = size_t{0}; i < parameters_size; ++i) { printf("-----"); } - printf("-x----------x--------------x--------x-------------------x\n"); + printf("-x----------------x--------------x--------x-------------------x\n"); } // ================================================================================================= diff --git a/src/tuning/tuning.hpp b/src/tuning/tuning.hpp index 80d71e06..2c7f6a0b 100644 --- a/src/tuning/tuning.hpp +++ b/src/tuning/tuning.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "utilities/utilities.hpp" #include "utilities/compile.hpp" @@ -211,7 +212,7 @@ void Tuner(int argc, char* argv[]) { printf("\n"); printf("| ID | total |"); for (auto i = size_t{0}; i < settings.parameters.size() - 1; ++i) { printf(" "); } - printf("param | compiles | time | %6s | status |\n", settings.performance_unit.c_str()); + printf("param | compiles | time | %6s | status |\n", settings.performance_unit.c_str()); print_separator(settings.parameters.size()); // First runs a reference example to compare against @@ -232,7 +233,7 @@ void Tuner(int argc, char* argv[]) { device, context, compiler_options); auto kernel = Kernel(program, settings.kernel_name); C::SetArguments(kernel, args, device_buffers); - printf(" %sOK%s |", kPrintSuccess.c_str(), kPrintEnd.c_str()); + printf(" %sOK%s |", kPrintSuccess.c_str(), kPrintEnd.c_str()); // Runs the kernel const auto time_ms = TimeKernel(args.num_runs, kernel, queue, device, @@ -248,7 +249,6 @@ void Tuner(int argc, char* argv[]) { } catch (...) { const auto status_code = DispatchExceptionCatchAll(true); - printf(" %d |\n", static_cast(status_code)); printf("* Exception caught with status %d while running the reference, aborting\n", static_cast(status_code)); return; @@ -286,11 +286,14 @@ void Tuner(int argc, char* argv[]) { kernel_source += settings.sources; // Compiles the kernel + const auto start_time = std::chrono::steady_clock::now(); auto compiler_options = std::vector(); const auto program = CompileFromSource(kernel_source, args.precision, settings.kernel_name, - device, context, compiler_options); + device, context, compiler_options, true); auto kernel = Kernel(program, settings.kernel_name); - printf(" %sOK%s |", kPrintSuccess.c_str(), kPrintEnd.c_str()); + const auto elapsed_time = std::chrono::steady_clock::now() - start_time; + const auto timing = std::chrono::duration(elapsed_time).count(); + printf(" %sOK%s %5.0lf ms |", kPrintSuccess.c_str(), kPrintEnd.c_str(), timing); // Runs the kernel C::SetArguments(kernel, args, device_buffers); @@ -326,6 +329,12 @@ void Tuner(int argc, char* argv[]) { printf(" %6.1lf |", settings.metric_amount / (time_ms * 1.0e6)); printf(" %sresults match%s |\n", kPrintSuccess.c_str(), kPrintEnd.c_str()); } + catch (const CLCudaAPIBuildError &e) { + const auto status_code = DispatchExceptionCatchAll(true); + printf(" %scompilation error: %5d%s |", + kPrintError.c_str(), static_cast(status_code), kPrintEnd.c_str()); + printf(" - | - | <-- skipping\n"); + } catch (...) { const auto status_code = DispatchExceptionCatchAll(true); if (status_code != StatusCode::kUnknownError) { @@ -384,7 +393,6 @@ void Tuner(int argc, char* argv[]) { printf("* Completed tuning process\n"); printf("\n"); - } // ================================================================================================= -- cgit v1.2.3