[all-commits] [llvm/llvm-project] c5488c: [OpenMP] Properly set static thread limit (w/o ana...

Johannes Doerfert via All-commits all-commits at lists.llvm.org
Wed Aug 23 11:13:04 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5488c8dcc8cd005f4a04aec239b8d22afae51e3
      https://github.com/llvm/llvm-project/commit/c5488c8dcc8cd005f4a04aec239b8d22afae51e3
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2023-08-23 (Wed, 23 Aug 2023)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntime.cpp
    M clang/lib/CodeGen/CGOpenMPRuntime.h
    M clang/test/OpenMP/bug60602.cpp
    M clang/test/OpenMP/distribute_codegen.cpp
    M clang/test/OpenMP/distribute_firstprivate_codegen.cpp
    M clang/test/OpenMP/distribute_lastprivate_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
    M clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
    M clang/test/OpenMP/distribute_private_codegen.cpp
    M clang/test/OpenMP/distribute_simd_codegen.cpp
    M clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
    M clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
    M clang/test/OpenMP/distribute_simd_private_codegen.cpp
    M clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
    M clang/test/OpenMP/nvptx_SPMD_codegen.cpp
    M clang/test/OpenMP/nvptx_lambda_capturing.cpp
    M clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
    M clang/test/OpenMP/reduction_implicit_map.cpp
    M clang/test/OpenMP/target_codegen_global_capture.cpp
    M clang/test/OpenMP/target_map_member_expr_codegen.cpp
    M clang/test/OpenMP/target_ompx_dyn_cgroup_mem_codegen.cpp
    M clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
    M clang/test/OpenMP/target_teams_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_proc_bind_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_private_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_reduction_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_codegen-1.cpp
    M clang/test/OpenMP/target_teams_generic_loop_collapse_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_depend_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_order_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_private_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_reduction_codegen.cpp
    M clang/test/OpenMP/target_teams_generic_loop_uses_allocators_codegen.cpp
    M clang/test/OpenMP/target_teams_map_codegen.cpp
    M clang/test/OpenMP/target_teams_num_teams_codegen.cpp
    M clang/test/OpenMP/teams_codegen.cpp
    M clang/test/OpenMP/teams_distribute_codegen.cpp
    M clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
    M clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
    M clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_lastprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_copyin_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_lastprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_proc_bind_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_reduction_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_collapse_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_private_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_proc_bind_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_reduction_codegen.cpp
    M clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
    M clang/test/OpenMP/teams_distribute_private_codegen.cpp
    M clang/test/OpenMP/teams_distribute_reduction_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_collapse_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_lastprivate_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_private_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_reduction_codegen.cpp
    M clang/test/OpenMP/teams_firstprivate_codegen.cpp
    M clang/test/OpenMP/teams_generic_loop_codegen-1.cpp
    M clang/test/OpenMP/teams_generic_loop_collapse_codegen.cpp
    M clang/test/OpenMP/teams_generic_loop_private_codegen.cpp
    M clang/test/OpenMP/teams_generic_loop_reduction_codegen.cpp
    M clang/test/OpenMP/teams_private_codegen.cpp
    A openmp/libomptarget/test/offloading/thread_limit.c

  Log Message:
  -----------
  [OpenMP] Properly set static thread limit (w/o analysis)

We used to have two separate implementations to derive the number of
threads used in a target region. This lead us to sometimes miss out on
user provided thread bounds (num_threads, or thread_limit) when we
looked for "constant default values". If we might miss out on the
presence of those bounds, we cannot set the thread_limit statically
since the runtime will try to honor user input rather than cap it at the
"preferred default". This patch replaces the secondary implementation
with the primary in a mode that will not emit code but just look for the
presence, and potentially upper bounds, of thread limiting clauses.

The runtime test would not pass without this rewrite as we missed some
clauses, set the static limit on the device to the preferred value, but
then violated that value at runtime.

Fixes: https://github.com/llvm/llvm-project/issues/64845

Differential Revision: https://reviews.llvm.org/D158381


  Commit: 7481b465ae3000589c1360c5c039e73b1d789783
      https://github.com/llvm/llvm-project/commit/7481b465ae3000589c1360c5c039e73b1d789783
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2023-08-23 (Wed, 23 Aug 2023)

  Changed paths:
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    A openmp/libomptarget/test/offloading/default_thread_limit.c

  Log Message:
  -----------
  [OpenMP] Use default grid value for static grid size

If the user did not provide any static clause to override the grid size,
we assume the default grid size as upper bound and use it to improve
code generation through vendor specific attributes.

Fixes: https://github.com/llvm/llvm-project/issues/64816

Differential Revision: https://reviews.llvm.org/D158382


  Commit: f3958ce0086a5774da53a6b793b23aee38f4b3f5
      https://github.com/llvm/llvm-project/commit/f3958ce0086a5774da53a6b793b23aee38f4b3f5
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2023-08-23 (Wed, 23 Aug 2023)

  Changed paths:
    M clang/test/OpenMP/distribute_simd_codegen.cpp
    M clang/test/OpenMP/target_ompx_dyn_cgroup_mem_codegen.cpp
    M clang/test/OpenMP/target_teams_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
    M clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
    M clang/test/OpenMP/teams_distribute_simd_codegen.cpp
    A clang/test/OpenMP/thread_limit_nvptx.c
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

  Log Message:
  -----------
  [OpenMP] Add NVIDIA annotations for static grid thread limit

We already add AMD GPU annotations, the NVIDIA ones are just a little
more convoluted to add/update but otherwise the same.
We see again that the interplay of ompx_attribute and deduced value
needs to be improved, see the TODO.

Differential Revision: https://reviews.llvm.org/D158383


Compare: https://github.com/llvm/llvm-project/compare/e7aed2265e1e...f3958ce0086a


More information about the All-commits mailing list