summaryrefslogtreecommitdiff
path: root/src/utilities/compile.cpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-11-30 21:32:47 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-11-30 21:32:47 +0100
commit13eb772343c46109da0181db3bdc6fa436a9dcce (patch)
treeb6c9ff01500de47fde27e60b7e84f000d37e628c /src/utilities/compile.cpp
parent93ffb876c60838bee75d3bb25ebbcbfce02e2cc7 (diff)
Integrated pre-processor in compilation flow, default is still disabled
Diffstat (limited to 'src/utilities/compile.cpp')
-rw-r--r--src/utilities/compile.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/utilities/compile.cpp b/src/utilities/compile.cpp
index 2a55506e..4d1e8929 100644
--- a/src/utilities/compile.cpp
+++ b/src/utilities/compile.cpp
@@ -15,6 +15,7 @@
#include <chrono>
#include "routines/common.hpp"
+#include "kernel_preprocessor.hpp"
namespace clblast {
// =================================================================================================
@@ -23,7 +24,8 @@ namespace clblast {
Program CompileFromSource(const std::string &source_string, const Precision precision,
const std::string &routine_name,
const Device& device, const Context& context,
- std::vector<std::string>& options, const bool silent) {
+ std::vector<std::string>& options,
+ const bool run_preprocessor, const bool silent) {
auto header_string = std::string{""};
header_string += "#define PRECISION " + ToString(static_cast<int>(precision)) + "\n";
@@ -73,8 +75,15 @@ Program CompileFromSource(const std::string &source_string, const Precision prec
const auto start_time = std::chrono::steady_clock::now();
#endif
+ // Runs a pre-processor to unroll loops and perform array-to-register promotion
+ auto kernel_string = header_string + source_string;
+ if (run_preprocessor) {
+ log_debug("Running built-in pre-processor");
+ kernel_string = PreprocessKernelSource(kernel_string);
+ }
+
// Compiles the kernel
- auto program = Program(context, header_string + source_string);
+ auto program = Program(context, kernel_string);
try {
program.Build(device, options);
} catch (const CLCudaAPIBuildError &e) {