summaryrefslogtreecommitdiff
path: root/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'output.c')
-rw-r--r--output.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/output.c b/output.c
new file mode 100644
index 0000000..afd0685
--- /dev/null
+++ b/output.c
@@ -0,0 +1,65 @@
+// > 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>
+
+static void expfun_13(int64_t* x14, int64_t* x15) {
+ x14[(0)] = (2LL);
+ x15[(0)] = (3LL);
+}
+
+static void expfun_16(int64_t n1, int64_t n2, int64_t* a3, int64_t n4, int64_t* a5, int64_t* a6, int64_t x17, int64_t x18, int64_t* x19) {
+ int64_t i20;
+ i20 = ((x17) * (n2)) + (x18);
+ int64_t x21;
+ int64_t x22;
+ int64_t i23;
+ i23 = x17;
+ x21 = a5[i23];
+ x22 = a6[i23];
+ x19[(0)] = (((x17) * (x18)) + (a3[i20])) + ((x21) * (x22));
+}
+
+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 n25 = (0); n25 < (n7); n25++) {
+ for (int64_t n26 = (0); n26 < (n8); n26++) {
+ int64_t x24;
+ expfun_16(n1, n2, a3, n4, a5, a6, n25, n26, &(x24));
+ a9[((n25) * (n8)) + (n26)] = x24;
+ }
+ }
+ 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");
+}