summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-09-25 21:46:24 +0200
committerTom Smeding <tom@tomsmeding.com>2021-09-25 21:46:24 +0200
commit4a782ea40ccb2043d96d437d5718cdf2c27a546f (patch)
treeafb8d8c100a1474a2c3f9cce8ab1197d83a4ddde
parent57e5bbbbab0d5315c6bba497447ff9bf2487e995 (diff)
Add example output in test.c
-rw-r--r--.gitignore1
-rw-r--r--test.c91
2 files changed, 92 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index c33954f..f8862b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
dist-newstyle/
+test
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..24b7b3d
--- /dev/null
+++ b/test.c
@@ -0,0 +1,91 @@
+// > import Data.Array.Accelerate.C
+// > import qualified Data.Array.Accelerate as A
+// > import qualified Data.Array.Accelerate.Interpreter as I
+// > let Right (p,_,_) = translateAcc "kaas" $ \(A.T2 a b) -> A.generate (A.I2 2 3) (\(A.I2 i j) -> let A.T2 x y = b A.! A.I1 i in i * j + a A.! A.I2 i j + x * y :: A.Exp Int) in putStr p
+// [...this file without main()...]
+// > I.run1 (\(A.T2 a b) -> A.generate (A.I2 2 3) (\(A.I2 i j) -> let A.T2 x y = b A.! A.I1 i in i * j + a A.! A.I2 i j + x * y :: A.Exp Int)) (A.fromList (A.Z A.:. (2 :: Int) A.:. (3 :: Int)) [0..], A.fromList (A.Z A.:. (2 :: Int)) [(1,2), (3,4)])
+// Matrix (Z :. 2 :. 3)
+// [ 2, 3, 4,
+// 15, 17, 19]
+//
+// Running this program will give the same result. :)
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+void expfun_13(int64_t* x14, int64_t* x15) {
+ int64_t x16;
+ int64_t x17;
+ x16 = (2LL);
+ x17 = (3LL);
+ x14[(0)] = x16;
+ x15[(0)] = x17;
+}
+
+void expfun_18(int64_t n1, int64_t n2, int64_t* a3, int64_t n4, int64_t* a5, int64_t* a6, int64_t x19, int64_t x20, int64_t* x21) {
+ int64_t x35;
+ int64_t x36;
+ int64_t x27;
+ int64_t x28;
+ int64_t x22;
+ int64_t x23;
+ x22 = x19;
+ x23 = x20;
+ x27 = (x22) * (x23);
+ int64_t i24;
+ int64_t x25;
+ int64_t x26;
+ x25 = x19;
+ x26 = x20;
+ i24 = ((x25) * (n2)) + (x26);
+ x28 = a3[i24];
+ x35 = (x27) + (x28);
+ int64_t x29;
+ int64_t x30;
+ int64_t i31;
+ int64_t x32;
+ x32 = x19;
+ i31 = x32;
+ x29 = a5[i31];
+ x30 = a6[i31];
+ int64_t x33;
+ int64_t x34;
+ x33 = x29;
+ x34 = x30;
+ x36 = (x33) * (x34);
+ x21[(0)] = (x35) + (x36);
+}
+
+void kaas(int64_t n1, int64_t n2, int64_t* a3, int64_t n4, int64_t* a5, int64_t* a6, int64_t* n10, int64_t* n11, int64_t** a12) {
+ int64_t n7;
+ int64_t n8;
+ expfun_13(&(n7), &(n8));
+ int64_t* a9 = malloc(((n7) * (n8)) * ((sizeof (int64_t))));
+ for (int64_t n38 = (0); n38 < (n7); n38++) {
+ for (int64_t n39 = (0); n39 < (n8); n39++) {
+ int64_t x37;
+ expfun_18(n1, n2, a3, n4, a5, a6, n38, n39, &(x37));
+ a9[((n38) * (n8)) + (n39)] = x37;
+ }
+ }
+ n10[(0)] = n7;
+ n11[(0)] = n8;
+ a12[(0)] = a9;
+}
+
+int main() {
+ int64_t a[6] = {0, 1, 2, 3, 4, 5};
+ int64_t b1[2] = {1, 3};
+ int64_t b2[2] = {2, 4};
+ int64_t resn1, resn2;
+ int64_t *res;
+ kaas(2, 3, a, 2, b1, b2, &resn1, &resn2, &res);
+ printf("%" PRIi64 "x%" PRIi64 ":", resn1, resn2);
+ for (int64_t i = 0; i < resn1; i++)
+ for (int64_t j = 0; j < resn2; j++)
+ printf(" %" PRIi64, res[resn2 * i + j]);
+ printf("\n");
+}