@@ -93,6 +93,7 @@ struct umfIpcTest : umf_test::test,
9393        providerParamsDestroy = provider_params_destroy;
9494        memAccessor = accessor;
9595        openedIpcCacheSize = getOpenedIpcCacheSize ();
96+         numThreads = std::max (10 , (int )utils_get_num_cores ());
9697    }
9798
9899    void  TearDown () override  { test::TearDown (); }
@@ -162,7 +163,8 @@ struct umfIpcTest : umf_test::test,
162163              closeCount (0 ) {}
163164    };
164165
165-     static  constexpr  int  NTHREADS = 10 ;
166+     unsigned  int  numThreads;
167+     static  constexpr  int  CNTHREADS = 10 ;
166168    stats_type stat;
167169    MemoryAccessor *memAccessor = nullptr ;
168170
@@ -188,9 +190,9 @@ struct umfIpcTest : umf_test::test,
188190            ptrs.push_back (ptr);
189191        }
190192
191-         std::array<std::vector<umf_ipc_handle_t >, NTHREADS > ipcHandles;
193+         std::array<std::vector<umf_ipc_handle_t >, CNTHREADS > ipcHandles;
192194
193-         umf_test::syncthreads_barrier syncthreads (NTHREADS );
195+         umf_test::syncthreads_barrier syncthreads (numThreads );
194196
195197        auto  getHandlesFn = [shuffle, &ipcHandles, &ptrs,
196198                             &syncthreads](size_t  tid) {
@@ -212,7 +214,7 @@ struct umfIpcTest : umf_test::test,
212214            }
213215        };
214216
215-         umf_test::parallel_exec (NTHREADS , getHandlesFn);
217+         umf_test::parallel_exec (numThreads , getHandlesFn);
216218
217219        auto  putHandlesFn = [&ipcHandles, &syncthreads](size_t  tid) {
218220            syncthreads ();
@@ -222,7 +224,7 @@ struct umfIpcTest : umf_test::test,
222224            }
223225        };
224226
225-         umf_test::parallel_exec (NTHREADS , putHandlesFn);
227+         umf_test::parallel_exec (numThreads , putHandlesFn);
226228
227229        for  (void  *ptr : ptrs) {
228230            umf_result_t  ret = umfPoolFree (pool.get (), ptr);
@@ -246,7 +248,7 @@ struct umfIpcTest : umf_test::test,
246248            ptrs.push_back (ptr);
247249        }
248250
249-         umf_test::syncthreads_barrier syncthreads (NTHREADS );
251+         umf_test::syncthreads_barrier syncthreads (numThreads );
250252
251253        auto  getPutHandlesFn = [shuffle, &ptrs, &syncthreads](size_t ) {
252254            //  Each thread gets a copy of the pointers to shuffle them
@@ -268,7 +270,7 @@ struct umfIpcTest : umf_test::test,
268270            }
269271        };
270272
271-         umf_test::parallel_exec (NTHREADS , getPutHandlesFn);
273+         umf_test::parallel_exec (numThreads , getPutHandlesFn);
272274
273275        for  (void  *ptr : ptrs) {
274276            umf_result_t  ret = umfPoolFree (pool.get (), ptr);
@@ -302,13 +304,13 @@ struct umfIpcTest : umf_test::test,
302304            ipcHandles.push_back (ipcHandle);
303305        }
304306
305-         std::array<std::vector<void  *>, NTHREADS > openedIpcHandles;
307+         std::array<std::vector<void  *>, CNTHREADS > openedIpcHandles;
306308        umf_ipc_handler_handle_t  ipcHandler = nullptr ;
307309        ret = umfPoolGetIPCHandler (pool.get (), &ipcHandler);
308310        ASSERT_EQ (ret, UMF_RESULT_SUCCESS);
309311        ASSERT_NE (ipcHandler, nullptr );
310312
311-         umf_test::syncthreads_barrier syncthreads (NTHREADS );
313+         umf_test::syncthreads_barrier syncthreads (numThreads );
312314
313315        auto  openHandlesFn = [shuffle, &ipcHandles, &openedIpcHandles,
314316                              &syncthreads, ipcHandler](size_t  tid) {
@@ -329,7 +331,7 @@ struct umfIpcTest : umf_test::test,
329331            }
330332        };
331333
332-         umf_test::parallel_exec (NTHREADS , openHandlesFn);
334+         umf_test::parallel_exec (numThreads , openHandlesFn);
333335
334336        auto  closeHandlesFn = [&openedIpcHandles, &syncthreads](size_t  tid) {
335337            syncthreads ();
@@ -339,7 +341,7 @@ struct umfIpcTest : umf_test::test,
339341            }
340342        };
341343
342-         umf_test::parallel_exec (NTHREADS , closeHandlesFn);
344+         umf_test::parallel_exec (numThreads , closeHandlesFn);
343345
344346        for  (auto  ipcHandle : ipcHandles) {
345347            ret = umfPutIPCHandle (ipcHandle);
@@ -386,7 +388,7 @@ struct umfIpcTest : umf_test::test,
386388        ASSERT_EQ (ret, UMF_RESULT_SUCCESS);
387389        ASSERT_NE (ipcHandler, nullptr );
388390
389-         umf_test::syncthreads_barrier syncthreads (NTHREADS );
391+         umf_test::syncthreads_barrier syncthreads (numThreads );
390392
391393        auto  openCloseHandlesFn = [shuffle, &ipcHandles, &syncthreads,
392394                                   ipcHandler](size_t ) {
@@ -408,7 +410,7 @@ struct umfIpcTest : umf_test::test,
408410            }
409411        };
410412
411-         umf_test::parallel_exec (NTHREADS , openCloseHandlesFn);
413+         umf_test::parallel_exec (numThreads , openCloseHandlesFn);
412414
413415        for  (auto  ipcHandle : ipcHandles) {
414416            ret = umfPutIPCHandle (ipcHandle);
0 commit comments