-
Notifications
You must be signed in to change notification settings - Fork 810
[SYCL] Implement sycl_ext_oneapi_usm_shortcuts #20911
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 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97ed386
[SYCL] Implement sycl_ext_oneapi_usm_shortcuts
HPS-1 7d5f369
[SYCL] Add respective test
HPS-1 670f356
[SYCL] Add respective test
HPS-1 7a2f61d
Merge remote-tracking branch 'origin/sycl' into usm_shortcuts_ext
HPS-1 279bb56
[SYCL] Fix outdated props in tests
HPS-1 d0af556
Merge remote-tracking branch 'origin/sycl' into usm_shortcuts_ext
HPS-1 6579cd6
[SYCL] Address comments
HPS-1 6e791e0
[SYCL] Remove unnecessary __SYCL_EXPORT
HPS-1 e234e40
[SYCL] Update Windows dump file
HPS-1 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // RUN: %{build} -o %t.out | ||
| // RUN: %{run} %t.out | ||
|
|
||
| //==------ usm_shortcuts_utility.cpp - USM malloc and aligned_alloc test | ||
| //-------==// | ||
| // | ||
| // 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/detail/core.hpp> | ||
|
|
||
| #include <sycl/ext/intel/experimental/usm_properties.hpp> | ||
| #include <sycl/usm.hpp> | ||
|
|
||
| #include <cassert> | ||
|
|
||
| using namespace sycl; | ||
| using namespace sycl::ext::oneapi::experimental; | ||
|
|
||
| constexpr int N = 8; | ||
|
|
||
| static void check_and_free(int *array, const device &dev, const context &ctxt, | ||
| usm::alloc expected_type) { | ||
| // host device treats all allocations as host allocations | ||
| assert((get_pointer_type(array, ctxt) == expected_type) && | ||
| "Allocation pointer has unexpected type."); | ||
| assert((get_pointer_device(array, ctxt) == dev) && | ||
| "Allocation pointer has unexpected device associated with it."); | ||
| free(array, ctxt); | ||
| } | ||
|
|
||
| int main() { | ||
| queue q; | ||
| auto dev = q.get_device(); | ||
| auto ctxt = q.get_context(); | ||
| int *array; | ||
|
|
||
| if (dev.get_info<sycl::info::device::usm_host_allocations>()) { | ||
| array = (int *)malloc(N * sizeof(int), dev, usm::alloc::host); | ||
| check_and_free(array, dev, ctxt, usm::alloc::host); | ||
|
|
||
| array = | ||
| (int *)malloc(N * sizeof(int), dev, usm::alloc::host, property_list{}); | ||
| check_and_free(array, dev, ctxt, usm::alloc::host); | ||
|
|
||
| array = (int *)aligned_alloc(alignof(long long), N * sizeof(int), dev, | ||
| usm::alloc::host); | ||
| check_and_free(array, dev, ctxt, usm::alloc::host); | ||
|
|
||
| array = (int *)aligned_alloc(alignof(long long), N * sizeof(int), dev, | ||
| usm::alloc::host, property_list{}); | ||
| check_and_free(array, dev, ctxt, usm::alloc::host); | ||
| } | ||
|
|
||
| if (dev.get_info<sycl::info::device::usm_shared_allocations>()) { | ||
| array = (int *)malloc_shared(N * sizeof(int), dev); | ||
| check_and_free(array, dev, ctxt, usm::alloc::shared); | ||
|
|
||
| array = (int *)malloc_shared( | ||
| N * sizeof(int), dev, | ||
| property_list{ | ||
| ext::intel::experimental::property::usm::buffer_location{2}}); | ||
| check_and_free(array, dev, ctxt, usm::alloc::shared); | ||
|
|
||
| array = | ||
| (int *)aligned_alloc_shared(alignof(long long), N * sizeof(int), dev); | ||
| check_and_free(array, dev, ctxt, usm::alloc::shared); | ||
|
|
||
| array = (int *)aligned_alloc_shared( | ||
| alignof(long long), N * sizeof(int), dev, | ||
| property_list{ | ||
| ext::intel::experimental::property::usm::buffer_location{2}}); | ||
| check_and_free(array, dev, ctxt, usm::alloc::shared); | ||
| } | ||
|
|
||
| if (dev.get_info<sycl::info::device::usm_device_allocations>()) { | ||
| array = (int *)malloc_device(N * sizeof(int), dev); | ||
| check_and_free(array, dev, ctxt, usm::alloc::device); | ||
|
|
||
| array = (int *)malloc_device( | ||
| N, dev, | ||
| property_list{ | ||
| ext::intel::experimental::property::usm::buffer_location(2)}); | ||
| check_and_free(array, dev, ctxt, usm::alloc::device); | ||
|
|
||
| array = | ||
| (int *)aligned_alloc_device(alignof(long long), N * sizeof(int), dev); | ||
| check_and_free(array, dev, ctxt, usm::alloc::device); | ||
|
|
||
| array = (int *)aligned_alloc_device(alignof(long long), N * sizeof(int), | ||
| dev, property_list{}); | ||
| check_and_free(array, dev, ctxt, usm::alloc::device); | ||
| } | ||
|
|
||
| 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.