Fix TLS in benchmarks
[riscv-tests.git] / benchmarks / sort / sort.h
1 #include <string.h>
2 #include <stdint.h>
3 #include <stdbool.h>
4
5 #define USE_N_SQUARED_SORT
6
7 #define FAKE_MALLOC_INIT(words, name) \
8 uint32_t heap_##name[words]; \
9 const size_t max_alloc_##name = (words) * sizeof(uint32_t); \
10 size_t cur_pos_##name; \
11 void* fake_malloc_##name( size_t size ) \
12 { \
13 static bool init = false; \
14 if(!init) { \
15 cur_pos_##name = 0; \
16 init = true; \
17 } \
18 if(cur_pos_##name < (words)) { \
19 void *ptr = (void*) &heap_##name[cur_pos_##name]; \
20 cur_pos_##name += size & ~((uint32_t)3) + 1; \
21 return ptr; \
22 } else { \
23 return NULL; \
24 } \
25 }
26
27
28
29 #ifndef _TAV_SORT_H_
30 #define _TAV_SORT_H_
31
32
33 int
34 n_squared_sort (float * value, int * index, int len);
35
36 int
37 radix_sort_tuples (int * value, int * index, int len, int radix_bits);
38
39 int
40 insertion_sort (float * value, int * index, int len);
41
42 int
43 quicksort (float * array, int * index, int len);
44
45 /* This defines the length at quicksort switches to insertion sort */
46 #ifndef MAX_THRESH
47 #define MAX_THRESH 10
48 #endif
49
50 #ifndef RADIX_BITS
51 #define RADIX_BITS (8)
52 #endif
53
54
55 #endif /* _TAV_SORT_H_ */