-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL][clang-offload-bundler] Add support for BC files in archives. #11034
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
cdce858
Add support for BC files in archives.
b0dd2c0
Add testing of -list, -check-section and -unbundle for archives with …
0b4fa66
Apply clang-format
d3ee76c
Use 'rm -f' to ensure that command will succeed
dd02094
Test BC archive unbundling with multiple files for the same target
4f153c4
Only apply clang-format to this PRs changes
bda9f68
Test unbundling multiple targets
0383d7e
Refactor common code
f752c81
Use llvm-ar not ar
1efe986
Rename FHP to FH
ac55b07
Change memory buffer check to assert
9509557
Use simpler kernel code
9f699dc
Add toplevel comment describing test and simplify test function
686a48f
Fix clang-format issue
9477f20
Avoid piping in back-ticked command to avoid Window's problems
225b30f
clang-offload-bundler tests require linux since b/c the target string…
4eee644
Create Windows version of test by updating target string
3ddec6a
Disable commands that use backticks on Windows. Give Linux tests a l…
8f5b407
Correctly disable RUN commands with a backtick
8f28b72
Update disabling comment for clarity
336e0b3
Correctly disable RUN commands with a backtick
182b3f1
Save test output to a temp file so it is not created twice
439a409
Revise comment and put in correct location
85ad4e7
Use C++ style comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
123 changes: 123 additions & 0 deletions
123
clang/test/Driver/clang-offload-bundler-bc-archive-support-linux.cpp
This file contains hidden or 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,123 @@ | ||
// Target "host-x86_64-unknown-linux-gnu" only works on Linux | ||
// REQUIRES: system-linux | ||
|
||
// Ensure that bundled BC files in archives can work with: | ||
// TEST1: clang-offload-bundler -list | ||
// TEST2: clang-offload-bundler -check-section | ||
// TEST3: clang-offload-bundler -unbundle with single target | ||
// TEST4: clang-offload-bundler -unbundle with multiple targets | ||
// | ||
// In all these tests also ensure functionality with bundled object files still | ||
// works correctly. | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Make bundled object with targets: | ||
// sycl-spir64-unknown-unknown | ||
// host-x86_64-unknown-linux-gnu | ||
// RUN: %clangxx -fsycl -c %s -o %t_bundled.o | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Make three distinct BC files | ||
// RUN: %clangxx -fsycl -fsycl-device-only -DTYPE1 %s -o %t1.bc | ||
// RUN: %clangxx -fsycl -fsycl-device-only -DTYPE2 %s -o %t2.bc | ||
// RUN: %clangxx -fsycl -fsycl-device-only -DTYPE3 %s -o %t3.bc | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Bundle BC files to different targets: | ||
// host-spir64-unknown-unknown | ||
// host-spir64_gen | ||
// host-spir64_x86_64 | ||
// RUN: clang-offload-bundler -type=bc -targets=host-spir64-unknown-unknown -input=%t1.bc -output=%t1_bundled.bc | ||
// RUN: clang-offload-bundler -type=bc -targets=host-spir64_gen -input=%t2.bc -output=%t2_bundled.bc | ||
// RUN: clang-offload-bundler -type=bc -targets=host-spir64_x86_64 -input=%t3.bc -output=%t3_bundled.bc | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Make archive with bundled BC and o files | ||
// RUN: rm -f %t_bundled.a | ||
// RUN: llvm-ar cr %t_bundled.a %t1_bundled.bc %t2_bundled.bc %t3_bundled.bc %t_bundled.o | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// TEST1 | ||
// Check that -list with various archive types can find all targets | ||
// RUN: clang-offload-bundler -list -type=ao -input=%t_bundled.a > %t_list_ao.txt | ||
// RUN: clang-offload-bundler -list -type=aoo -input=%t_bundled.a > %t_list_aoo.txt | ||
// RUN: FileCheck --check-prefixes=CHECK-LIST < %t_list_ao.txt %s | ||
// RUN: FileCheck --check-prefixes=CHECK-LIST < %t_list_aoo.txt %s | ||
|
||
// CHECK-LIST-DAG: sycl-spir64-unknown-unknown | ||
// CHECK-LIST-DAG: host-x86_64-unknown-linux-gnu | ||
// CHECK-LIST-DAG: host-spir64-unknown-unknown | ||
// CHECK-LIST-DAG: host-spir64_gen | ||
// CHECK-LIST-DAG: host-spir64_x86_64 | ||
|
||
// RUN: wc -l %t_list_ao.txt | FileCheck --check-prefixes=CHECK-LIST-LENGTH %s | ||
// RUN: wc -l %t_list_aoo.txt | FileCheck --check-prefixes=CHECK-LIST-LENGTH %s | ||
|
||
// CHECK-LIST-LENGTH: 5 | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// TEST2 | ||
// Test -check-section | ||
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown | ||
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu | ||
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64-unknown-unknown | ||
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_gen | ||
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_x86_64 | ||
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown-a | ||
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu-b | ||
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64-unknown-unknown-c | ||
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_gen-d | ||
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_x86_64-e | ||
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown | ||
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu | ||
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown | ||
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_gen | ||
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64 | ||
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown-a | ||
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu-b | ||
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown-c | ||
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_gen-d | ||
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64-e | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// Unbundle object file to use as a reference result | ||
// RUN: clang-offload-bundler -unbundle -type=o -input=%t_bundled.o -targets=sycl-spir64-unknown-unknown -output=%t_unbundled_A.o | ||
// RUN: clang-offload-bundler -unbundle -type=o -input=%t_bundled.o -targets=host-x86_64-unknown-linux-gnu -output=%t_unbundled_B.o | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// TEST3 | ||
// Test archive unbundling | ||
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown -output=%t_list1.txt | ||
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu -output=%t_list2.txt | ||
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown -output=%t_list3.txt | ||
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64_gen -output=%t_list4.txt | ||
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64 -output=%t_list5.txt | ||
|
||
// RUN: cmp %t_unbundled_A.o `cat %t_list1.txt` | ||
// RUN: cmp %t_unbundled_B.o `cat %t_list2.txt` | ||
// RUN: cmp %t1.bc `cat %t_list3.txt` | ||
// RUN: cmp %t2.bc `cat %t_list4.txt` | ||
// RUN: cmp %t3.bc `cat %t_list5.txt` | ||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// TEST4 | ||
// Test archive unbundling for multiple targets | ||
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown,host-spir64_gen -output=%t_listA.txt -output=%t_listB.txt | ||
|
||
// RUN: cmp %t_unbundled_A.o `cat %t_listA.txt` | ||
// RUN: cmp %t2.bc `cat %t_listB.txt` | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
SYCL_EXTERNAL int foo(int x) { | ||
|
||
#ifdef TYPE1 | ||
return x+13; | ||
#elif TYPE2 | ||
return x+17; | ||
#elif TYPE3 | ||
return x+23; | ||
#else | ||
return x+29; | ||
#endif | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @maksimsab
We are trying to add support here for cases where the archive file will contain .bc file. Previously, we handle only those archive files which have .o files.
Can you please comment if we will need this check for archives containing .bc files?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know at the moment whether we will need it in the future.
This particular piece of code was related to handling of "FPGA" part. Frankly speaking, we don't have a concrete design for them.