Skip to content

Commit 7bf9480

Browse files
committed
Speed up tests, in particular when OpenMP is disabled
1 parent d8a9d28 commit 7bf9480

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",
@@ -30,6 +34,7 @@ class simdkvsort : public ::testing::Test {
3034
}
3135
std::vector<std::string> arrtype;
3236
std::vector<size_t> arrsize = std::vector<size_t>(1024);
37+
std::vector<size_t> arrsize_long = std::vector<size_t>(1024);
3338
};
3439

3540
TYPED_TEST_SUITE_P(simdkvsort);
@@ -157,7 +162,7 @@ TYPED_TEST_P(simdkvsort, test_kvsort_ascending)
157162
using T2 = typename std::tuple_element<1, decltype(TypeParam())>::type;
158163
for (auto type : this->arrtype) {
159164
bool hasnan = (type == "rand_with_nan") ? true : false;
160-
for (auto size : this->arrsize) {
165+
for (auto size : this->arrsize_long) {
161166
std::vector<T1> key = get_array<T1>(type, size);
162167
std::vector<T2> val = get_array<T2>(type, size);
163168
std::vector<T1> key_bckp = key;
@@ -188,7 +193,7 @@ TYPED_TEST_P(simdkvsort, test_kvsort_descending)
188193
using T2 = typename std::tuple_element<1, decltype(TypeParam())>::type;
189194
for (auto type : this->arrtype) {
190195
bool hasnan = (type == "rand_with_nan") ? true : false;
191-
for (auto size : this->arrsize) {
196+
for (auto size : this->arrsize_long) {
192197
std::vector<T1> key = get_array<T1>(type, size);
193198
std::vector<T2> val = get_array<T2>(type, size);
194199
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",
@@ -27,6 +31,7 @@ class simdsort : public ::testing::Test {
2731
}
2832
std::vector<std::string> arrtype;
2933
std::vector<size_t> arrsize = std::vector<size_t>(1024);
34+
std::vector<size_t> arrsize_long = std::vector<size_t>(1024);
3035
};
3136

3237
TYPED_TEST_SUITE_P(simdsort);
@@ -35,7 +40,7 @@ TYPED_TEST_P(simdsort, test_qsort_ascending)
3540
{
3641
for (auto type : this->arrtype) {
3742
bool hasnan = (type == "rand_with_nan") ? true : false;
38-
for (auto size : this->arrsize) {
43+
for (auto size : this->arrsize_long) {
3944
std::vector<TypeParam> basearr = get_array<TypeParam>(type, size);
4045

4146
// Ascending order
@@ -57,7 +62,7 @@ TYPED_TEST_P(simdsort, test_qsort_descending)
5762
{
5863
for (auto type : this->arrtype) {
5964
bool hasnan = (type == "rand_with_nan") ? true : false;
60-
for (auto size : this->arrsize) {
65+
for (auto size : this->arrsize_long) {
6166
std::vector<TypeParam> basearr = get_array<TypeParam>(type, size);
6267

6368
// Descending order

0 commit comments

Comments
 (0)