This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 131
[SYCL] Tests for Level Zero linker flags #713
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// RUN: %clangxx -fsycl -D__SYCL_INTERNAL_API %s -o %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
// REQUIRES: level_zero | ||
// | ||
//==--- level-zero-link-flags.cpp - Error handling for link flags --==// | ||
// | ||
// The Level Zero backend does not accept any online linker options. | ||
// This test validates that an error is raised if you attempt to pass any. | ||
// | ||
// 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 | ||
// | ||
//===--------------------------------------------------------------===// | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
class MyKernel; | ||
|
||
void test() { | ||
sycl::queue Queue; | ||
sycl::context Context = Queue.get_context(); | ||
|
||
sycl::program Program(Context); | ||
Program.compile_with_kernel_type<MyKernel>(); | ||
|
||
try { | ||
Program.link("-foo"); | ||
assert(false && "Expected error linking program"); | ||
} catch (const sycl::exception &e) { | ||
assert((e.code() == sycl::errc::build) && "Wrong error code"); | ||
} catch (...) { | ||
assert(false && "Expected sycl::exception"); | ||
} | ||
|
||
Queue.submit([&](sycl::handler &CGH) { CGH.single_task<MyKernel>([=] {}); }) | ||
.wait(); | ||
} | ||
|
||
int main() { | ||
test(); | ||
|
||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// RUN: %clangxx -fsycl -Xsycl-target-linker=spir64 -foo %s -o %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
// REQUIRES: level_zero | ||
// | ||
// This test is disabled because the runtime does not currently pass linker | ||
// flags from SYCL_PROGRAM_LINK_OPTIONS when the program calls "sycl::link()". | ||
// This seems like a bug since the runtime passes linker flags from that | ||
// environment variable in other cases when it links device code. | ||
// | ||
// XFAIL: level_zero | ||
// | ||
//==--- level-zero-link-flags.cpp - Error handling for link flags --==// | ||
// | ||
// The Level Zero backend does not accept any online linker options. | ||
// This test validates that an error is raised if you attempt to pass any. | ||
// | ||
// 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 | ||
// | ||
//===--------------------------------------------------------------===// | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
class MyKernel; | ||
|
||
void test() { | ||
sycl::queue Queue; | ||
sycl::context Context = Queue.get_context(); | ||
|
||
auto BundleInput = | ||
sycl::get_kernel_bundle<MyKernel, sycl::bundle_state::input>(Context); | ||
auto BundleObject = sycl::compile(BundleInput); | ||
|
||
try { | ||
sycl::link(BundleObject); | ||
assert(false && "Expected error linking kernel bundle"); | ||
} catch (const sycl::exception &e) { | ||
std::string Msg(e.what()); | ||
assert((e.code() == sycl::errc::build) && "Wrong error code"); | ||
assert(Msg.find("-foo") != std::string::npos); | ||
} catch (...) { | ||
assert(false && "Expected sycl::exception"); | ||
} | ||
|
||
Queue.submit([&](sycl::handler &CGH) { CGH.single_task<MyKernel>([=] {}); }) | ||
.wait(); | ||
} | ||
|
||
int main() { | ||
test(); | ||
|
||
return 0; | ||
} |
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.
@smaslov-intel: Do you agree that the behavior I describe above is a bug? If so, I'll create a bug report.
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 am not sure, the SYCL_PROGRAM_LINK_OPTIONS doc says "String of valid OpenCL link options", so it sounds like OpenCL specific. Also, given that Level-Zero doesn't support any linking options, why would we have an option to pass any?
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 handling for
SYCL_PROGRAM_LINK_OPTIONS
is done in the generic part of the DPC++ runtime. Currently, it only uses this envvar when a module is compiled in order to submit it to a device. In that case, the runtime passes theSYCL_PROGRAM_LINK_OPTIONS
topiProgramLink
regardless of the backend. Therefore, I think the intent of this envvar is that it can be used to pass options to the linker for any backend, not just for OpenCL.The handling for
sycl::link()
is also in the generic part of the library. For some reason, that code does not use options fromSYCL_PROGRAM_LINK_OPTIONS
for any backend.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 am OK making SYCL_PROGRAM_LINK_OPTIONS to be backend-agnostic (need to fix doc then).
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 created a bug report, which also captures the doc issue.
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 got feedback that I should pass the linker options via
-Xsycl-target-linker
instead of usingSYCL_PROGRAM_LINK_OPTIONS
. I modified the test to use that option, but it still fails. Therefore, this test is still disabled. I entered a new bug report to capture this issue.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.
@smaslov-intel said:
I assume you are asking about the "level-zero-link-flags.cpp" test? If so, my comment above is the answer.