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

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 4 11:42:15 PDT 2021


protze.joachim added a comment.

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.`


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