Skip to content

Commit 2af9e28

Browse files
committed
Set NTHREADS to utils_get_num_cores() at minimum
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 1faa557 commit 2af9e28

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

test/ipcFixtures.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ struct umfIpcTest : umf_test::test,
9393
providerParamsDestroy = provider_params_destroy;
9494
memAccessor = accessor;
9595
openedIpcCacheSize = getOpenedIpcCacheSize();
96+
97+
int ncores = utils_get_num_cores();
98+
NTHREADS = (ncores > 10) ? ncores : 10;
9699
}
97100

98101
void TearDown() override { test::TearDown(); }
@@ -162,7 +165,8 @@ struct umfIpcTest : umf_test::test,
162165
closeCount(0) {}
163166
};
164167

165-
static constexpr int NTHREADS = 10;
168+
unsigned int NTHREADS;
169+
static constexpr int CNTHREADS = 10;
166170
stats_type stat;
167171
MemoryAccessor *memAccessor = nullptr;
168172

@@ -188,7 +192,7 @@ struct umfIpcTest : umf_test::test,
188192
ptrs.push_back(ptr);
189193
}
190194

191-
std::array<std::vector<umf_ipc_handle_t>, NTHREADS> ipcHandles;
195+
std::array<std::vector<umf_ipc_handle_t>, CNTHREADS> ipcHandles;
192196

193197
umf_test::syncthreads_barrier syncthreads(NTHREADS);
194198

@@ -302,7 +306,7 @@ struct umfIpcTest : umf_test::test,
302306
ipcHandles.push_back(ipcHandle);
303307
}
304308

305-
std::array<std::vector<void *>, NTHREADS> openedIpcHandles;
309+
std::array<std::vector<void *>, CNTHREADS> openedIpcHandles;
306310
umf_ipc_handler_handle_t ipcHandler = nullptr;
307311
ret = umfPoolGetIPCHandler(pool.get(), &ipcHandler);
308312
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);

test/poolFixtures.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@ struct umfPoolTest : umf_test::test,
8282
test::SetUp();
8383

8484
pool = poolCreateExtUnique(this->GetParam());
85+
86+
int ncores = utils_get_num_cores();
87+
NTHREADS = (ncores > 5) ? ncores : 5;
8588
}
8689

8790
void TearDown() override { test::TearDown(); }
8891

8992
umf_test::pool_unique_handle_t pool;
9093

91-
static constexpr int NTHREADS = 5;
94+
int NTHREADS;
9295
static constexpr std::array<int, 7> nonAlignedAllocSizes = {5, 7, 23, 55,
9396
80, 119, 247};
9497
};

test/test_base_alloc.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -17,10 +17,12 @@
1717
using umf_test::test;
1818

1919
TEST_F(test, baseAllocMultiThreadedAllocMemset) {
20-
static constexpr int NTHREADS = 10;
2120
static constexpr int ITERATIONS = 1000;
2221
static constexpr int ALLOCATION_SIZE = 16;
2322

23+
int ncores = utils_get_num_cores();
24+
int NTHREADS = (ncores > 10) ? ncores : 10;
25+
2426
auto pool = std::shared_ptr<umf_ba_pool_t>(umf_ba_create(ALLOCATION_SIZE),
2527
umf_ba_destroy);
2628

test/test_base_alloc_linear.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -50,10 +50,12 @@ TEST_F(test, baseAllocLinearPoolContainsPointer) {
5050
}
5151

5252
TEST_F(test, baseAllocLinearMultiThreadedAllocMemset) {
53-
static constexpr int NTHREADS = 10;
5453
static constexpr int ITERATIONS = 1000;
5554
static constexpr int MAX_ALLOCATION_SIZE = 1024;
5655

56+
int ncores = utils_get_num_cores();
57+
int NTHREADS = (ncores > 10) ? ncores : 10;
58+
5759
srand(0);
5860

5961
// The first pool should be bigger than one page,

0 commit comments

Comments
 (0)