1 #include "cado.h" /* HAVE_* macros ! */
2
3 #include <algorithm>
4 #include <cstdio>
5 #include <cstdlib>
6 #include <string>
7 #include <set>
8 #include <vector>
9
10 #include "params.h"
11
12 #include "test_bblas_base.hpp"
13 #include "test_bblas_level2.hpp"
14 #include "test_bblas_level3.hpp"
15 #include "test_bblas_level4.hpp"
16 #include "test_bblas_level5.hpp"
17 #include "test_bpack.hpp"
18
19 void
print_features()20 print_features() /*{{{*/
21 {
22 printf("## compile-time features\n");
23 #ifdef HAVE_M4RI
24 printf("## HAVE_M4RI\n");
25 #endif /* HAVE_M4RI */
26 #ifdef HAVE_M4RIE
27 printf("## HAVE_M4RIE\n");
28 #endif /* HAVE_M4RIE */
29 #ifdef HAVE_PCLMUL
30 printf("## HAVE_PCLMUL\n");
31 #endif /* HAVE_PCLMUL */
32 #ifdef HAVE_SSE2
33 printf("## HAVE_SSE2\n");
34 #endif /* HAVE_SSE2 */
35 #ifdef HAVE_SSE41
36 printf("## HAVE_SSE41\n");
37 #endif /* HAVE_SSE41 */
38 #ifdef HAVE_AVX2
39 printf("## HAVE_AVX2\n");
40 #endif /* HAVE_AVX2 */
41 #ifdef VALGRIND
42 printf("## VALGRIND\n");
43 #endif /* VALGRIND */
44 printf("## ULONG_BITS=%d\n", ULONG_BITS);
45 } /*}}}*/
46
47 void
declare_usage(cxx_param_list & pl)48 declare_usage(cxx_param_list& pl) /*{{{*/
49 {
50 param_list_decl_usage(pl, "seed", "seed for random data generation");
51 param_list_decl_usage(pl, "n", "n value for some size-dependent tests");
52 param_list_decl_usage(pl, "fast", "do quick tests only\n");
53 param_list_decl_usage(pl, "tests", "list of tests to perform\n");
54 } /*}}}*/
55
56 // coverity[root_function]
57 int
main(int argc,char * argv[])58 main(int argc, char* argv[])
59 {
60 cxx_param_list pl;
61 unsigned int n = 2 * 1000 * 1000;
62 int seed = 0;
63 param_list_configure_switch(pl, "-fast", &test_bblas_base::test_accel);
64 const char* argv0 = argv[0];
65 argc--, argv++;
66 for (; argc;) {
67 if (param_list_update_cmdline(pl, &argc, &argv)) {
68 continue;
69 }
70 fprintf(stderr, "Unhandled parameter %s\n", argv[0]);
71 param_list_print_usage(pl, argv0, stderr);
72 exit(EXIT_FAILURE);
73 }
74
75 param_list_parse_uint(pl, "n", &n);
76 char** tests_list;
77 int ntests;
78 param_list_parse_string_list_alloc(pl, "tests", &tests_list, &ntests, ",");
79 std::vector<std::string> tests;
80 for (int i = 0; i < ntests; i++) {
81 tests.emplace_back(tests_list[i]);
82 free(tests_list[i]);
83 }
84 free(tests_list);
85 tests_list = NULL;
86 if (tests.empty())
87 tests.emplace_back("all");
88
89 if (!seed)
90 seed = time(NULL);
91
92 setbuf(stdout, NULL);
93 setbuf(stderr, NULL);
94
95 print_features();
96
97 printf("# seeding with seed %d\n", seed);
98
99 std::set<std::string> seen;
100
101 test_bblas_level2 A2(n);
102 A2.set_seed(seed);
103 A2(tests, seen);
104
105 test_bblas_level3 A3(n);
106 A3.set_seed(seed);
107 A3(tests, seen);
108
109 test_bblas_level4 A4(n);
110 A4.set_seed(seed);
111 A4(tests, seen);
112
113 test_bblas_level5 A5(n);
114 A5.set_seed(seed);
115 A5(tests, seen);
116
117 test_bpack A6(n);
118 A6.set_seed(seed);
119 A6(tests, seen);
120
121 for (auto const& s : tests) {
122 if (seen.find(s) == seen.end())
123 fprintf(stderr, "## no test for key %s\n", s.c_str());
124 }
125
126 return 0;
127 }
128