Skip to content

Commit 64228dc

Browse files
committed
remove containerization
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 0557f89 commit 64228dc

File tree

3 files changed

+4
-99
lines changed

3 files changed

+4
-99
lines changed

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,11 @@ wrapDeviceImages(ArrayRef<std::unique_ptr<MemoryBuffer>> Buffers,
736736
}
737737

738738
Expected<SmallVector<std::unique_ptr<MemoryBuffer>>>
739-
bundleOpenMP(SmallVectorImpl<OffloadingImage> &Images) {
739+
bundleOpenMP(ArrayRef<OffloadingImage> Images) {
740740
SmallVector<std::unique_ptr<MemoryBuffer>> Buffers;
741-
for (OffloadingImage &Image : Images) {
742-
llvm::Triple Triple(Image.StringData.lookup("triple"));
743-
if (Triple.isSPIRV() && Triple.getVendor() == llvm::Triple::Intel)
744-
offloading::intel::containerizeOpenMPSPIRVImage(Image);
741+
for (const OffloadingImage &Image : Images)
745742
Buffers.emplace_back(
746743
MemoryBuffer::getMemBufferCopy(OffloadBinary::write(Image)));
747-
}
748744

749745
return std::move(Buffers);
750746
}
@@ -798,8 +794,8 @@ bundleHIP(ArrayRef<OffloadingImage> Images, const ArgList &Args) {
798794
/// Transforms the input \p Images into the binary format the runtime expects
799795
/// for the given \p Kind.
800796
Expected<SmallVector<std::unique_ptr<MemoryBuffer>>>
801-
bundleLinkedOutput(SmallVectorImpl<OffloadingImage> &Images,
802-
const ArgList &Args, OffloadKind Kind) {
797+
bundleLinkedOutput(ArrayRef<OffloadingImage> Images, const ArgList &Args,
798+
OffloadKind Kind) {
803799
llvm::TimeTraceScope TimeScope("Bundle linked output");
804800
switch (Kind) {
805801
case OFK_OpenMP:

llvm/include/llvm/Frontend/Offloading/Utility.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ Error getAMDGPUMetaDataFromImage(MemoryBufferRef MemBuffer,
133133
StringMap<AMDGPUKernelMetaData> &KernelInfoMap,
134134
uint16_t &ELFABIVersion);
135135
} // namespace amdgpu
136-
namespace intel {
137-
/// Containerizes an offloading image into the ELF binary format expected by
138-
/// the Intel runtime offload plugin.
139-
void containerizeOpenMPSPIRVImage(object::OffloadBinary::OffloadingImage &Img);
140-
} // namespace intel
141136
} // namespace offloading
142137
} // namespace llvm
143138

llvm/lib/Frontend/Offloading/Utility.cpp

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include "llvm/IR/GlobalVariable.h"
1616
#include "llvm/IR/Value.h"
1717
#include "llvm/Object/ELFObjectFile.h"
18-
#include "llvm/ObjectYAML/ELFYAML.h"
19-
#include "llvm/ObjectYAML/yaml2obj.h"
2018
#include "llvm/Support/MemoryBufferRef.h"
2119
#include "llvm/Transforms/Utils/ModuleUtils.h"
2220

@@ -367,87 +365,3 @@ Error llvm::offloading::amdgpu::getAMDGPUMetaDataFromImage(
367365
}
368366
return Error::success();
369367
}
370-
371-
void offloading::intel::containerizeOpenMPSPIRVImage(
372-
object::OffloadBinary::OffloadingImage &Img) {
373-
constexpr char INTEL_ONEOMP_OFFLOAD_VERSION[] = "1.0";
374-
constexpr int NT_INTEL_ONEOMP_OFFLOAD_VERSION = 1;
375-
constexpr int NT_INTEL_ONEOMP_OFFLOAD_IMAGE_COUNT = 2;
376-
constexpr int NT_INTEL_ONEOMP_OFFLOAD_IMAGE_AUX = 3;
377-
llvm::Triple Triple(Img.StringData.lookup("triple"));
378-
assert((Triple.isSPIRV() && Triple.getVendor() == llvm::Triple::Intel) &&
379-
"Unexpected triple");
380-
381-
// Start creating notes for the ELF container.
382-
std::vector<ELFYAML::NoteEntry> Notes;
383-
std::string Version = toHex(INTEL_ONEOMP_OFFLOAD_VERSION);
384-
Notes.emplace_back(ELFYAML::NoteEntry{"INTELONEOMPOFFLOAD",
385-
yaml::BinaryRef(Version),
386-
NT_INTEL_ONEOMP_OFFLOAD_VERSION});
387-
388-
// The AuxInfo string will hold auxiliary information for the image.
389-
// ELFYAML::NoteEntry structures will hold references to the
390-
// string, so we have to make sure the string is valid.
391-
std::string AuxInfo;
392-
393-
// TODO: Pass compile/link opts
394-
StringRef CompileOpts = "";
395-
StringRef LinkOpts = "";
396-
397-
unsigned ImageFmt = 1; // SPIR-V format
398-
399-
AuxInfo = toHex((Twine(0) + Twine('\0') + Twine(ImageFmt) + Twine('\0') +
400-
CompileOpts + Twine('\0') + LinkOpts)
401-
.str());
402-
Notes.emplace_back(ELFYAML::NoteEntry{"INTELONEOMPOFFLOAD",
403-
yaml::BinaryRef(AuxInfo),
404-
NT_INTEL_ONEOMP_OFFLOAD_IMAGE_AUX});
405-
406-
std::string ImgCount = toHex(Twine(1).str()); // always one image per ELF
407-
Notes.emplace_back(ELFYAML::NoteEntry{"INTELONEOMPOFFLOAD",
408-
yaml::BinaryRef(ImgCount),
409-
NT_INTEL_ONEOMP_OFFLOAD_IMAGE_COUNT});
410-
411-
std::string YamlFile;
412-
llvm::raw_string_ostream YamlFileStream(YamlFile);
413-
414-
// Write YAML template file.
415-
{
416-
// We use 64-bit little-endian ELF currently.
417-
ELFYAML::FileHeader Header{};
418-
Header.Class = ELF::ELFCLASS64;
419-
Header.Data = ELF::ELFDATA2LSB;
420-
Header.Type = ELF::ET_DYN;
421-
// Use an existing Intel machine type as there is not one specifically for
422-
// Intel GPUs.
423-
Header.Machine = ELF::EM_IA_64;
424-
425-
// Create a section with notes.
426-
ELFYAML::NoteSection Section{};
427-
Section.Type = ELF::SHT_NOTE;
428-
Section.AddressAlign = 0;
429-
Section.Name = ".note.inteloneompoffload";
430-
Section.Notes.emplace(std::move(Notes));
431-
432-
ELFYAML::Object Object{};
433-
Object.Header = Header;
434-
Object.Chunks.push_back(
435-
std::make_unique<ELFYAML::NoteSection>(std::move(Section)));
436-
437-
// Create the section that will hold the image
438-
ELFYAML::RawContentSection ImageSection{};
439-
ImageSection.Type = ELF::SHT_PROGBITS;
440-
ImageSection.AddressAlign = 0;
441-
std::string Name = "__openmp_offload_spirv_0";
442-
ImageSection.Name = Name;
443-
ImageSection.Content =
444-
llvm::yaml::BinaryRef(arrayRefFromStringRef(Img.Image->getBuffer()));
445-
Object.Chunks.push_back(
446-
std::make_unique<ELFYAML::RawContentSection>(std::move(ImageSection)));
447-
448-
llvm::yaml::yaml2elf(
449-
Object, YamlFileStream,
450-
[](const Twine &Msg) { llvm::report_fatal_error(Msg); }, UINT64_MAX);
451-
}
452-
Img.Image = MemoryBuffer::getMemBufferCopy(YamlFile);
453-
}

0 commit comments

Comments
 (0)