[Openmp-commits] [PATCH] D107121: [OpenMP] Fix performance regression reported in bug #51235

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 4 11:44:35 PDT 2021


tianshilei1992 added a comment.

In D107121#2926365 <https://reviews.llvm.org/D107121#2926365>, @protze.joachim wrote:

> The issue you linked is somewhat different.
>
> Using detached tasks, the gtid/depend test is similar to:
>
>   #include <omp.h>
>   #include <thread>
>   #include <unistd.h>
>   #include <assert.h>
>   
>   std::atomic<int> a{0};
>   std::thread t;
>   
>   void async(omp_event_handle_t e){
>     sleep(1);
>     assert(a==2);
>     omp_fulfill_event(e);
>   }
>   
>   int main(int argc, char *argv[]) {
>   #pragma omp parallel master
>     {
>   #pragma omp task depend(out: a)
>       { a = 1; }
>       omp_event_handle_t event;
>   #pragma omp task depend(out: a) detach(event)
>       { a = 2; t = std::thread(async, event);}
>   #pragma omp task depend(out: a)
>       { a = 4; }
>   #pragma omp taskwait
>       assert(a==4);
>     }
>     t.join();
>     return 0;
>   }
>
> Then compile/execute:
>
>   $ clang++ -fopenmp test.cpp
>   $ for i in $(seq 10); do numactl -C 0 env OMP_NUM_THREADS=1 ./a.out & done
>
> For me ~6/10 processes print `Assertion 'a==4' failed.`

Yeah, thanks for that. I updated my previous comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107121/new/

https://reviews.llvm.org/D107121



More information about the Openmp-commits mailing list