[llvm-branch-commits] [flang] [Flang][OMP] Replace SUM intrinsic call with SUM operations (PR #113082)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Oct 23 05:09:59 PDT 2024


tblah wrote:

>     * I imagine that using a C `omp for` inside of a fortran `omp parallel` should work **so long as they use the same openmp library**. Of course care will need to be taken about privatisation etc but that can probably be handled in the interface of the runtime function.

It might not be practical though. An `omp for` inside of an `omp parallel` looks a bit like

```
static GlobalOpenMPData data;

void per_thread_callback([...]) {
  int lowerbound, upperbound, stride;
  __kmpc_for_static_int_4u(&data, [...], &lowerbound, &upperbound, &stride, [...]);
  for (int i = lowerbound; i < upperbound; i += stride) {
  }
  __kmpc_for_static_fini(&data, [...[);
}

void sourceFunc() {
  __kpmc_fork_call(&data, [...], per_thread_callback, [...]);
}
```

So I guess we would have to pass the OpenMP struct to the runtime function and then do all openmp runtime calls manually inside of the runtime library - not ideal. Even this would be hard to do because the OpenMP struct is only added to the module when we convert to LLVMIR so refering to it here would break the layering of the compiler.

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


More information about the llvm-branch-commits mailing list