-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] sub-devices selected by ONEAPI_DEVICE_SELECTOR as root devices (…
…#7167) All devices available when using ONEAPI_DEVICE_SELECTOR are root devices, even those which are gotten via the sub-device selection choices ( e.g. `ONEAPI_DEVICE_SELECTOR=level_zero:*.*` ). In this PR we are ensuring that those devices pretend to be root devices. Tests for this are here: intel/llvm-test-suite#1346
- Loading branch information
1 parent
5dc011f
commit b21e74e
Showing
6 changed files
with
117 additions
and
12 deletions.
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
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
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,69 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %t.out | ||
|
||
#include <sycl/detail/util.hpp> | ||
#include <sycl/sycl.hpp> | ||
using namespace sycl; | ||
|
||
struct someStruct { | ||
int firstValue; | ||
bool secondValue; | ||
}; | ||
|
||
int main() { | ||
someStruct myStruct; | ||
myStruct.firstValue = 2; | ||
myStruct.secondValue = false; | ||
someStruct moarStruct; | ||
moarStruct.firstValue = 3; | ||
moarStruct.secondValue = false; | ||
someStruct *moarPtr = &moarStruct; | ||
int anotherValue = 4; | ||
|
||
{ // Scope to limit lifetime of TempAssignGuards. | ||
|
||
sycl::detail::TempAssignGuard myTAG_1(myStruct.firstValue, -20); | ||
sycl::detail::TempAssignGuard myTAG_2(myStruct.secondValue, true); | ||
sycl::detail::TempAssignGuard moarTAG_1(moarPtr->firstValue, -30); | ||
sycl::detail::TempAssignGuard moarTAG_2(moarPtr->secondValue, true); | ||
sycl::detail::TempAssignGuard anotherTAG(anotherValue, -40); | ||
|
||
// Ensure values have been temporarily assigned. | ||
assert(myStruct.firstValue == -20); | ||
assert(myStruct.secondValue == true); | ||
assert(moarStruct.firstValue == -30); | ||
assert(moarStruct.secondValue == true); | ||
assert(anotherValue == -40); | ||
} | ||
|
||
// Ensure values have been restored. | ||
assert(myStruct.firstValue == 2); | ||
assert(myStruct.secondValue == false); | ||
assert(moarStruct.firstValue == 3); | ||
assert(moarStruct.secondValue == false); | ||
assert(anotherValue == 4); | ||
|
||
// Test exceptions | ||
int exceptionalValue = 5; | ||
try { | ||
sycl::detail::TempAssignGuard exceptionalTAG(exceptionalValue, -50); | ||
assert(exceptionalValue == -50); | ||
throw 7; // Baby needs a new pair of shoes. | ||
} catch (...) { | ||
assert(exceptionalValue == 5); | ||
} | ||
assert(exceptionalValue == 5); | ||
|
||
// Test premature exit | ||
int prematureValue = 6; | ||
{ | ||
sycl::detail::TempAssignGuard prematureTAG(prematureValue, -60); | ||
assert(prematureValue == -60); | ||
goto dragons; | ||
assert(true == false); | ||
} | ||
dragons: | ||
assert(prematureValue == 6); | ||
|
||
return 0; | ||
} |