-
Notifications
You must be signed in to change notification settings - Fork 787
Reintroduce reverted commit "[clang-offload-bundler] Standardize TargetID field for bundler #9631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd5854c
39ba794
3e5e586
60af2b0
65a7ae1
19be7ab
554e033
184c9e8
02b0933
04a6d5e
d44e71a
b281004
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,21 @@ using namespace clang::driver; | |
using namespace clang; | ||
using namespace llvm::opt; | ||
|
||
// clang-offload-bundler is currently generating a 'standardized' target triple. | ||
// Triple's format - Architecture-Vendor-OS-Environment. | ||
// Bundle sections created by clang-offload-bundler contain the 'standardized' | ||
// triple. This routine transforms the triple specified by user as input to this | ||
// 'standardized' format to facilitate checks. | ||
static std::string standardizedTriple(std::string OrigTriple) { | ||
if (OrigTriple.back() == '-') // Already standardized | ||
return OrigTriple; | ||
llvm::Triple t = llvm::Triple(OrigTriple); | ||
return llvm::Triple(t.getArchName(), t.getVendorName(), t.getOSName(), | ||
t.getEnvironmentName()) | ||
.str() + | ||
"-"; | ||
} | ||
|
||
static std::optional<llvm::Triple> getOffloadTargetTriple(const Driver &D, | ||
const ArgList &Args) { | ||
auto OffloadTargets = Args.getAllArgValues(options::OPT_offload_EQ); | ||
|
@@ -5975,7 +5990,7 @@ class OffloadingActionBuilder final { | |
Arch = C.getDriver().MakeSYCLDeviceTriple("spir64_fpga").str(); | ||
if (std::find(UniqueSections.begin(), UniqueSections.end(), Arch) == | ||
UniqueSections.end()) | ||
UniqueSections.push_back(Arch); | ||
UniqueSections.push_back(standardizedTriple(Arch)); | ||
} | ||
} | ||
|
||
|
@@ -5988,7 +6003,7 @@ class OffloadingActionBuilder final { | |
SectionTriple += "-"; | ||
SectionTriple += SyclTarget.BoundArch; | ||
} | ||
|
||
SectionTriple = standardizedTriple(SectionTriple); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the bundler is doing the 'standardizing' to determine if the bundled sections are there - why do we need to do any standardizing on the caller side? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, we are not calling the bundler. We seem to be reading the sections created by bundler directly. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see - so here we are scanning all of the objects/archives and retrieving the section names. These names could be names that are created with the updated standardized bundler behavior, requiring us to fix up any names for comparisons on the Driver end. |
||
// If any matching section is found, we are good. | ||
if (std::find(UniqueSections.begin(), UniqueSections.end(), | ||
SectionTriple) != UniqueSections.end()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// REQUIRES: x86-registered-target | ||
// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, system-windows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why won't this test work for Windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned offline, this test was never running in the past. There are some issues in the way temporary files are generated that causes failure in windows. It is beyond the scope of this change and should be addressed as a separate issue. Thanks |
||
|
||
// Check working of bundler before and after standardization | ||
// RUN: clang-offload-bundler -type=o -targets=host-x86_64-unknown-linux-gnu,sycl-spir64-unknown-unknown -input=%S/Inputs/bundles/bundle_bef_standardization_of_target_triple.o -output=test-host-x86_64-unknown-linux-gnu.o -output=test-sycl-spir64-unknown-unknown.o -unbundle 2>&1 | FileCheck %s -check-prefix=CHECK-STD-OLD --allow-empty | ||
// CHECK-STD-OLD-NOT: error: Can't find bundles for | ||
// RUN: clang-offload-bundler -type=o -targets=host-x86_64-unknown-linux-gnu,sycl-spir64-unknown-unknown -input=%S/Inputs/bundles/bundle_aft_standardization_of_target_triple.o -output=test-host-x86_64-unknown-linux-gnu.o -output=test-sycl-spir64-unknown-unknown.o -unbundle 2>&1 | FileCheck %s -check-prefix=CHECK-STD-NEW --allow-empty | ||
// CHECK-STD-NEW-NOT: error: Can't find bundles for | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: x86-registered-target | ||
// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}} | ||
|
||
// Generate the file we can bundle. | ||
// RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o | ||
|
||
// | ||
// Generate a couple of files to bundle with. | ||
// | ||
// RUN: echo 'Content of device file 1' > %t.tgt1 | ||
// RUN: echo 'Content of device file 2' > %t.tgt2 | ||
|
||
// | ||
// Check code object compatibility for archive unbundling | ||
// | ||
// Create an object bundle with and without env fields | ||
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.no.env | ||
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple-,hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908 -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle.env | ||
|
||
|
||
// Unbundle bundle.no.env while providing targets with env | ||
// RUN: clang-offload-bundler -unbundle -type=o -targets=hip-amdgcn-amd-amdhsa--gfx906,hip-amdgcn-amd-amdhsa--gfx908 -input=%t.bundle.no.env -output=%t-hip-amdgcn-amd-amdhsa--gfx906.bc -output=%t-hip-amdgcn-amd-amdhsa--gfx908.bc -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLE-NO-ENV | ||
// BUNDLE-NO-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906] | ||
// BUNDLE-NO-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx908] : [Target: hip-amdgcn-amd-amdhsa--gfx908] | ||
|
||
// Unbundle bundle.env while providing targets with no env | ||
// RUN: clang-offload-bundler -unbundle -type=o -targets=hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx908 -input=%t.bundle.env -output=%t-hip-amdgcn-amd-amdhsa-gfx906.bc -output=%t-hip-amdgcn-amd-amdhsa-gfx908.bc -debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s -check-prefix=BUNDLE-ENV | ||
// BUNDLE-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx906] : [Target: hip-amdgcn-amd-amdhsa--gfx906] | ||
// BUNDLE-ENV: Compatible: Exact match: [CodeObject: hip-amdgcn-amd-amdhsa--gfx908] : [Target: hip-amdgcn-amd-amdhsa--gfx908] | ||
|
||
// Some code so that we can create a binary out of this file. | ||
int A = 0; | ||
void test_func(void) { | ||
++A; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.