[Openmp-commits] [PATCH] D114413: [OpenMPIRBuilder] Implement static-chunked workshare-loop schedules.

Peixin Qiao via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 9 06:59:13 PST 2021


peixin added a comment.

Can you check the following example by applying this patch on fir-dev?

  program main
    integer :: i, N = 10
    real :: x = 0
  
    !$omp do schedule(static, 2)
    do i = 3, N
      x = x + i
    end do
    !$omp end do
  
    print *, x
  end

Test running result:

  $ gfortran test.f90 -fopenmp && ./a.out
     52.0000000    
  $ bbc -fopenmp -emit-fir test.f90
  $ tco test.mlir -o test.ll
  $ clang++ -lFortran_main -lFortranRuntime -lFortranDecimal -lomp -o a.out test.ll
  $ ./a.out
   7.

When you change "schedule(static, 2)" into "schedule(static, 1)", the running result is 3.0.



================
Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1676
+  Value *SrcLoc = getOrCreateIdent(getOrCreateSrcLocStr(DL));
+  Value *ThreadNum = getOrCreateThreadID(SrcLoc);
+  Constant *SchedulingType = ConstantInt::get(
----------------
Can you move "Value *ThreadNum = getOrCreateThreadID(SrcLoc);" after "Builder.CreateStore(One, PStride);" in order that the "kmpc_global_thread_num" call is right before the "kmpc_static_init" call to keep consistence with others?


================
Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1765
+  switch (SchedKind) {
+  case llvm::omp::ScheduleKind ::OMP_SCHEDULE_Default:
+    assert(!ChunkSize && "No chunk size with default schedule (which for clang "
----------------
Please remove the space between "ScheduleKind" and "OMP_SCHEDULE_Default"? Also for the following switch cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114413



More information about the Openmp-commits mailing list