Browse code

core - test: reorganized the old files in test folder

- moved to subfolders in test/misc
- keep content of the test folder cleaner for travis and unit tests

Daniel-Constantin Mierla authored on 26/11/2015 22:30:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,206 +0,0 @@
1
-/*
2
- * test bit_scan operations from bit_scan.h
3
- *  (both for correctness  and speed)
4
- * 
5
- * Copyright (C) 2007 iptelorg GmbH
6
- *
7
- * Permission to use, copy, modify, and distribute this software for any
8
- * purpose with or without fee is hereby granted, provided that the above
9
- * copyright notice and this permission notice appear in all copies.
10
- *
11
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
- */
19
-/* 
20
- * Example gcc command line:
21
- *  gcc -O9 -Wall -DCC_GCC_LIKE_ASM  -D__CPU_x86 bit_scan_test.c ../bit_scan.c
22
- *      -o bit_scan_test
23
- *
24
- * History:
25
- * --------
26
- *  2007-06-23  created by andrei
27
- */
28
-
29
-
30
-#include <stdlib.h>
31
-#include <stdio.h>
32
-
33
-
34
-#define BIT_SCAN_DEBRUIJN
35
-#define BIT_SCAN_BRANCH
36
-#define BIT_SCAN_SLOW
37
-
38
-#include "../bit_scan.h"
39
-#ifdef NO_PROFILE
40
-#define profile_init(x,y)  do{}while(0)
41
-#define profile_start(x)  do{}while(0)
42
-#define profile_end(x)  do{}while(0)
43
-#define PROFILE_PRINT(x) do{}while(0)
44
-#else
45
-#include "profile.h"
46
-#endif
47
-
48
-#define CHECK(txt, v1, val, f, pd) \
49
-	do{ \
50
-		unsigned long long ret; \
51
-		profile_start(pd); \
52
-		ret=(unsigned long long)f(val); \
53
-		profile_end(pd); \
54
-		if ((unsigned long long)v1!=ret){ \
55
-			fprintf(stderr, "ERROR:" #f ": %s, expected %llx (%llx), got"\
56
-					" %llx\n", \
57
-					(txt), (unsigned long long)v1, \
58
-					(unsigned long long)val, ret); \
59
-			exit(-1); \
60
-		} \
61
-	}while(0)
62
-
63
-#ifndef PROFILE_PRINT
64
-#define PROFILE_PRINT(pd) \
65
-	do{ \
66
-		printf("profile: %s (%ld/%ld) total %llu max %llu average %llu\n", \
67
-				(pd)->name,  (pd)->entries, (pd)->exits, \
68
-				(pd)->total_cycles,  (pd)->max_cycles, \
69
-				(pd)->entries? \
70
-				(pd)->total_cycles/(unsigned long long)(pd)->entries:0ULL ); \
71
-	}while(0)
72
-#endif
73
-
74
-int main(int argc, char** argv)
75
-{
76
-	int r;
77
-	unsigned int v;
78
-	unsigned long long ll;
79
-	int i;
80
-#ifndef NO_PROFILE
81
-	struct profile_data pdf1, pdf2, pdf4, pdf5, pdf6, pdf8;
82
-	struct profile_data pdl1, pdl2, pdl4, pdl5, pdl6, pdl8;
83
-#ifdef HAS_BIT_SCAN_ASM
84
-	struct profile_data pdf3, pdf7, pdl3, pdl7;
85
-#endif
86
-	struct profile_data pdf_32, pdf_64, pdl_32, pdl_64;
87
-	struct profile_data pdf_long, pdl_long;
88
-#endif /* NO_PROFILE */
89
-	
90
-	profile_init(&pdf1, "first_debruijn32");
91
-	profile_init(&pdf2, "first_slow32");
92
-#ifdef HAS_BIT_SCAN_ASM
93
-	profile_init(&pdf3, "first_asm32");
94
-#endif
95
-	profile_init(&pdf4, "first_br32");
96
-	profile_init(&pdf5, "first_debruijn64");
97
-	profile_init(&pdf6, "first_slow64");
98
-#ifdef HAS_BIT_SCAN_ASM
99
-	profile_init(&pdf7, "first_asm64");
100
-#endif
101
-	profile_init(&pdf8, "first_br64");
102
-	profile_init(&pdl1, "last_debruijn32");
103
-	profile_init(&pdl2, "last_slow32");
104
-#ifdef HAS_BIT_SCAN_ASM
105
-	profile_init(&pdl3, "last_asm32");
106
-#endif
107
-	profile_init(&pdl4, "last_br32");
108
-	profile_init(&pdl5, "last_debruijn64");
109
-	profile_init(&pdl6, "last_slow64");
110
-#ifdef HAS_BIT_SCAN_ASM
111
-	profile_init(&pdl7, "last_asm64");
112
-#endif
113
-	profile_init(&pdl8, "last_br64");
114
-	
115
-	profile_init(&pdf_32, "scan_forward32");
116
-	profile_init(&pdf_64, "scan_forward64");
117
-	profile_init(&pdl_32, "scan_reverse32");
118
-	profile_init(&pdl_64, "scan_reverse64");
119
-	profile_init(&pdf_long, "scan_forward_l");
120
-	profile_init(&pdl_long, "scan_reverse_l");
121
-
122
-
123
-	for (i=0; i<100; i++){
124
-	for (r=0; r<32; r++){
125
-		v=(1U<<r);
126
-		CHECK("first debruijn 32bit", r, v, bit_scan_forward_debruijn32, &pdf1);
127
-		CHECK("first slow 32bit", r, v, bit_scan_forward_slow32, &pdf2);
128
-#ifdef HAS_BIT_SCAN_ASM
129
-		CHECK("first asm 32bit", r, v, bit_scan_forward_asm32, &pdf3);
130
-#endif
131
-		CHECK("first br 32bit", r, v, bit_scan_forward_br32, &pdf4);
132
-		CHECK("scan_forward32", r, v, bit_scan_forward32, &pdf_32);
133
-		if (sizeof(long)<=4){
134
-			CHECK("scan_forward_l", r, v, bit_scan_forward, &pdf_long);
135
-		}
136
-		v+=(v-1);
137
-		CHECK("last debruijn 32bit", r, v, bit_scan_reverse_debruijn32, &pdl1);
138
-		CHECK("last slow 32bit", r, v, bit_scan_reverse_slow32, &pdl2);
139
-#ifdef HAS_BIT_SCAN_ASM
140
-		CHECK("last asm 32bit", r, v, bit_scan_reverse_asm32, &pdl3);
141
-#endif
142
-		CHECK("last br 32bit", r, v, bit_scan_reverse_br32, &pdl4);
143
-		CHECK("scan_reverse32", r, v, bit_scan_reverse32, &pdl_32);
144
-		if (sizeof(long)<=4){
145
-			CHECK("scan_reverse_l", r, v, bit_scan_reverse, &pdl_long);
146
-		}
147
-	}
148
-	for (r=0; r<64; r++){
149
-		ll=(1ULL<<r);
150
-		CHECK("first debruijn 64bit", r, ll, bit_scan_forward_debruijn64, &pdf5);
151
-		CHECK("first slow 64bit", r, ll, bit_scan_forward_slow64, &pdf6);
152
-#ifdef HAS_BIT_SCAN_ASM
153
-		CHECK("first asm 64bit", r, ll, bit_scan_forward_asm64, &pdf7);
154
-#endif
155
-		CHECK("first br 64bit", r, ll, bit_scan_forward_br64, &pdf8);
156
-		CHECK("scan_forward64", r, ll, bit_scan_forward64, &pdf_64);
157
-		if (sizeof(long)>4){
158
-			CHECK("scan_forward_l", r, ll, bit_scan_forward, &pdf_long);
159
-		}
160
-		ll+=ll-1;
161
-		CHECK("last debruijn 64bit", r, ll, bit_scan_reverse_debruijn64, &pdl5);
162
-		CHECK("last slow 64bit", r, ll, bit_scan_reverse_slow64, &pdl6);
163
-#ifdef HAS_BIT_SCAN_ASM
164
-		CHECK("last asm 64bit", r, ll, bit_scan_reverse_asm64, &pdl7);
165
-#endif
166
-		CHECK("last br 64bit", r, ll, bit_scan_reverse_br64, &pdl8);
167
-		CHECK("scan_reverse64", r, ll, bit_scan_reverse64, &pdl_64);
168
-		if (sizeof(long)>4){
169
-			CHECK("scan_reverse_l", r, ll, bit_scan_reverse, &pdl_long);
170
-		}
171
-	}
172
-	}
173
-
174
-	PROFILE_PRINT(&pdf1);
175
-	PROFILE_PRINT(&pdf2);
176
-#ifdef HAS_BIT_SCAN_ASM
177
-	PROFILE_PRINT(&pdf3);
178
-#endif
179
-	PROFILE_PRINT(&pdf4);
180
-	PROFILE_PRINT(&pdl1);
181
-	PROFILE_PRINT(&pdl2);
182
-#ifdef HAS_BIT_SCAN_ASM
183
-	PROFILE_PRINT(&pdl3);
184
-#endif
185
-	PROFILE_PRINT(&pdl4);
186
-	PROFILE_PRINT(&pdf5);
187
-	PROFILE_PRINT(&pdf6);
188
-#ifdef HAS_BIT_SCAN_ASM
189
-	PROFILE_PRINT(&pdf7);
190
-#endif
191
-	PROFILE_PRINT(&pdf8);
192
-	PROFILE_PRINT(&pdl5);
193
-	PROFILE_PRINT(&pdl6);
194
-#ifdef HAS_BIT_SCAN_ASM
195
-	PROFILE_PRINT(&pdl7);
196
-#endif
197
-	PROFILE_PRINT(&pdl8);
198
-	
199
-	PROFILE_PRINT(&pdf_32);
200
-	PROFILE_PRINT(&pdf_64);
201
-	PROFILE_PRINT(&pdf_long);
202
-	PROFILE_PRINT(&pdl_32);
203
-	PROFILE_PRINT(&pdl_64);
204
-	PROFILE_PRINT(&pdl_long);
205
-	return 0;
206
-}
Browse code

test: Remove SVN ID's

Olle E. Johansson authored on 07/03/2015 19:43:49
Showing 1 changed files
... ...
@@ -1,5 +1,4 @@
1
-/* $Id$
2
- * 
1
+/*
3 2
  * test bit_scan operations from bit_scan.h
4 3
  *  (both for correctness  and speed)
5 4
  * 
Browse code

- added functions to get the index of the first or last bit set in a 32 bit or 64 bit int: bit_scan_forward32(), bit_scan_forward64(), bit_scan_reverse32(), bit_scan_reverse64(), bit_scan_forward(long) and bit_scan_reverse(long). All of them are very fast, they use asm if available (for now only for __CPU_x86 and __CPU_x86_64), and fall back to a de Bruijn based method or binary search (depending on which method was faster in my measurements on a particular cpu). - added test/profile.h - simple measure the cpu cycles between two calls functions (for now support for x86, x86_64 and sparc64)

Andrei Pelinescu-Onciul authored on 25/06/2007 17:20:34
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,207 @@
1
+/* $Id$
2
+ * 
3
+ * test bit_scan operations from bit_scan.h
4
+ *  (both for correctness  and speed)
5
+ * 
6
+ * Copyright (C) 2007 iptelorg GmbH
7
+ *
8
+ * Permission to use, copy, modify, and distribute this software for any
9
+ * purpose with or without fee is hereby granted, provided that the above
10
+ * copyright notice and this permission notice appear in all copies.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ */
20
+/* 
21
+ * Example gcc command line:
22
+ *  gcc -O9 -Wall -DCC_GCC_LIKE_ASM  -D__CPU_x86 bit_scan_test.c ../bit_scan.c
23
+ *      -o bit_scan_test
24
+ *
25
+ * History:
26
+ * --------
27
+ *  2007-06-23  created by andrei
28
+ */
29
+
30
+
31
+#include <stdlib.h>
32
+#include <stdio.h>
33
+
34
+
35
+#define BIT_SCAN_DEBRUIJN
36
+#define BIT_SCAN_BRANCH
37
+#define BIT_SCAN_SLOW
38
+
39
+#include "../bit_scan.h"
40
+#ifdef NO_PROFILE
41
+#define profile_init(x,y)  do{}while(0)
42
+#define profile_start(x)  do{}while(0)
43
+#define profile_end(x)  do{}while(0)
44
+#define PROFILE_PRINT(x) do{}while(0)
45
+#else
46
+#include "profile.h"
47
+#endif
48
+
49
+#define CHECK(txt, v1, val, f, pd) \
50
+	do{ \
51
+		unsigned long long ret; \
52
+		profile_start(pd); \
53
+		ret=(unsigned long long)f(val); \
54
+		profile_end(pd); \
55
+		if ((unsigned long long)v1!=ret){ \
56
+			fprintf(stderr, "ERROR:" #f ": %s, expected %llx (%llx), got"\
57
+					" %llx\n", \
58
+					(txt), (unsigned long long)v1, \
59
+					(unsigned long long)val, ret); \
60
+			exit(-1); \
61
+		} \
62
+	}while(0)
63
+
64
+#ifndef PROFILE_PRINT
65
+#define PROFILE_PRINT(pd) \
66
+	do{ \
67
+		printf("profile: %s (%ld/%ld) total %llu max %llu average %llu\n", \
68
+				(pd)->name,  (pd)->entries, (pd)->exits, \
69
+				(pd)->total_cycles,  (pd)->max_cycles, \
70
+				(pd)->entries? \
71
+				(pd)->total_cycles/(unsigned long long)(pd)->entries:0ULL ); \
72
+	}while(0)
73
+#endif
74
+
75
+int main(int argc, char** argv)
76
+{
77
+	int r;
78
+	unsigned int v;
79
+	unsigned long long ll;
80
+	int i;
81
+#ifndef NO_PROFILE
82
+	struct profile_data pdf1, pdf2, pdf4, pdf5, pdf6, pdf8;
83
+	struct profile_data pdl1, pdl2, pdl4, pdl5, pdl6, pdl8;
84
+#ifdef HAS_BIT_SCAN_ASM
85
+	struct profile_data pdf3, pdf7, pdl3, pdl7;
86
+#endif
87
+	struct profile_data pdf_32, pdf_64, pdl_32, pdl_64;
88
+	struct profile_data pdf_long, pdl_long;
89
+#endif /* NO_PROFILE */
90
+	
91
+	profile_init(&pdf1, "first_debruijn32");
92
+	profile_init(&pdf2, "first_slow32");
93
+#ifdef HAS_BIT_SCAN_ASM
94
+	profile_init(&pdf3, "first_asm32");
95
+#endif
96
+	profile_init(&pdf4, "first_br32");
97
+	profile_init(&pdf5, "first_debruijn64");
98
+	profile_init(&pdf6, "first_slow64");
99
+#ifdef HAS_BIT_SCAN_ASM
100
+	profile_init(&pdf7, "first_asm64");
101
+#endif
102
+	profile_init(&pdf8, "first_br64");
103
+	profile_init(&pdl1, "last_debruijn32");
104
+	profile_init(&pdl2, "last_slow32");
105
+#ifdef HAS_BIT_SCAN_ASM
106
+	profile_init(&pdl3, "last_asm32");
107
+#endif
108
+	profile_init(&pdl4, "last_br32");
109
+	profile_init(&pdl5, "last_debruijn64");
110
+	profile_init(&pdl6, "last_slow64");
111
+#ifdef HAS_BIT_SCAN_ASM
112
+	profile_init(&pdl7, "last_asm64");
113
+#endif
114
+	profile_init(&pdl8, "last_br64");
115
+	
116
+	profile_init(&pdf_32, "scan_forward32");
117
+	profile_init(&pdf_64, "scan_forward64");
118
+	profile_init(&pdl_32, "scan_reverse32");
119
+	profile_init(&pdl_64, "scan_reverse64");
120
+	profile_init(&pdf_long, "scan_forward_l");
121
+	profile_init(&pdl_long, "scan_reverse_l");
122
+
123
+
124
+	for (i=0; i<100; i++){
125
+	for (r=0; r<32; r++){
126
+		v=(1U<<r);
127
+		CHECK("first debruijn 32bit", r, v, bit_scan_forward_debruijn32, &pdf1);
128
+		CHECK("first slow 32bit", r, v, bit_scan_forward_slow32, &pdf2);
129
+#ifdef HAS_BIT_SCAN_ASM
130
+		CHECK("first asm 32bit", r, v, bit_scan_forward_asm32, &pdf3);
131
+#endif
132
+		CHECK("first br 32bit", r, v, bit_scan_forward_br32, &pdf4);
133
+		CHECK("scan_forward32", r, v, bit_scan_forward32, &pdf_32);
134
+		if (sizeof(long)<=4){
135
+			CHECK("scan_forward_l", r, v, bit_scan_forward, &pdf_long);
136
+		}
137
+		v+=(v-1);
138
+		CHECK("last debruijn 32bit", r, v, bit_scan_reverse_debruijn32, &pdl1);
139
+		CHECK("last slow 32bit", r, v, bit_scan_reverse_slow32, &pdl2);
140
+#ifdef HAS_BIT_SCAN_ASM
141
+		CHECK("last asm 32bit", r, v, bit_scan_reverse_asm32, &pdl3);
142
+#endif
143
+		CHECK("last br 32bit", r, v, bit_scan_reverse_br32, &pdl4);
144
+		CHECK("scan_reverse32", r, v, bit_scan_reverse32, &pdl_32);
145
+		if (sizeof(long)<=4){
146
+			CHECK("scan_reverse_l", r, v, bit_scan_reverse, &pdl_long);
147
+		}
148
+	}
149
+	for (r=0; r<64; r++){
150
+		ll=(1ULL<<r);
151
+		CHECK("first debruijn 64bit", r, ll, bit_scan_forward_debruijn64, &pdf5);
152
+		CHECK("first slow 64bit", r, ll, bit_scan_forward_slow64, &pdf6);
153
+#ifdef HAS_BIT_SCAN_ASM
154
+		CHECK("first asm 64bit", r, ll, bit_scan_forward_asm64, &pdf7);
155
+#endif
156
+		CHECK("first br 64bit", r, ll, bit_scan_forward_br64, &pdf8);
157
+		CHECK("scan_forward64", r, ll, bit_scan_forward64, &pdf_64);
158
+		if (sizeof(long)>4){
159
+			CHECK("scan_forward_l", r, ll, bit_scan_forward, &pdf_long);
160
+		}
161
+		ll+=ll-1;
162
+		CHECK("last debruijn 64bit", r, ll, bit_scan_reverse_debruijn64, &pdl5);
163
+		CHECK("last slow 64bit", r, ll, bit_scan_reverse_slow64, &pdl6);
164
+#ifdef HAS_BIT_SCAN_ASM
165
+		CHECK("last asm 64bit", r, ll, bit_scan_reverse_asm64, &pdl7);
166
+#endif
167
+		CHECK("last br 64bit", r, ll, bit_scan_reverse_br64, &pdl8);
168
+		CHECK("scan_reverse64", r, ll, bit_scan_reverse64, &pdl_64);
169
+		if (sizeof(long)>4){
170
+			CHECK("scan_reverse_l", r, ll, bit_scan_reverse, &pdl_long);
171
+		}
172
+	}
173
+	}
174
+
175
+	PROFILE_PRINT(&pdf1);
176
+	PROFILE_PRINT(&pdf2);
177
+#ifdef HAS_BIT_SCAN_ASM
178
+	PROFILE_PRINT(&pdf3);
179
+#endif
180
+	PROFILE_PRINT(&pdf4);
181
+	PROFILE_PRINT(&pdl1);
182
+	PROFILE_PRINT(&pdl2);
183
+#ifdef HAS_BIT_SCAN_ASM
184
+	PROFILE_PRINT(&pdl3);
185
+#endif
186
+	PROFILE_PRINT(&pdl4);
187
+	PROFILE_PRINT(&pdf5);
188
+	PROFILE_PRINT(&pdf6);
189
+#ifdef HAS_BIT_SCAN_ASM
190
+	PROFILE_PRINT(&pdf7);
191
+#endif
192
+	PROFILE_PRINT(&pdf8);
193
+	PROFILE_PRINT(&pdl5);
194
+	PROFILE_PRINT(&pdl6);
195
+#ifdef HAS_BIT_SCAN_ASM
196
+	PROFILE_PRINT(&pdl7);
197
+#endif
198
+	PROFILE_PRINT(&pdl8);
199
+	
200
+	PROFILE_PRINT(&pdf_32);
201
+	PROFILE_PRINT(&pdf_64);
202
+	PROFILE_PRINT(&pdf_long);
203
+	PROFILE_PRINT(&pdl_32);
204
+	PROFILE_PRINT(&pdl_64);
205
+	PROFILE_PRINT(&pdl_long);
206
+	return 0;
207
+}