[Openmp-commits] [openmp] [OpenMP][AIX] lower max threads to reduce collapse testing time (PR #88319)

Xing Xue via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 11 09:46:53 PDT 2024


xingxue-ibm wrote:




> The test should not use more than 128 threads on your system (default value returned by `omp_get_max_threads` is number of available cores). Since we usually run multiple test in parallel, I think it makes sense to modify the test to never use more than half of the available cores:
> 
> ```diff
> -  unsigned num_threads = omp_get_max_threads();
> +  unsigned num_threads = omp_get_max_threads()/2;
>   if (num_threads > MAX_THREADS)
>     num_threads = MAX_THREADS;
>   omp_set_num_threads(num_threads);
> ```
> 
> Furthermore, I suggest to move the `omp_get_thread_num` call out of the loop:
> 
> ```diff
> #pragma omp parallel num_threads(num_threads)
>   {
> +    unsigned gtid = omp_get_thread_num();
> #pragma omp for collapse(3) private(i, j, k)
>     LOOP {
>       unsigned count;
> -      unsigned gtid = omp_get_thread_num();
> ```
Good point, thanks @jprotze! It makes sense not to use more than half of the available logical processors to avoid over-subscribing, noting there are other libomp test cases run running in parallel, including 2 other collapse test cases using `collapse_test.inc`. Changed as per suggestion. Also removed `omp_set_num_threads(num_threads);` because it will make the call to `omp_get_max_threads()` in the next iteration return half of the original value.

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


More information about the Openmp-commits mailing list