summaryrefslogtreecommitdiff
path: root/test/correctness/misc/preprocessor.cpp
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-12-05 20:39:49 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-12-05 20:39:49 +0100
commit0f9637bbac6248a381d7012d7224331d3d394efb (patch)
tree958093804cd0f1be907a2b748c0477fd811cbb35 /test/correctness/misc/preprocessor.cpp
parentcf4555d1f44aea9c82b60211b5650b6b77a1226c (diff)
Improved array-to-register promotion, now handling function calls as well
Diffstat (limited to 'test/correctness/misc/preprocessor.cpp')
-rw-r--r--test/correctness/misc/preprocessor.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/correctness/misc/preprocessor.cpp b/test/correctness/misc/preprocessor.cpp
index 71b59c04..fa0d2ccc 100644
--- a/test/correctness/misc/preprocessor.cpp
+++ b/test/correctness/misc/preprocessor.cpp
@@ -60,6 +60,54 @@ bool TestDefines() {
const auto result1 = PreprocessKernelSource(source1);
return result1 == expected1;
}
+// =================================================================================================
+
+bool TestArrayToRegisterPromotion() {
+ const auto source1 =
+ R"(#define WPT 2
+inline void SetValues(int float, float values[WPT],
+ const float k) {
+ #pragma unroll
+ for (int i = 0; i < WPT; i += 1) {
+ values[i] = k + j;
+ }
+}
+__kernel void ExampleKernel() {
+ #pragma promote_to_registers
+ float values[WPT];
+ #pragma unroll
+ for (int i = 0; i < WPT; i += 1) {
+ values[i] = 0.0f;
+ }
+ SetValues(12.3f, values, -3.9f);
+}
+)";
+ const auto expected1 =
+ R"(#define WPT 2
+inline void SetValues(int float, float values_0, float values_1,
+ const float k) {
+ {
+ values_0 = k + j;
+ }
+ {
+ values_1 = k + j;
+ }
+}
+__kernel void ExampleKernel() {
+ float values_0;
+ float values_1;
+ {
+ values_0 = 0.0f;
+ }
+ {
+ values_1 = 0.0f;
+ }
+ SetValues(12.3f, values_0, values_1, -3.9f);
+}
+)";
+ const auto result1 = PreprocessKernelSource(source1);
+ return result1 == expected1;
+}
// =================================================================================================
@@ -110,6 +158,7 @@ size_t RunPreprocessor(int argc, char *argv[], const bool silent, const Precisio
// Basic tests
if (TestDefines()) { passed++; } else { errors++; }
+ if (TestArrayToRegisterPromotion()) { passed++; } else { errors++; }
// XAXPY
const auto xaxpy_sources =