[PATCH] D49510: [OpenMP][Clang] Usability improvements for OpenMP offloading

Sergey Dmitriev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 18 14:34:50 PDT 2018


sdmitriev created this revision.
sdmitriev added reviewers: sfantao, ABataev, gtbercea.
Herald added subscribers: cfe-commits, guansong, mgorny.

Current OpenMP offload implementation assumes that offload targets cannot be dropped. If object file is created with some set of offload targets, you cannot drop any offload target at link step. This limitation impacts offload usability.

Offload targets are non discardable because of the compiler generated offload initialization code which is intended to register target binary for each offload target at program startup. Compiler creates the initialization code in each host object. This code depends on the offload targets the object was compiled with which makes host part of the object dependent on the particular targets that were specified at compile time.

This patch implements a different way of registering target binaries at runtime. Compiler no longer creates registration code for the target binaries in the host part of each fat object which makes host object completely independent from particular offload targets. Instead, registration code is moved to a dynamically generated "offload-wrapper" object which besides the registration code also contains offload target binaries packaged as read only data. The wrapper object is created by the clang driver at link step with a help of a new tool called clang-offload-wrapper.

Making host part of the object independent from offload targets relaxes the requirement to use exactly the same set of offload targets for compile and link steps. Offload targets provided at the link steps now need to be a subset of the targets used at compile steps.


Repository:
  rC Clang

https://reviews.llvm.org/D49510

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/ToolChain.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Clang.h
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/clang-offload-wrapper.ll
  test/Driver/openmp-offload-gpu.c
  test/Driver/openmp-offload.c
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_codegen_registration.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_codegen_registration.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_codegen_registration.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_codegen_registration.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_teams_num_teams_codegen.cpp
  test/OpenMP/target_teams_thread_limit_codegen.cpp
  tools/CMakeLists.txt
  tools/clang-offload-wrapper/CMakeLists.txt
  tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49510.156149.patch
Type: text/x-patch
Size: 192449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180718/76d7003b/attachment-0001.bin>


More information about the cfe-commits mailing list