This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Introduce a new worksharing RTL function for distribute
ClosedPublic

Authored by jhuber6 on Sep 24 2021, 10:13 AM.

Details

Summary

This patch adds a new RTL function for worksharing. Currently we use
__kmpc_for_static_init for both the distribute and parallel
portion of the loop clause. This patch replaces the distribute portion
with a new runtime call __kmpc_distribute_static_init. Currently this
will be used exactly the same way, but will make it easier in the future
to fine-tune the distribute and parallel portion of the loop.

Diff Detail

Event Timeline

jhuber6 created this revision.Sep 24 2021, 10:13 AM
jhuber6 requested review of this revision.Sep 24 2021, 10:13 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 24 2021, 10:13 AM
jhuber6 updated this revision to Diff 374965.Sep 24 2021, 2:38 PM

Fixing test update artifacts.

jhuber6 updated this revision to Diff 374971.Sep 24 2021, 3:22 PM

Removing function duplication.

jhuber6 updated this revision to Diff 374972.Sep 24 2021, 3:24 PM

Forgot to remove from header.

jdoerfert accepted this revision.Sep 27 2021, 8:08 AM

LG.

We might be able to revert/simplify this eventually again but for now it makes it much simpler to distinguish the distribute and workshare (=for) via their call site.

clang/lib/CodeGen/CGOpenMPRuntime.cpp
2860

Could we pass the 4 potential functions to createForStaticInitFunction (or similar name) to avoid the duplication? Or just pass a flag.

This revision is now accepted and ready to land.Sep 27 2021, 8:08 AM
This revision was landed with ongoing or failed builds.Sep 27 2021, 8:36 AM
This revision was automatically updated to reflect the committed changes.

hi, we seem to have a link time error after this patch in our buildbot

https://lab.llvm.org/staging/#/builders/182/builds/2023

  • TEST 'libomptarget :: amdgcn-amd-amdhsa :: mapping/private_mapping.c' FAILED ****

Script:

: 'RUN: at line 1'; /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/./bin/clang -fopenmp -fno-experimental-isel -I /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test -I /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget -L /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget -Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src --libomptarget-amdgcn-bc-path=/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget -fopenmp-targets=amdgcn-amd-amdhsa /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test/mapping/private_mapping.c -o /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/mapping/Output/private_mapping.c.tmp && /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/mapping/Output/private_mapping.c.tmp | /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/./bin/FileCheck /work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test/mapping/private_mapping.c

Exit Code: 1

Command Output (stdout):

$ ":" "RUN: at line 1"
$ "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/./bin/clang" "-fopenmp" "-fno-experimental-isel" "-I" "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test" "-I" "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src" "-L" "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget" "-L" "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src" "-Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget" "-Wl,-rpath,/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/runtime/src" "--libomptarget-amdgcn-bc-path=/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget" "-fopenmp-targets=amdgcn-amd-amdhsa" "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.src/openmp/libomptarget/test/mapping/private_mapping.c" "-o" "/work/omp-vega20-0/openmp-offload-amdgpu-project/llvm.build/runtimes/runtimes-bins/openmp/libomptarget/test/amdgcn-amd-amdhsa/mapping/Output/private_mapping.c.tmp"

command stderr:

lld: error: undefined symbol: __kmpc_distribute_static_init_4

referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)

lld: error: undefined symbol: __kmpc_distribute_static_fini

referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__.1)
referenced 1 more times

clang-14: error: amdgcn-link command failed with exit code 1 (use -v to see invocation)
error: command failed with exit status: 1

apologies, that pasted very poorly ...

lld: error: undefined symbol: __kmpc_distribute_static_init_4

referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)

lld: error: undefined symbol: __kmpc_distribute_static_fini

referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__.1)
referenced 1 more times

clang-14: error: amdgcn-link command failed with exit code 1 (use -v to see invocation)

looks like subsequent builders passed. we might have an issue where the runtime was not fully built when the test ran.
please disregard , your patch is fine.

lld: error: undefined symbol: __kmpc_distribute_static_init_4

referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)

lld: error: undefined symbol: __kmpc_distribute_static_fini

referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(omp_outlined)
referenced by /tmp/private_mapping-6f3f07-gfx906-d001f0.o:(__omp_outlined__.1)
referenced 1 more times

clang-14: error: amdgcn-link command failed with exit code 1 (use -v to see invocation)

I'm guessing this has D110430 applied as well?

looks like subsequent builders passed. we might have an issue where the runtime was not fully built when the test ran.
please disregard , your patch is fine.

two dependent patches and you probably picked up only one. Should resolve itself.

[AMD Official Use Only]

Yes, thank you, it was two dependent patches
Builder 1 only saw 1st patch, failed, then 2nd patch arrived, and passed.
Builder 2 picked up both and passed

All good.