forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm][frontend][offloading] Move clang-linker-wrapper/OffloadWrapper…
….* to llvm/Frontend/Offloading (llvm#78057) This patch moves `clang/tools/clang-linker-wrapper/OffloadWrapper.*` to `llvm/Frontend/Offloading` allowing them to be re-utilized by other projects. Additionally, it makes minor modifications to the API to make it more flexible. Concretely: - The `wrap*` methods now have additional arguments `EntryArray`, `Suffix` and `EmitSurfacesAndTextures` to specify some additional options. - The `EntryArray` is now constructed by the caller. This change is needed to enable JIT compilation, as ORC doesn't fully support `__start_` and `__stop_` symbols. Thus, to JIT the code, the `EntryArray` has to be constructed explicitly in the IR. - The `Suffix` field is used when emitting the descriptor, registration methods, etc, to make them more readable. It is empty by default. - The `EmitSurfacesAndTextures` field controls whether to emit surface and texture registration code, as those functions were removed from `CUDART` in CUDA 12. It is true by default. - The function `getOffloadingEntryInitializer` was added to help create the `EntryArray`, as it returns the constant initializer and not a global variable.
- Loading branch information
1 parent
487f7d0
commit 31c4ec4
Showing
9 changed files
with
162 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===- OffloadWrapper.h --r-------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H | ||
#define LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H | ||
|
||
#include "llvm/ADT/ArrayRef.h" | ||
#include "llvm/IR/Module.h" | ||
|
||
namespace llvm { | ||
namespace offloading { | ||
using EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *>; | ||
/// Wraps the input device images into the module \p M as global symbols and | ||
/// registers the images with the OpenMP Offloading runtime libomptarget. | ||
/// \param EntryArray Optional pair pointing to the `__start` and `__stop` | ||
/// symbols holding the `__tgt_offload_entry` array. | ||
/// \param Suffix An optional suffix appended to the emitted symbols. | ||
llvm::Error wrapOpenMPBinaries(llvm::Module &M, | ||
llvm::ArrayRef<llvm::ArrayRef<char>> Images, | ||
EntryArrayTy EntryArray, | ||
llvm::StringRef Suffix = ""); | ||
|
||
/// Wraps the input fatbinary image into the module \p M as global symbols and | ||
/// registers the images with the CUDA runtime. | ||
/// \param EntryArray Optional pair pointing to the `__start` and `__stop` | ||
/// symbols holding the `__tgt_offload_entry` array. | ||
/// \param Suffix An optional suffix appended to the emitted symbols. | ||
/// \param EmitSurfacesAndTextures Whether to emit surface and textures | ||
/// registration code. It defaults to false. | ||
llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images, | ||
EntryArrayTy EntryArray, llvm::StringRef Suffix = "", | ||
bool EmitSurfacesAndTextures = true); | ||
|
||
/// Wraps the input bundled image into the module \p M as global symbols and | ||
/// registers the images with the HIP runtime. | ||
/// \param EntryArray Optional pair pointing to the `__start` and `__stop` | ||
/// symbols holding the `__tgt_offload_entry` array. | ||
/// \param Suffix An optional suffix appended to the emitted symbols. | ||
/// \param EmitSurfacesAndTextures Whether to emit surface and textures | ||
/// registration code. It defaults to false. | ||
llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images, | ||
EntryArrayTy EntryArray, llvm::StringRef Suffix = "", | ||
bool EmitSurfacesAndTextures = true); | ||
} // namespace offloading | ||
} // namespace llvm | ||
|
||
#endif // LLVM_FRONTEND_OFFLOADING_OFFLOADWRAPPER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.