[Openmp-commits] [openmp] [OpenMP] Use half of available logical processors for collapse tests (PR #88319)

Xing Xue via Openmp-commits openmp-commits at lists.llvm.org
Mon Apr 15 08:41:52 PDT 2024


================
@@ -106,12 +106,14 @@ int test() {
   unsigned scalarCount = 0;
   unsigned uselessThreadsOpenMP = 0;
   unsigned usefulThreadsOpenMP = 0;
-  unsigned chunkSizesOpenmp[MAX_THREADS] = {0};
 
-  unsigned num_threads = omp_get_max_threads();
+  // Use half of the available threads/logical processor.
+  unsigned num_threads = omp_get_max_threads() / 2;
   if (num_threads > MAX_THREADS)
     num_threads = MAX_THREADS;
----------------
xingxue-ibm wrote:

> Because the test reduces `num_threads`, please also add a check ensuring num_threads is not 0. Machines with only one hardware thread (or only one logical processor assigned to the process) will now assign num_threads to 0.
> 
> ```
> if (num_threads == 0)
>   num_threads = 1;
> ```

Good catch, added the check. Thanks!

https://github.com/llvm/llvm-project/pull/88319


More information about the Openmp-commits mailing list