-
Notifications
You must be signed in to change notification settings - Fork 795
[UR][SYCL] Implement USM prefetch from device to host in SYCL runtime and UR #19437
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
Open
ianayl
wants to merge
32
commits into
intel:sycl
Choose a base branch
from
ianayl:2way-prefetch-2
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
9ae0c55
Initial non-ABI breaking impl in runtime
ianayl 59ae777
Initial UR implementation, + opencl adapter
ianayl 6e6fe08
Add migration flags to memorymanager
ianayl fb827be
Add CUDA adapter impl
ianayl c42c233
More preliminary adapter support
ianayl a5ed168
Merge branch 'sycl' of https://github.com/intel/llvm into 2way-prefet…
ianayl 41d9a6f
Update USM testing
ianayl 742a636
Revise UR impl to not error, add graph testing
ianayl c160e42
Merge branch 'sycl' into 2way-prefetch-2
ianayl 6654b6e
Fix bug
ianayl 7141dea
Merge branch 'sycl' of https://github.com/intel/llvm into 2way-prefet…
ianayl 96059fc
Fix bug in enqueue function header
ianayl b427472
update ur testing
ianayl 4f09c40
fix build issue in new command buffer ur test
ianayl e3b9e9e
Fix bug
ianayl ba1f9f6
Fix memory leak
ianayl 294702c
Disable opencl adapter
ianayl 6dbf10a
Disable opencl enqueue function grpah tests
ianayl a2263f6
ammend test
ianayl 1d16e60
Add breaking changes preview hotpath
ianayl 64bec80
formatting
ianayl c3cfc1f
Merge branch 'sycl' into 2way-prefetch-2
ianayl 0a45ea3
reenable queue test
ianayl 0f4ed1f
Add unittesting to ensure the runtime calls the UR with the right args
ianayl 236f70b
clang-format
ianayl 6de51cc
Remove overcomplicated prefetch alternatives
ianayl 16d40d9
Fix testing
ianayl 160af9d
Apply suggestions for graph tests
ianayl ddb53e5
use new syntax for malloc_shared
ianayl 8de6a9a
clang-format
ianayl e601af9
remove import from handler
ianayl ebc89db
Merge branch 'sycl' of https://github.com/intel/llvm into 2way-prefet…
ianayl 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
33 changes: 33 additions & 0 deletions
33
sycl/include/sycl/ext/oneapi/experimental/enqueue_types.hpp
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 @@ | ||
//==--------------- enqueue_types.hpp ---- SYCL enqueue types --------------==// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace sycl { | ||
inline namespace _V1 { | ||
namespace ext::oneapi::experimental { | ||
|
||
/// @brief Indicates the destination device for USM data to be prefetched to. | ||
enum class prefetch_type { device, host }; | ||
|
||
inline std::string prefetchTypeToString(prefetch_type value) { | ||
switch (value) { | ||
case sycl::ext::oneapi::experimental::prefetch_type::device: | ||
return "prefetch_type::device"; | ||
case sycl::ext::oneapi::experimental::prefetch_type::host: | ||
return "prefetch_type::host"; | ||
default: | ||
return "prefetch_type::unknown"; | ||
} | ||
} | ||
|
||
} // namespace ext::oneapi::experimental | ||
} // namespace _V1 | ||
} // namespace sycl |
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
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
87 changes: 87 additions & 0 deletions
87
sycl/test-e2e/Graph/RecordReplay/ext_oneapi_enqueue_functions_prefetch.cpp
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,87 @@ | ||
// REQUIRES: aspect-usm_shared_allocations | ||
// | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
// | ||
// UNSUPPORTED: opencl | ||
// UNSUPPORTED-INTENDED: OpenCL currently does not support command buffers | ||
// | ||
// RUN: %if level_zero %{%{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
|
||
// Tests prefetch functionality in enqueue functions | ||
|
||
#include "../graph_common.hpp" | ||
#include <sycl/ext/oneapi/experimental/enqueue_functions.hpp> | ||
|
||
static constexpr int N = 100; | ||
static constexpr int Pattern = 42; | ||
|
||
int main() { | ||
queue Q{}; | ||
|
||
int *Src = malloc_shared<int>(N, Q); | ||
int *Dst = malloc_shared<int>(N, Q); | ||
for (int i = 0; i < N; i++) | ||
Src[i] = Pattern; | ||
|
||
{ | ||
exp_ext::command_graph Graph{Q.get_context(), Q.get_device(), {}}; | ||
|
||
Graph.begin_recording(Q); | ||
|
||
// Test submitting host-to-device prefetch | ||
event TestH2D = exp_ext::submit_with_event( | ||
Q, [&](handler &CGH) { exp_ext::prefetch(CGH, Src, sizeof(int) * N); }); | ||
|
||
exp_ext::submit(Q, [&](handler &CGH) { | ||
CGH.depends_on(TestH2D); | ||
exp_ext::parallel_for(CGH, range<1>(N), | ||
[=](id<1> i) { Dst[i] = Src[i] * 2; }); | ||
}); | ||
|
||
Graph.end_recording(); | ||
|
||
auto GraphExec = Graph.finalize(); | ||
|
||
exp_ext::execute_graph(Q, GraphExec); | ||
Q.wait_and_throw(); | ||
} | ||
|
||
// Check host-to-device prefetch results | ||
for (int i = 0; i < N; i++) | ||
assert(check_value(i, Pattern * 2, Dst[i], "Dst")); | ||
|
||
{ | ||
exp_ext::command_graph Graph{Q.get_context(), Q.get_device(), {}}; | ||
|
||
Graph.begin_recording(Q); | ||
|
||
// Test submitting device-to-host prefetch | ||
event TestD2H = exp_ext::submit_with_event(Q, [&](handler &CGH) { | ||
exp_ext::parallel_for(CGH, range<1>(N), | ||
[=](id<1> i) { Dst[i] = Src[i] + 1; }); | ||
}); | ||
|
||
exp_ext::submit(Q, [&](handler &CGH) { | ||
CGH.depends_on(TestD2H); | ||
exp_ext::prefetch(CGH, Dst, sizeof(int) * N, | ||
exp_ext::prefetch_type::host); | ||
}); | ||
|
||
Graph.end_recording(); | ||
|
||
auto GraphExec = Graph.finalize(); | ||
|
||
exp_ext::execute_graph(Q, GraphExec); | ||
Q.wait_and_throw(); | ||
} | ||
|
||
// Check device-to-host prefetch results | ||
for (int i = 0; i < N; i++) | ||
assert(check_value(i, Pattern + 1, Dst[i], "Dst")); | ||
|
||
free(Src, Q); | ||
free(Dst, Q); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
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.