-
Notifications
You must be signed in to change notification settings - Fork 796
[Driver][SYCL] Remove object upon failure #18190
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
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /// Verify object removal when the offload compilation fails. | ||
|
|
||
| // REQUIRES: system-linux | ||
|
|
||
| /// Force failure during device compilation | ||
| // RUN: touch %t.o | ||
| // RUN: not %clangxx -fsycl -Xsycl-target-frontend -DCOMPILE_FAIL=1 -c -o %t.o %s | ||
|
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. Can you share why 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. The use of |
||
| // RUN: not ls %t.o | ||
|
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. Could you explain how running the If we try to Can you check for that message instead? 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.
|
||
|
|
||
| // RUN: touch %t.o | ||
| // RUN: not %clangxx --offload-new-driver -fsycl -Xsycl-target-frontend -DCOMPILE_FAIL=1 -c -o %t.o %s | ||
| // RUN: not ls %t.o | ||
|
|
||
| /// Force failure during compilation | ||
| // RUN: touch %t.o | ||
| // RUN: not %clangxx -fsycl -DCOMPILE_FAIL=1 -c -o %t.o %s | ||
| // RUN: not ls %t.o | ||
|
|
||
| // RUN: touch %t.o | ||
| // RUN: not %clangxx --offload-new-driver -fsycl -DCOMPILE_FAIL=1 -c -o %t.o %s | ||
| // RUN: not ls %t.o | ||
|
|
||
| void func(){}; | ||
| #ifdef COMPILE_FAIL | ||
| #error FAIL | ||
| #endif // COMPILE_FAIL | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Can you add some details on why they don't match?
And also give an example Offload JobAction for this scenario?
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.
The generated result files are associated with a specific
JobAction. One example here is with the old offloading model. Here, the output object fromclang++ -fsycl file.cpp -o file.ois generated from theclang-offload-bundlercall. Both the host and device compilations have temporary output files, so theJobActionassociated with the actual fail (if one fails) including the output file do not match.Here, the failing action is a
BackendCompileJobActionbut the file that needs to be removed is from theOffloadBundlingJobActionThere 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.
clang++ -fsycl file.cpp -o file.owill trigger both compilation and linking at the same invocation and will not call clang-offload-bundler.AFAIK, when compilation is separated from linking, the compilation step ends with engaging the offload bundler to generate "fat object" (<host object, device code IR> pair).
Can you clarify this?
If host or device compilation fails, there will be no host object or device object file generated right?
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.
Oh - yeah
-cis needed in that compilation line. Thanks for pointing that out.Yes, that is right, no object will be generated. The issue is an existing object that needs to be cleaned up. During the object compilation, the compiler is responsible for cleaning up the output file upon failure. Since the output file in those instances are temporary - there is no association with the actual output file pointed to with
-o. The driver knows what the final output object file is, so we need to take the steps to clean up upon failure.Uh oh!
There was an error while loading. Please reload this page.
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.
Did I understand it correctly that if the host and device object files have been created, but the
clang-offload-bundlerfails to produce the fat object, we should still proceed with deleting the host and device object files?In this case, the failing JobAction is OffloadBundlingJobAction but the host and device object files were created by a different JobAction.
Is it not possible to pass the JobAction associated with generating the host and device object files instead of not passing any JA at all?
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.
The
JobActionassociated with the host/device object generation is the theBackendCompileJobAction. TheJobActionassociated with theclang-offload-bundlercall is theOffloadBundlingJobAction. Passing in theJobActionassociated with the host and device compilation will not match theJobActionthat is associated with the actual output file we want to remove, so ultimately the file will not be removed when we want it to be.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.
What is the actual output file we want to remove in the case where
OffloadBundlingJobActionfails?My understanding is we want to remove the host and device object files, since those will be the only ones created.
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.
If the
OffloadBundlingJobActionfails, we still want to remove the resulting output file, which is the 'fat' object. This is the named objectfile.ofromclang++ -c -fsycl file.cpp -o file.oThere 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'm confused. You mentioned above that if a compilation fails, there will be no result/output file generated for that failed compilation.
So if
OffloadBundlingJobActionfails, there will be no fat object created right?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.
That's right. But we still need to remove the object if one existed before the compilation. This allows for matching behavior between
clang++ -c a.cpp -o a.oandclang++ -fsycl -c a.cpp -o a.oif compilation fails in any way.