-
Notifications
You must be signed in to change notification settings - Fork 810
[SYCL] Fix weak_object and owner_less for device objects #8740
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
steffenlarsen
merged 5 commits into
intel:sycl
from
steffenlarsen:steffen/fix_weak_obj_for_devices
Mar 31, 2023
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ec2ffb
[SYCL] Fix weak_object and owner_less for device objects
a156905
Merge remote-tracking branch 'intel/sycl' into steffen/fix_weak_obj_f…
af53037
Move E2E tests back
a7bb994
Merge remote-tracking branch 'intel/sycl' into steffen/fix_weak_obj_f…
a7439a2
Use BE_RUN_PLACEHOLDER
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
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
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
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
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,30 @@ | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // This test checks the behavior of the copy ctor and assignment operator for | ||
| // `weak_object`. | ||
|
|
||
| #include "weak_object_utils.hpp" | ||
|
|
||
| template <typename SyclObjT> struct WeakObjectCheckCopy { | ||
| void operator()(SyclObjT Obj) { | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj{Obj}; | ||
|
|
||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObjCopyCtor{WeakObj}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObjCopyAssign = WeakObj; | ||
|
|
||
| assert(!WeakObjCopyCtor.expired()); | ||
| assert(!WeakObjCopyAssign.expired()); | ||
|
|
||
| assert(WeakObjCopyCtor.lock() == Obj); | ||
| assert(WeakObjCopyAssign.lock() == Obj); | ||
| } | ||
| }; | ||
|
|
||
| int main() { | ||
| sycl::queue Q; | ||
| runTest<WeakObjectCheckCopy>(Q); | ||
| return 0; | ||
| } | ||
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,24 @@ | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // This test checks the behavior of `expired()` for `weak_object`. | ||
|
|
||
| #include "weak_object_utils.hpp" | ||
|
|
||
| template <typename SyclObjT> struct WeakObjectCheckExpired { | ||
| void operator()(SyclObjT Obj) { | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj{Obj}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> NullWeakObj; | ||
|
|
||
| assert(!WeakObj.expired()); | ||
| assert(NullWeakObj.expired()); | ||
| } | ||
| }; | ||
|
|
||
| int main() { | ||
| sycl::queue Q; | ||
| runTest<WeakObjectCheckExpired>(Q); | ||
| return 0; | ||
| } |
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,32 @@ | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // This test checks the behavior of `lock()` for `weak_object`. | ||
|
|
||
| #include "weak_object_utils.hpp" | ||
|
|
||
| template <typename SyclObjT> struct WeakObjectCheckLock { | ||
| void operator()(SyclObjT Obj) { | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj{Obj}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> NullWeakObj; | ||
|
|
||
| SyclObjT LObj = WeakObj.lock(); | ||
| assert(LObj == Obj); | ||
|
|
||
| try { | ||
| SyclObjT LNull = NullWeakObj.lock(); | ||
| assert(false && "Locking empty weak object did not throw."); | ||
| } catch (sycl::exception &E) { | ||
| assert(E.code() == sycl::make_error_code(sycl::errc::invalid) && | ||
| "Unexpected thrown error code."); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| int main() { | ||
| sycl::queue Q; | ||
| runTest<WeakObjectCheckLock>(Q); | ||
| return 0; | ||
| } |
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,33 @@ | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // This test checks the behavior of the copy ctor and assignment operator for | ||
| // `weak_object`. | ||
|
|
||
| #include "weak_object_utils.hpp" | ||
|
|
||
| template <typename SyclObjT> struct WeakObjectCheckMove { | ||
| void operator()(SyclObjT Obj) { | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj1{Obj}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj2{Obj}; | ||
|
|
||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObjMoveCtor{ | ||
| std::move(WeakObj1)}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObjMoveAssign = | ||
| std::move(WeakObj2); | ||
|
|
||
| assert(!WeakObjMoveCtor.expired()); | ||
| assert(!WeakObjMoveAssign.expired()); | ||
|
|
||
| assert(WeakObjMoveCtor.lock() == Obj); | ||
| assert(WeakObjMoveAssign.lock() == Obj); | ||
| } | ||
| }; | ||
|
|
||
| int main() { | ||
| sycl::queue Q; | ||
| runTest<WeakObjectCheckMove>(Q); | ||
| return 0; | ||
| } |
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,54 @@ | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // This test checks the behavior of owner_before semantics for `weak_object`. | ||
|
|
||
| #include "weak_object_utils.hpp" | ||
|
|
||
| template <typename SyclObjT> struct WeakObjectCheckOwnerBefore { | ||
| void operator()(SyclObjT Obj) { | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj{Obj}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> NullWeakObj; | ||
|
|
||
| assert((WeakObj.owner_before(NullWeakObj) && | ||
| !NullWeakObj.owner_before(WeakObj)) || | ||
| (NullWeakObj.owner_before(WeakObj) && | ||
| !WeakObj.owner_before(NullWeakObj))); | ||
|
|
||
| assert(!WeakObj.owner_before(Obj)); | ||
| assert(!Obj.ext_oneapi_owner_before(WeakObj)); | ||
|
|
||
| assert(!Obj.ext_oneapi_owner_before(Obj)); | ||
| } | ||
| }; | ||
|
|
||
| template <typename SyclObjT> struct WeakObjectCheckOwnerBeforeMulti { | ||
| void operator()(SyclObjT Obj1, SyclObjT Obj2) { | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj1{Obj1}; | ||
| sycl::ext::oneapi::weak_object<SyclObjT> WeakObj2{Obj2}; | ||
|
|
||
| assert( | ||
| (WeakObj1.owner_before(WeakObj2) && !WeakObj2.owner_before(WeakObj1)) || | ||
| (WeakObj2.owner_before(WeakObj1) && !WeakObj1.owner_before(WeakObj2))); | ||
|
|
||
| assert(!WeakObj1.owner_before(Obj1)); | ||
| assert(!Obj1.ext_oneapi_owner_before(WeakObj1)); | ||
|
|
||
| assert(!WeakObj2.owner_before(Obj2)); | ||
| assert(!Obj2.ext_oneapi_owner_before(WeakObj2)); | ||
|
|
||
| assert((Obj1.ext_oneapi_owner_before(Obj2) && | ||
| !Obj2.ext_oneapi_owner_before(Obj1)) || | ||
| (Obj2.ext_oneapi_owner_before(Obj1) && | ||
| !Obj1.ext_oneapi_owner_before(Obj2))); | ||
| } | ||
| }; | ||
|
|
||
| int main() { | ||
| sycl::queue Q; | ||
| runTest<WeakObjectCheckOwnerBefore>(Q); | ||
| runTestMulti<WeakObjectCheckOwnerBeforeMulti>(Q); | ||
| return 0; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.