summaryrefslogtreecommitdiff
path: root/test-chill/unit-tests/cpp_validate_prog
diff options
context:
space:
mode:
Diffstat (limited to 'test-chill/unit-tests/cpp_validate_prog')
-rwxr-xr-xtest-chill/unit-tests/cpp_validate_prog/mm_in.py9
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one.cc29
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one.testproc6
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_defines.cc25
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_longer_main.cc93
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_longer_wrong_main.cc93
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_main.cc91
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_out.cc60
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_with.cc30
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_with.testproc7
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_one_with_defines.cc25
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc33
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc.databin124 -> 0 bytes
-rw-r--r--test-chill/unit-tests/cpp_validate_prog/mm_three_slow.cc35
-rwxr-xr-xtest-chill/unit-tests/cpp_validate_prog/print_mm_out.py10
15 files changed, 0 insertions, 546 deletions
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_in.py b/test-chill/unit-tests/cpp_validate_prog/mm_in.py
deleted file mode 100755
index 93eb080..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_in.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/python
-
-import struct
-
-data = list(range(15)) + list(range(10)) + [0]*6
-bindata = ''.join([struct.pack('f',n) for n in data])
-with open('mm.in.data','wb') as f:
- f.write(bindata)
-
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one.cc
deleted file mode 100644
index 6131ae1..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-#define AN 3
-#define BM 2
-#define AMBN 5
-
-/*
-
-<test name='mm_small'>
-
-procedure void mm(
- in float[3][5] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[5][2] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[3][2] C = matrix([*,*],lambda i,j: 0))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one.testproc b/test-chill/unit-tests/cpp_validate_prog/mm_one.testproc
deleted file mode 100644
index a12a963..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one.testproc
+++ /dev/null
@@ -1,6 +0,0 @@
-
-procedure void mm(
- in float[3][5] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[5][2] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[3][2] C = matrix([*,*],lambda i,j: 0))
-
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_defines.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_defines.cc
deleted file mode 100644
index e35f189..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_defines.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-
-/*
-<test name='mm_small' define="{'AN':3, 'BM':2, 'AMBN':5}">
-
-procedure void mm(
- in float[AN][AMBN] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[AMBN][BM] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[AN][BM] C = matrix([*,*],lambda i,j: 0))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_longer_main.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_longer_main.cc
deleted file mode 100644
index 5b7e6c1..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_longer_main.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-#define AN 3
-#define BM 2
-#define AMBN 5
-//#define PRINT
-
-#include <time.h>
-#include <fstream>
-#include <cstdio>
-
-/*
-
-<test name='mm_small'>
-
-procedure void mm(
- in float[3][5] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[5][2] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[3][2] C = matrix([*,*],lambda i,j: 0))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- C[i][j] = 0;
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
-
-int main(int argc, char** argv) {
- float A[3][5] = {{0,1,2,3,4},{5,6,7,8,9},{10,11,12,13,14}};
- float B[5][2] = {{0,1},{2,3},{4,5},{6,7},{8,9}};
- float C[3][2] = {{0,0},{0,0},{0,0}};
- timespec start_time;
- timespec end_time;
-
- if (argc == 3) {
- std::ifstream is(argv[1], std::ifstream::in | std::ifstream::binary);
- is.read((char*)A, 15*sizeof(float));
- is.read((char*)B, 10*sizeof(float));
- is.close();
- }
-
- clock_gettime(CLOCK_REALTIME, &start_time);
- for(int i = 0; i < 10000; i++) {
- mm(A,B,C);
- }
- clock_gettime(CLOCK_REALTIME, &end_time);
-
- if (argc == 3) {
- std::ofstream os(argv[2], std::ofstream::out | std::ofstream::binary);
- os.write((char*)C, 6*sizeof(float));
- os.close();
- }
-
- #ifdef PRINT
- std::printf("A:\n");
- for(int i = 0; i < 3; i++) {
- std::printf("[");
- for(int j = 0; j < 5; j++) {
- std::printf("%f,",A[i][j]);
- }
- std::printf("]\n");
- }
- std::printf("B:\n");
- for(int i = 0; i < 5; i++) {
- std::printf("[");
- for(int j = 0; j < 2; j++) {
- std::printf("%f,",B[i][j]);
- }
- std::printf("]\n");
- }
- std::printf("C:\n");
- for(int i = 0; i < 3; i++) {
- std::printf("[");
- for(int j = 0; j < 2; j++) {
- std::printf("%f,",C[i][j]);
- }
- std::printf("]\n");
- }
- #else
- double time_diff = (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec)/1000000000.0;
- std::printf("(%f,)", time_diff);
- #endif
- return 0;
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_longer_wrong_main.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_longer_wrong_main.cc
deleted file mode 100644
index 7d96248..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_longer_wrong_main.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-#define AN 3
-#define BM 2
-#define AMBN 5
-//#define PRINT
-
-#include <time.h>
-#include <fstream>
-#include <cstdio>
-
-/*
-
-<test name='mm_small'>
-
-procedure void mm(
- in float[3][5] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[5][2] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[3][2] C = matrix([*,*],lambda i,j: 0))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- C[i][j] = 0;
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] + B[k][j];
- }
- }
- }
-}
-
-int main(int argc, char** argv) {
- float A[3][5] = {{0,1,2,3,4},{5,6,7,8,9},{10,11,12,13,14}};
- float B[5][2] = {{0,1},{2,3},{4,5},{6,7},{8,9}};
- float C[3][2] = {{0,0},{0,0},{0,0}};
- timespec start_time;
- timespec end_time;
-
- if (argc == 3) {
- std::ifstream is(argv[1], std::ifstream::in | std::ifstream::binary);
- is.read((char*)A, 15*sizeof(float));
- is.read((char*)B, 10*sizeof(float));
- is.close();
- }
-
- clock_gettime(CLOCK_REALTIME, &start_time);
- for(int i = 0; i < 1000000; i++) {
- mm(A,B,C);
- }
- clock_gettime(CLOCK_REALTIME, &end_time);
-
- if (argc == 3) {
- std::ofstream os(argv[2], std::ofstream::out | std::ofstream::binary);
- os.write((char*)C, 6*sizeof(float));
- os.close();
- }
-
- #ifdef PRINT
- std::printf("A:\n");
- for(int i = 0; i < 3; i++) {
- std::printf("[");
- for(int j = 0; j < 5; j++) {
- std::printf("%f,",A[i][j]);
- }
- std::printf("]\n");
- }
- std::printf("B:\n");
- for(int i = 0; i < 5; i++) {
- std::printf("[");
- for(int j = 0; j < 2; j++) {
- std::printf("%f,",B[i][j]);
- }
- std::printf("]\n");
- }
- std::printf("C:\n");
- for(int i = 0; i < 3; i++) {
- std::printf("[");
- for(int j = 0; j < 2; j++) {
- std::printf("%f,",C[i][j]);
- }
- std::printf("]\n");
- }
- #else
- double time_diff = (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec)/1000000000.0;
- std::printf("(%f,)", time_diff);
- #endif
- return 0;
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_main.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_main.cc
deleted file mode 100644
index a03b505..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_main.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-#define AN 3
-#define BM 2
-#define AMBN 5
-//#define PRINT
-
-#include <time.h>
-#include <fstream>
-#include <cstdio>
-
-/*
-
-<test name='mm_small'>
-
-procedure void mm(
- in float[3][5] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[5][2] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[3][2] C = matrix([*,*],lambda i,j: 0))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- C[i][j] = 0;
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
-
-int main(int argc, char** argv) {
- float A[3][5] = {{0,1,2,3,4},{5,6,7,8,9},{10,11,12,13,14}};
- float B[5][2] = {{0,1},{2,3},{4,5},{6,7},{8,9}};
- float C[3][2] = {{0,0},{0,0},{0,0}};
- timespec start_time;
- timespec end_time;
-
- if (argc == 3) {
- std::ifstream is(argv[1], std::ifstream::in | std::ifstream::binary);
- is.read((char*)A, 15*sizeof(float));
- is.read((char*)B, 10*sizeof(float));
- is.close();
- }
-
- clock_gettime(CLOCK_REALTIME, &start_time);
- mm(A,B,C);
- clock_gettime(CLOCK_REALTIME, &end_time);
-
- if (argc == 3) {
- std::ofstream os(argv[2], std::ofstream::out | std::ofstream::binary);
- os.write((char*)C, 6*sizeof(float));
- os.close();
- }
-
- #ifdef PRINT
- std::printf("A:\n");
- for(int i = 0; i < 3; i++) {
- std::printf("[");
- for(int j = 0; j < 5; j++) {
- std::printf("%f,",A[i][j]);
- }
- std::printf("]\n");
- }
- std::printf("B:\n");
- for(int i = 0; i < 5; i++) {
- std::printf("[");
- for(int j = 0; j < 2; j++) {
- std::printf("%f,",B[i][j]);
- }
- std::printf("]\n");
- }
- std::printf("C:\n");
- for(int i = 0; i < 3; i++) {
- std::printf("[");
- for(int j = 0; j < 2; j++) {
- std::printf("%f,",C[i][j]);
- }
- std::printf("]\n");
- }
- #else
- double time_diff = (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec)/1000000000.0;
- std::printf("(%f,)", time_diff);
- #endif
- return 0;
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_out.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_out.cc
deleted file mode 100644
index 6151301..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_out.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <time.h>
-#include <fstream>
-#include <cstdio>
-
-
-#define AN 3
-#define BM 2
-#define AMBN 5
-
-/*
-
-<test name='mm_small'>
-
-procedure void mm(
- in float[3][5] A = matrix([*,*],lambda i,j: random(-8,8)),
- in float[5][2] B = matrix([*,*],lambda i,j: random(-8,8)),
- out float[3][2] C = matrix([*,*],lambda i,j: 0))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
-
-int main(int argc, char** argv) {
- float A[3][5];
- float B[5][2];
- float C[3][2];
- timespec start_time;
- timespec end_time;
-
- std::ifstream datafile_initialize(argv[1]);
- datafile_initialize.read((char*)A, 15*sizeof(float));
- datafile_initialize.read((char*)B, 10*sizeof(float));
- datafile_initialize.read((char*)C, 6*sizeof(float));
- datafile_initialize.close();
-
- clock_gettime(CLOCK_REALTIME, &start_time);
- mm(A,B,C);
- clock_gettime(CLOCK_REALTIME, &end_time);
-
- std::ofstream datafile_out(argv[2]);
- datafile_out.write((char*)C, 6*sizeof(float));
- datafile_out.close();
-
- double time_diff = (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec - start_time.tv_nsec)/1000000000.0;
- std::printf("(%f,)", time_diff);
- return 0;
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_with.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_with.cc
deleted file mode 100644
index 9cb0ae4..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_with.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-#define AN 3
-#define BM 2
-#define AMBN 5
-
-/*
-
-<test name='mm_small'>
-
-with {evendist2:lambda i,j: random(-8,8), zero2:lambda i,j: 0}
-procedure void mm(
- in float[3][5] A = matrix([*,*],evendist2),
- in float[5][2] B = matrix([*,*],evendist2),
- out float[3][2] C = matrix([*,*],zero2))
-
-</test>
-
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_with.testproc b/test-chill/unit-tests/cpp_validate_prog/mm_one_with.testproc
deleted file mode 100644
index 80bc841..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_with.testproc
+++ /dev/null
@@ -1,7 +0,0 @@
-
-with {evendist2:lambda i,j: random(-8,8), zero2:lambda i,j: 0}
-procedure void mm(
- in float[3][5] A = matrix([*,*],evendist2),
- in float[5][2] B = matrix([*,*],evendist2),
- out float[3][2] C = matrix([*,*],zero2))
-
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_one_with_defines.cc b/test-chill/unit-tests/cpp_validate_prog/mm_one_with_defines.cc
deleted file mode 100644
index 77ce673..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_one_with_defines.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-
-/*
-<test name='mm_small' define="{'AN':3, 'BM':2, 'AMBN':5}">
-
-with {evendist2:lambda i,j: random(-8,8), zero2:lambda i,j: 0}
-procedure void mm(
- in float[AN][AMBN] A = matrix([*,*],evendist2),
- in float[AMBN][BM] B = matrix([*,*],evendist2),
- out float[AN][BM] C = matrix([*,*],zero2))
-
-</test>
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- int i;
- int j;
- int k;
- for(i = 0; i < AN; i++) {
- for(j = 0; j < BM; j++) {
- for(k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc b/test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc
deleted file mode 100644
index 49df049..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-<test name=small define="{'AN':2, 'AMBN':5, 'BM':3}">
- procedure void mm(
- in float[AN][AMBN] A = matrix([,],lambda i,j: i*AMBN + j),
- in float[AMBN][BM] B = matrix([,],lambda i,j: i*BM + j),
- out float[AN][BM] C = matrix([,],lambda i,j: 0))
-</test>
-
-<test name=medium define="{'AN':20, 'AMBN':50, 'BM':30}">
- procedure void mm(
- in float[AN][AMBN] A = matrix([,],lambda i,j: i*AMBN + j),
- in float[AMBN][BM] B = matrix([,],lambda i,j: i*BM + j),
- out float[AN][BM] C = matrix([,],lambda i,j: 0))
-</test>
-
-<test name=big define="{'AN':200, 'AMBN':500, 'BM':300}">
- procedure void mm(
- in float[AN][AMBN] A = matrix([,],lambda i,j: i*AMBN + j),
- in float[AMBN][BM] B = matrix([,],lambda i,j: i*BM + j),
- out float[AN][BM] C = matrix([,],lambda i,j: 0))
-</test>
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- for(int i = 0; i < AN; i++) {
- for(int j = 0; j < BM; j++) {
- C[i][j] = 0;
- for(int k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc.data b/test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc.data
deleted file mode 100644
index 82c5ce6..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_three_basic.cc.data
+++ /dev/null
Binary files differ
diff --git a/test-chill/unit-tests/cpp_validate_prog/mm_three_slow.cc b/test-chill/unit-tests/cpp_validate_prog/mm_three_slow.cc
deleted file mode 100644
index dd8c7e7..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/mm_three_slow.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-<test name=small define="{'AN':2, 'AMBN':5, 'BM':3}">
- procedure void mm(
- in float[AN][AMBN] A = matrix([,],lambda i,j: i*AMBN + j),
- in float[AMBN][BM] B = matrix([,],lambda i,j: i*BM + j),
- out float[AN][BM] C = matrix([,],lambda i,j: 0))
-</test>
-
-<test name=medium define="{'AN':20, 'AMBN':50, 'BM':30}">
- procedure void mm(
- in float[AN][AMBN] A = matrix([,],lambda i,j: i*AMBN + j),
- in float[AMBN][BM] B = matrix([,],lambda i,j: i*BM + j),
- out float[AN][BM] C = matrix([,],lambda i,j: 0))
-</test>
-
-<test name=big define="{'AN':200, 'AMBN':500, 'BM':300}">
- procedure void mm(
- in float[AN][AMBN] A = matrix([,],lambda i,j: i*AMBN + j),
- in float[AMBN][BM] B = matrix([,],lambda i,j: i*BM + j),
- out float[AN][BM] C = matrix([,],lambda i,j: 0))
-</test>
-*/
-
-void mm(float A[AN][AMBN], float B[AMBN][BM], float C[AN][BM]) {
- for(int w = 0; w < 100; w++) {
- for(int i = 0; i < AN; i++) {
- for(int j = 0; j < BM; j++) {
- C[i][j] = 0;
- for(int k = 0; k < AMBN; k++) {
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
- }
-}
diff --git a/test-chill/unit-tests/cpp_validate_prog/print_mm_out.py b/test-chill/unit-tests/cpp_validate_prog/print_mm_out.py
deleted file mode 100755
index fefbd2a..0000000
--- a/test-chill/unit-tests/cpp_validate_prog/print_mm_out.py
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-
-import struct
-import numpy as np
-
-with open('mm.out.data','rb') as f:
- data = f.read()
-
-mat = np.array([struct.unpack_from('f',data,n*4) for n in range(len(data)/4)]).reshape((3,2))
-print(mat)