diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2020-05-28 18:26:22 +0200 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2020-05-28 18:26:22 +0200 |
commit | 050f408dd2b3f2cf1b8db512edafe2701b7a2dce (patch) | |
tree | 5f962fb6166fd2cd95a239e0d66fee362c1bfb23 /test/mppa/sort/insertion.c | |
parent | d46e96ef6c0287d6892bfc7d2272b7473f5e4979 (diff) | |
parent | 17c564cb99076eb0e2b34eeed4f24a18febe7116 (diff) | |
download | compcert-kvx-050f408dd2b3f2cf1b8db512edafe2701b7a2dce.tar.gz compcert-kvx-050f408dd2b3f2cf1b8db512edafe2701b7a2dce.zip |
Merge branch 'kvx-work' into mppa-RTLpathSE
Adapting the new mppa-RTLpathSE passes into the new Compiler.vexpand
framework
Diffstat (limited to 'test/mppa/sort/insertion.c')
-rw-r--r-- | test/mppa/sort/insertion.c | 59 |
1 files changed, 0 insertions, 59 deletions
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__ |