Skip to content

Commit fe14564

Browse files
committed
Speed up tests, in particular when OpenMP is disabled
1 parent c5dabb7 commit fe14564

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

tests/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
libtests = []
22

3+
if get_option('use_openmp')
4+
openmpflags = ['-DXSS_USE_OPENMP=true']
5+
endif
6+
37
libtests += static_library('tests_qsort',
48
files('test-qsort.cpp', ),
59
dependencies: gtest_dep,
610
include_directories : [src, lib, utils],
11+
cpp_args : [openmpflags],
712
)
813

914
libtests += static_library('tests_kvsort',
1015
files('test-keyvalue.cpp', ),
1116
dependencies: gtest_dep,
1217
include_directories : [src, lib, utils],
18+
cpp_args : [openmpflags],
1319
)
1420

1521
libtests += static_library('tests_objsort',
1622
files('test-objqsort.cpp', ),
1723
dependencies: gtest_dep,
1824
include_directories : [src, lib, utils],
25+
cpp_args : [openmpflags],
1926
)

tests/test-keyvalue.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ class simdkvsort : public ::testing::Test {
1515
simdkvsort()
1616
{
1717
std::iota(arrsize.begin(), arrsize.end(), 1);
18-
arrsize.push_back(10'000);
19-
arrsize.push_back(100'000);
20-
arrsize.push_back(1'000'000);
18+
std::iota(arrsize_long.begin(), arrsize_long.end(), 1);
19+
#ifdef XSS_USE_OPENMP
20+
// These extended tests are only needed for the OpenMP logic
21+
arrsize_long.push_back(10'000);
22+
arrsize_long.push_back(100'000);
23+
arrsize_long.push_back(1'000'000);
24+
#endif
2125

2226
arrtype = {"random",
2327
"constant",
@@ -32,6 +36,7 @@ class simdkvsort : public ::testing::Test {
3236
}
3337
std::vector<std::string> arrtype;
3438
std::vector<size_t> arrsize = std::vector<size_t>(1024);
39+
std::vector<size_t> arrsize_long = std::vector<size_t>(1024);
3540
};
3641

3742
TYPED_TEST_SUITE_P(simdkvsort);
@@ -168,7 +173,7 @@ TYPED_TEST_P(simdkvsort, test_kvsort_ascending)
168173
using T2 = typename std::tuple_element<1, decltype(TypeParam())>::type;
169174
for (auto type : this->arrtype) {
170175
bool hasnan = is_nan_test(type);
171-
for (auto size : this->arrsize) {
176+
for (auto size : this->arrsize_long) {
172177
std::vector<T1> key = get_array<T1>(type, size);
173178
std::vector<T2> val = get_array<T2>(type, size);
174179
std::vector<T1> key_bckp = key;
@@ -199,7 +204,7 @@ TYPED_TEST_P(simdkvsort, test_kvsort_descending)
199204
using T2 = typename std::tuple_element<1, decltype(TypeParam())>::type;
200205
for (auto type : this->arrtype) {
201206
bool hasnan = is_nan_test(type);
202-
for (auto size : this->arrsize) {
207+
for (auto size : this->arrsize_long) {
203208
std::vector<T1> key = get_array<T1>(type, size);
204209
std::vector<T2> val = get_array<T2>(type, size);
205210
std::vector<T1> key_bckp = key;

tests/test-qsort.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ class simdsort : public ::testing::Test {
1111
simdsort()
1212
{
1313
std::iota(arrsize.begin(), arrsize.end(), 1);
14-
arrsize.push_back(10'000);
15-
arrsize.push_back(100'000);
16-
arrsize.push_back(1'000'000);
14+
std::iota(arrsize_long.begin(), arrsize_long.end(), 1);
15+
#ifdef XSS_USE_OPENMP
16+
// These extended tests are only needed for the OpenMP logic
17+
arrsize_long.push_back(10'000);
18+
arrsize_long.push_back(100'000);
19+
arrsize_long.push_back(1'000'000);
20+
#endif
1721

1822
arrtype = {"random",
1923
"constant",
@@ -28,6 +32,7 @@ class simdsort : public ::testing::Test {
2832
}
2933
std::vector<std::string> arrtype;
3034
std::vector<size_t> arrsize = std::vector<size_t>(1024);
35+
std::vector<size_t> arrsize_long = std::vector<size_t>(1024);
3136
};
3237

3338
TYPED_TEST_SUITE_P(simdsort);
@@ -36,7 +41,7 @@ TYPED_TEST_P(simdsort, test_qsort_ascending)
3641
{
3742
for (auto type : this->arrtype) {
3843
bool hasnan = is_nan_test(type);
39-
for (auto size : this->arrsize) {
44+
for (auto size : this->arrsize_long) {
4045
std::vector<TypeParam> basearr = get_array<TypeParam>(type, size);
4146

4247
// Ascending order
@@ -58,7 +63,7 @@ TYPED_TEST_P(simdsort, test_qsort_descending)
5863
{
5964
for (auto type : this->arrtype) {
6065
bool hasnan = is_nan_test(type);
61-
for (auto size : this->arrsize) {
66+
for (auto size : this->arrsize_long) {
6267
std::vector<TypeParam> basearr = get_array<TypeParam>(type, size);
6368

6469
// Descending order

0 commit comments

Comments
 (0)