From b4a08d0815342b6238d307864f0823d0f07bb691 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Tue, 26 May 2020 22:04:20 +0200 Subject: k1c -> kvx changes --- test/mppa/sort/.gitignore | 10 +++++----- test/mppa/sort/Makefile | 46 +++++++++++++++++++++++----------------------- test/mppa/sort/README.md | 4 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) (limited to 'test/mppa/sort') diff --git a/test/mppa/sort/.gitignore b/test/mppa/sort/.gitignore index a8d6921c..070b87c4 100644 --- a/test/mppa/sort/.gitignore +++ b/test/mppa/sort/.gitignore @@ -1,9 +1,9 @@ -main-test-ccomp-k1c -main-test-gcc-k1c +main-test-ccomp-kvx +main-test-gcc-kvx main-test-gcc-x86 -merge-test-gcc-k1c +merge-test-gcc-kvx merge-test-gcc-x86 -selection-test-gcc-k1c +selection-test-gcc-kvx selection-test-gcc-x86 -insertion-test-gcc-k1c +insertion-test-gcc-kvx insertion-test-gcc-x86 diff --git a/test/mppa/sort/Makefile b/test/mppa/sort/Makefile index 0ae9d1f6..c4090352 100644 --- a/test/mppa/sort/Makefile +++ b/test/mppa/sort/Makefile @@ -1,11 +1,11 @@ -K1CC ?= k1-cos-gcc +KVXC ?= k1-cos-gcc CC ?= gcc CCOMP ?= ccomp CFLAGS ?= -O2 SIMU ?= k1-mppa TIMEOUT ?= 10s -K1CCPATH=$(shell which $(K1CC)) +KVXCPATH=$(shell which $(KVXC)) CCPATH=$(shell which $(CC)) CCOMPPATH=$(shell which $(CCOMP)) SIMUPATH=$(shell which $(SIMU)) @@ -14,15 +14,15 @@ 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 +ALL= insertion-gcc-x86 insertion-gcc-kvx insertion-ccomp-kvx\ + selection-gcc-x86 selection-gcc-kvx selection-ccomp-kvx\ + merge-gcc-x86 merge-gcc-kvx merge-ccomp-kvx\ + main-gcc-x86 main-gcc-kvx main-ccomp-kvx -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 +CCOMP_OUT= insertion-ccomp-kvx.out selection-ccomp-kvx.out merge-ccomp-kvx.out\ + main-ccomp-kvx.out +GCC_OUT= insertion-gcc-kvx.out selection-gcc-kvx.out merge-gcc-kvx.out\ + main-gcc-kvx.out X86_GCC_OUT= insertion-gcc-x86.out selection-gcc-x86.out merge-gcc-x86.out\ main-gcc-x86.out STUB_OUT= .zero @@ -35,23 +35,23 @@ main-gcc-x86: $(CFILES) $(PRNG) $(CCPATH) %-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 $@ +main-gcc-kvx: $(CFILES) $(PRNG) $(CCPATH) + $(KVXC) $(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 $@ +%-gcc-kvx: %.c $(PRNG) $(KVXCPATH) + $(KVXC) -D__UNIT_TEST_$$(echo $(basename $<) | tr a-z A-Z)__ $(CFLAGS) $(filter-out $(KVXCPATH),$^) -o $@ -main-ccomp-k1c: $(CFILES) $(PRNG) $(CCOMPPATH) +main-ccomp-kvx: $(CFILES) $(PRNG) $(CCOMPPATH) $(CCOMP) $(CFLAGS) $(filter-out $(CCOMPPATH),$^) -o $@ -%-ccomp-k1c: %.c $(PRNG) $(CCOMPPATH) +%-ccomp-kvx: %.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) +%kvx.out: %kvx $(SIMUPATH) ret=0; timeout $(TIMEOUT) $(SIMU) -- $< > $@ || { ret=$$?; }; echo $$ret >> $@ .zero: @@ -68,24 +68,24 @@ test-x86: $(STUB_OUT) $(X86_GCC_OUT) done .PHONY: -test-k1c: $(STUB_OUT) $(GCC_OUT) +test-kvx: $(STUB_OUT) $(GCC_OUT) @for test in $(wordlist 2,100,$^); do\ if ! diff $$test $(STUB_OUT); then\ - >&2 echo "ERROR k1c: $$test failed";\ + >&2 echo "ERROR kvx: $$test failed";\ else\ - echo "GOOD k1c: $$test succeeded";\ + echo "GOOD kvx: $$test succeeded";\ fi;\ done .PHONY: -test: test-x86 test-k1c +test: test-x86 test-kvx .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";\ + >&2 echo "ERROR kvx: $$test failed";\ else\ - echo "GOOD k1c: $$test succeeded";\ + echo "GOOD kvx: $$test succeeded";\ fi;\ done diff --git a/test/mppa/sort/README.md b/test/mppa/sort/README.md index b4c2279b..98ed539d 100644 --- a/test/mppa/sort/README.md +++ b/test/mppa/sort/README.md @@ -11,7 +11,7 @@ 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 + - `prng-test-kvx-x86` : binary from gcc on kvx + - `prng-test-ccomp-x86` : binary from ccomp on kvx - `make test`: tests the return value of the binaries produced by gcc. - `make check`: tests the return value of the binary produced by CompCert. -- cgit From bc1e43ea95b9455cdccee442db77bc5fafd3dcc6 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Tue, 26 May 2020 22:11:32 +0200 Subject: tests for kvx --- test/mppa/sort/.gitignore | 9 ----- test/mppa/sort/Makefile | 91 --------------------------------------------- test/mppa/sort/README.md | 17 --------- test/mppa/sort/insertion.c | 59 ----------------------------- test/mppa/sort/insertion.h | 6 --- test/mppa/sort/main.c | 34 ----------------- test/mppa/sort/merge.c | 92 ---------------------------------------------- test/mppa/sort/merge.h | 7 ---- test/mppa/sort/selection.c | 62 ------------------------------- test/mppa/sort/selection.h | 6 --- test/mppa/sort/test.h | 6 --- 11 files changed, 389 deletions(-) delete mode 100644 test/mppa/sort/.gitignore delete mode 100644 test/mppa/sort/Makefile delete mode 100644 test/mppa/sort/README.md delete mode 100644 test/mppa/sort/insertion.c delete mode 100644 test/mppa/sort/insertion.h delete mode 100644 test/mppa/sort/main.c delete mode 100644 test/mppa/sort/merge.c delete mode 100644 test/mppa/sort/merge.h delete mode 100644 test/mppa/sort/selection.c delete mode 100644 test/mppa/sort/selection.h delete mode 100644 test/mppa/sort/test.h (limited to 'test/mppa/sort') diff --git a/test/mppa/sort/.gitignore b/test/mppa/sort/.gitignore deleted file mode 100644 index 070b87c4..00000000 --- a/test/mppa/sort/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -main-test-ccomp-kvx -main-test-gcc-kvx -main-test-gcc-x86 -merge-test-gcc-kvx -merge-test-gcc-x86 -selection-test-gcc-kvx -selection-test-gcc-x86 -insertion-test-gcc-kvx -insertion-test-gcc-x86 diff --git a/test/mppa/sort/Makefile b/test/mppa/sort/Makefile deleted file mode 100644 index c4090352..00000000 --- a/test/mppa/sort/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -KVXC ?= k1-cos-gcc -CC ?= gcc -CCOMP ?= ccomp -CFLAGS ?= -O2 -SIMU ?= k1-mppa -TIMEOUT ?= 10s - -KVXCPATH=$(shell which $(KVXC)) -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-kvx insertion-ccomp-kvx\ - selection-gcc-x86 selection-gcc-kvx selection-ccomp-kvx\ - merge-gcc-x86 merge-gcc-kvx merge-ccomp-kvx\ - main-gcc-x86 main-gcc-kvx main-ccomp-kvx - -CCOMP_OUT= insertion-ccomp-kvx.out selection-ccomp-kvx.out merge-ccomp-kvx.out\ - main-ccomp-kvx.out -GCC_OUT= insertion-gcc-kvx.out selection-gcc-kvx.out merge-gcc-kvx.out\ - main-gcc-kvx.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-kvx: $(CFILES) $(PRNG) $(CCPATH) - $(KVXC) $(CFLAGS) $(filter-out $(CCPATH),$^) -o $@ - -%-gcc-kvx: %.c $(PRNG) $(KVXCPATH) - $(KVXC) -D__UNIT_TEST_$$(echo $(basename $<) | tr a-z A-Z)__ $(CFLAGS) $(filter-out $(KVXCPATH),$^) -o $@ - -main-ccomp-kvx: $(CFILES) $(PRNG) $(CCOMPPATH) - $(CCOMP) $(CFLAGS) $(filter-out $(CCOMPPATH),$^) -o $@ - -%-ccomp-kvx: %.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 >> $@ - -%kvx.out: %kvx $(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-kvx: $(STUB_OUT) $(GCC_OUT) - @for test in $(wordlist 2,100,$^); do\ - if ! diff $$test $(STUB_OUT); then\ - >&2 echo "ERROR kvx: $$test failed";\ - else\ - echo "GOOD kvx: $$test succeeded";\ - fi;\ - done - -.PHONY: -test: test-x86 test-kvx - -.PHONY: -check: $(STUB_OUT) $(CCOMP_OUT) - @for test in $(wordlist 2,100,$^); do\ - if ! diff $$test $(STUB_OUT); then\ - >&2 echo "ERROR kvx: $$test failed";\ - else\ - echo "GOOD kvx: $$test succeeded";\ - fi;\ - done diff --git a/test/mppa/sort/README.md b/test/mppa/sort/README.md deleted file mode 100644 index 98ed539d..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-kvx-x86` : binary from gcc on kvx - - `prng-test-ccomp-x86` : binary from ccomp on kvx -- `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 -- cgit