aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/sort
diff options
context:
space:
mode:
Diffstat (limited to 'test/mppa/sort')
-rw-r--r--test/mppa/sort/.gitignore9
-rw-r--r--test/mppa/sort/Makefile91
-rw-r--r--test/mppa/sort/README.md17
-rw-r--r--test/mppa/sort/insertion.c59
-rw-r--r--test/mppa/sort/insertion.h6
-rw-r--r--test/mppa/sort/main.c34
-rw-r--r--test/mppa/sort/merge.c92
-rw-r--r--test/mppa/sort/merge.h7
-rw-r--r--test/mppa/sort/selection.c62
-rw-r--r--test/mppa/sort/selection.h6
-rw-r--r--test/mppa/sort/test.h6
11 files changed, 0 insertions, 389 deletions
diff --git a/test/mppa/sort/.gitignore b/test/mppa/sort/.gitignore
deleted file mode 100644
index a8d6921c..00000000
--- a/test/mppa/sort/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-main-test-ccomp-k1c
-main-test-gcc-k1c
-main-test-gcc-x86
-merge-test-gcc-k1c
-merge-test-gcc-x86
-selection-test-gcc-k1c
-selection-test-gcc-x86
-insertion-test-gcc-k1c
-insertion-test-gcc-x86
diff --git a/test/mppa/sort/Makefile b/test/mppa/sort/Makefile
deleted file mode 100644
index 0ae9d1f6..00000000
--- a/test/mppa/sort/Makefile
+++ /dev/null
@@ -1,91 +0,0 @@
-K1CC ?= k1-cos-gcc
-CC ?= gcc
-CCOMP ?= ccomp
-CFLAGS ?= -O2
-SIMU ?= k1-mppa
-TIMEOUT ?= 10s
-
-K1CCPATH=$(shell which $(K1CC))
-CCPATH=$(shell which $(CC))
-CCOMPPATH=$(shell which $(CCOMP))
-SIMUPATH=$(shell which $(SIMU))
-
-PRNG=../prng/prng.c
-
-CFILES=insertion.c merge.c selection.c main.c
-
-ALL= insertion-gcc-x86 insertion-gcc-k1c insertion-ccomp-k1c\
- selection-gcc-x86 selection-gcc-k1c selection-ccomp-k1c\
- merge-gcc-x86 merge-gcc-k1c merge-ccomp-k1c\
- main-gcc-x86 main-gcc-k1c main-ccomp-k1c
-
-CCOMP_OUT= insertion-ccomp-k1c.out selection-ccomp-k1c.out merge-ccomp-k1c.out\
- main-ccomp-k1c.out
-GCC_OUT= insertion-gcc-k1c.out selection-gcc-k1c.out merge-gcc-k1c.out\
- main-gcc-k1c.out
-X86_GCC_OUT= insertion-gcc-x86.out selection-gcc-x86.out merge-gcc-x86.out\
- main-gcc-x86.out
-STUB_OUT= .zero
-
-all: $(ALL)
-
-main-gcc-x86: $(CFILES) $(PRNG) $(CCPATH)
- $(CC) $(CFLAGS) $(filter-out $(CCPATH),$^) -o $@
-
-%-gcc-x86: %.c $(PRNG) $(CCPATH)
- $(CC) -D__UNIT_TEST_$$(echo $(basename $<) | tr a-z A-Z)__ $(CFLAGS) $(filter-out $(CCPATH),$^) -o $@
-
-main-gcc-k1c: $(CFILES) $(PRNG) $(CCPATH)
- $(K1CC) $(CFLAGS) $(filter-out $(CCPATH),$^) -o $@
-
-%-gcc-k1c: %.c $(PRNG) $(K1CCPATH)
- $(K1CC) -D__UNIT_TEST_$$(echo $(basename $<) | tr a-z A-Z)__ $(CFLAGS) $(filter-out $(K1CCPATH),$^) -o $@
-
-main-ccomp-k1c: $(CFILES) $(PRNG) $(CCOMPPATH)
- $(CCOMP) $(CFLAGS) $(filter-out $(CCOMPPATH),$^) -o $@
-
-%-ccomp-k1c: %.c $(PRNG) $(CCOMPPATH)
- $(CCOMP) -D__UNIT_TEST_$$(echo $(basename $<) | tr a-z A-Z)__ $(CFLAGS) $(filter-out $(CCOMPPATH),$^) -o $@
-
-.SECONDARY:
-%x86.out: %x86
- ret=0; timeout $(TIMEOUT) ./$< > $@ || { ret=$$?; }; echo $$ret >> $@
-
-%k1c.out: %k1c $(SIMUPATH)
- ret=0; timeout $(TIMEOUT) $(SIMU) -- $< > $@ || { ret=$$?; }; echo $$ret >> $@
-
-.zero:
- @echo "0" > $@
-
-.PHONY:
-test-x86: $(STUB_OUT) $(X86_GCC_OUT)
- @for test in $(wordlist 2,100,$^); do\
- if ! diff $$test $(STUB_OUT); then\
- >&2 echo "ERROR x86: $$test failed";\
- else\
- echo "GOOD x86: $$test succeeded";\
- fi;\
- done
-
-.PHONY:
-test-k1c: $(STUB_OUT) $(GCC_OUT)
- @for test in $(wordlist 2,100,$^); do\
- if ! diff $$test $(STUB_OUT); then\
- >&2 echo "ERROR k1c: $$test failed";\
- else\
- echo "GOOD k1c: $$test succeeded";\
- fi;\
- done
-
-.PHONY:
-test: test-x86 test-k1c
-
-.PHONY:
-check: $(STUB_OUT) $(CCOMP_OUT)
- @for test in $(wordlist 2,100,$^); do\
- if ! diff $$test $(STUB_OUT); then\
- >&2 echo "ERROR k1c: $$test failed";\
- else\
- echo "GOOD k1c: $$test succeeded";\
- fi;\
- done
diff --git a/test/mppa/sort/README.md b/test/mppa/sort/README.md
deleted file mode 100644
index b4c2279b..00000000
--- a/test/mppa/sort/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-PRNG
-====
-
-This is a simple Pseudo Random Number Generator.
-
-`prng.c` contains a simple unitary test that compares the sum of the "bytewise sum"
-of 1000 generated numbers to a hardcoded result, that is the one obtained with
-`gcc -O2` on a x86 processor, and returns 0 if the result is correct.
-
-The following commands can be run inside that folder:
-
-- `make`: produces the unitary test binaries
- - `prng-test-gcc-x86` : binary from gcc on x86
- - `prng-test-k1c-x86` : binary from gcc on k1c
- - `prng-test-ccomp-x86` : binary from ccomp on k1c
-- `make test`: tests the return value of the binaries produced by gcc.
-- `make check`: tests the return value of the binary produced by CompCert.
diff --git a/test/mppa/sort/insertion.c b/test/mppa/sort/insertion.c
deleted file mode 100644
index bca09599..00000000
--- a/test/mppa/sort/insertion.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "../prng/prng.h"
-#include "../prng/types.h"
-
-#ifdef __UNIT_TEST_INSERTION__
-#define SIZE 100
-#else
-#include "test.h"
-#endif
-
-void swap_ins(uint64_t *a, uint64_t *b){
- uint64_t tmp = *a;
- *a = *b;
- *b = tmp;
-}
-
-int insert_sort(uint64_t *res, const uint64_t *T){
- int i, j;
-
- if (SIZE <= 0)
- return -1;
-
- for (i = 0 ; i < SIZE ; i++)
- res[i] = T[i];
-
- for (i = 0 ; i < SIZE-1 ; i++){
- if (res[i] > res[i+1]){
- swap_ins(&res[i], &res[i+1]);
- for (j = i ; j > 0 ; j--)
- if (res[j-1] > res[j])
- swap_ins(&res[j-1], &res[j]);
- }
- }
-
- return 0;
-}
-
-#ifdef __UNIT_TEST_INSERTION__
-int main(void){
- uint64_t T[SIZE];
- uint64_t res[SIZE];
- int i;
- srand(42);
-
- for (i = 0 ; i < SIZE ; i++)
- T[i] = randlong();
-
- /* Sorting the table */
- if (insert_sort(res, T) < 0) return -1;
-
- /* Computing max(T) */
- uint64_t max = T[0];
- for (i = 1 ; i < SIZE ; i++)
- if (T[i] > max)
- max = T[i];
-
- /* We should have: max(T) == res[SIZE] */
- return !(max == res[SIZE-1]);
-}
-#endif // __UNIT_TEST_INSERTION__
diff --git a/test/mppa/sort/insertion.h b/test/mppa/sort/insertion.h
deleted file mode 100644
index 6e37c5fe..00000000
--- a/test/mppa/sort/insertion.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __INSERTION_H__
-#define __INSERTION_H__
-
-int insert_sort(uint64_t *res, const uint64_t *T);
-
-#endif // __INSERTION_H__
diff --git a/test/mppa/sort/main.c b/test/mppa/sort/main.c
deleted file mode 100644
index aef419aa..00000000
--- a/test/mppa/sort/main.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "../prng/prng.h"
-#include "../prng/types.h"
-
-#include "test.h"
-#include "insertion.h"
-#include "selection.h"
-#include "merge.h"
-
-int main(void){
- uint64_t T[SIZE];
- uint64_t res1[SIZE], res2[SIZE], res3[SIZE];
- int i;
- srand(42);
-
- for (i = 0 ; i < SIZE ; i++)
- T[i] = randlong();
-
- /* insertion sort */
- if (insert_sort(res1, T) < 0) return -1;
-
- /* selection sort */
- if (select_sort(res2, T) < 0) return -2;
-
- /* merge sort */
- if (merge_sort(res3, T) < 0) return -3;
-
- /* We should have: res1[i] == res2[i] == res3[i] */
- for (i = 0 ; i < SIZE ; i++){
- if (!(res1[i] == res2[i] && res2[i] == res3[i]))
- return -4;
- }
-
- return 0;
-}
diff --git a/test/mppa/sort/merge.c b/test/mppa/sort/merge.c
deleted file mode 100644
index 99f8ba85..00000000
--- a/test/mppa/sort/merge.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "../prng/prng.h"
-#include "../prng/types.h"
-
-//https://en.wikipedia.org/wiki/Merge_sort
-
-#ifdef __UNIT_TEST_MERGE__
-#define SIZE 100
-#else
-#include "test.h"
-#endif
-
-int min(int a, int b){
- return (a < b)?a:b;
-}
-
-void BottomUpMerge(const uint64_t *A, int iLeft, int iRight, int iEnd, uint64_t *B)
-{
- int i = iLeft, j = iRight, k;
- for (k = iLeft; k < iEnd; k++) {
- if (i < iRight && (j >= iEnd || A[i] <= A[j])) {
- B[k] = A[i];
- i = i + 1;
- } else {
- B[k] = A[j];
- j = j + 1;
- }
- }
-}
-
-void CopyArray(uint64_t *to, const uint64_t *from)
-{
- const int n = SIZE;
- int i;
-
- for(i = 0; i < n; i++)
- to[i] = from[i];
-}
-
-void BottomUpMergeSort(uint64_t *A, uint64_t *B)
-{
- const int n = SIZE;
- int width, i;
-
- for (width = 1; width < n; width = 2 * width)
- {
- for (i = 0; i < n; i = i + 2 * width)
- {
- BottomUpMerge(A, i, min(i+width, n), min(i+2*width, n), B);
- }
- CopyArray(A, B);
- }
-}
-
-int merge_sort(uint64_t *res, const uint64_t *T){
- int i;
-
- if (SIZE <= 0)
- return -1;
-
- uint64_t B[SIZE];
- uint64_t *A = res;
- for (i = 0 ; i < SIZE ; i++)
- A[i] = T[i];
-
- BottomUpMergeSort(A, B);
-
- return 0;
-}
-
-#ifdef __UNIT_TEST_MERGE__
-int main(void){
- uint64_t T[SIZE];
- uint64_t res[SIZE];
- int i;
- srand(42);
-
- for (i = 0 ; i < SIZE ; i++)
- T[i] = randlong();
-
- /* Sorting the table */
- if (merge_sort(res, T) < 0) return -1;
-
- /* Computing max(T) */
- uint64_t max = T[0];
- for (i = 1 ; i < SIZE ; i++)
- if (T[i] > max)
- max = T[i];
-
- /* We should have: max(T) == res[SIZE] */
- return !(max == res[SIZE-1]);
-}
-#endif // __UNIT_TEST_MERGE__
diff --git a/test/mppa/sort/merge.h b/test/mppa/sort/merge.h
deleted file mode 100644
index 439ce64a..00000000
--- a/test/mppa/sort/merge.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __MERGE_H__
-#define __MERGE_H__
-
-int merge_sort(uint64_t *res, const uint64_t *T);
-
-#endif // __MERGE_H__
-
diff --git a/test/mppa/sort/selection.c b/test/mppa/sort/selection.c
deleted file mode 100644
index df4be04f..00000000
--- a/test/mppa/sort/selection.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "../prng/prng.h"
-#include "../prng/types.h"
-
-#ifdef __UNIT_TEST_SELECTION__
-#define SIZE 100
-#else
-#include "test.h"
-#endif
-
-void swap_sel(uint64_t *a, uint64_t *b){
- uint64_t tmp = *a;
- *a = *b;
- *b = tmp;
-}
-
-int select_sort(uint64_t *res, const uint64_t *T){
- int i, j, iMin;
-
- if (SIZE <= 0)
- return -1;
-
- for (i = 0 ; i < SIZE ; i++)
- res[i] = T[i];
-
- for (j = 0 ; j < SIZE ; j++){
- iMin = j;
- for (i = j+1 ; i < SIZE ; i++)
- if (res[i] < res[iMin])
- iMin = i;
-
- if (iMin != j)
- swap_sel (&res[j], &res[iMin]);
- }
-
- return 0;
-}
-
-#ifdef __UNIT_TEST_SELECTION__
-int main(void){
- uint64_t T[SIZE];
- uint64_t res[SIZE];
- uint64_t max;
- int i;
- srand(42);
-
- for (i = 0 ; i < SIZE ; i++)
- T[i] = randlong();
-
- /* Sorting the table */
- if (select_sort(res, T) < 0) return -1;
-
- /* Computing max(T) */
- max = T[0];
- for (i = 1 ; i < SIZE ; i++)
- if (T[i] > max)
- max = T[i];
-
- /* We should have: max(T) == res[SIZE] */
- return !(max == res[SIZE-1]);
-}
-#endif // __UNIT_TEST_SELECTION__
-
diff --git a/test/mppa/sort/selection.h b/test/mppa/sort/selection.h
deleted file mode 100644
index 92a6b461..00000000
--- a/test/mppa/sort/selection.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __SELECTION_H__
-#define __SELECTION_H__
-
-int select_sort(uint64_t *res, const uint64_t *T);
-
-#endif // __SELECTION_H__
diff --git a/test/mppa/sort/test.h b/test/mppa/sort/test.h
deleted file mode 100644
index 4501ee38..00000000
--- a/test/mppa/sort/test.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __TEST_H__
-#define __TEST_H__
-
-#define SIZE 100
-
-#endif