-
Notifications
You must be signed in to change notification settings - Fork 33
Feature/async kernel submition #1219
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 all commits
Commits
Show all changes
2 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 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
71 changes: 71 additions & 0 deletions
71
numba_dpex/core/runtime/experimental/nrt_reserve_meminfo.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,71 @@ | ||
| // SPDX-FileCopyrightText: 2023 Intel Corporation | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "nrt_reserve_meminfo.h" | ||
|
|
||
ZzEeKkAa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include "_dbg_printer.h" | ||
| #include "syclinterface/dpctl_sycl_type_casters.hpp" | ||
| #include <CL/sycl.hpp> | ||
|
|
||
| extern "C" | ||
| { | ||
| DPCTLSyclEventRef | ||
| DPEXRT_nrt_acquire_meminfo_and_schedule_release(NRT_api_functions *nrt, | ||
| DPCTLSyclQueueRef QRef, | ||
| NRT_MemInfo **meminfo_array, | ||
| size_t meminfo_array_size, | ||
| DPCTLSyclEventRef *depERefs, | ||
| size_t nDepERefs, | ||
| int *status) | ||
| { | ||
| DPEXRT_DEBUG(drt_debug_print( | ||
| "DPEXRT-DEBUG: scheduling nrt meminfo release.\n");); | ||
|
|
||
| using dpctl::syclinterface::unwrap; | ||
| using dpctl::syclinterface::wrap; | ||
|
|
||
| sycl::queue *q = unwrap<sycl::queue>(QRef); | ||
|
|
||
| std::vector<NRT_MemInfo *> meminfo_vec( | ||
| meminfo_array, meminfo_array + meminfo_array_size); | ||
|
|
||
| for (size_t i = 0; i < meminfo_array_size; ++i) { | ||
| nrt->acquire(meminfo_vec[i]); | ||
| } | ||
|
|
||
| DPEXRT_DEBUG(drt_debug_print("DPEXRT-DEBUG: acquired meminfo.\n");); | ||
|
|
||
| try { | ||
| sycl::event ht_ev = q->submit([&](sycl::handler &cgh) { | ||
| for (size_t ev_id = 0; ev_id < nDepERefs; ++ev_id) { | ||
| cgh.depends_on(*(unwrap<sycl::event>(depERefs[ev_id]))); | ||
| } | ||
| cgh.host_task([meminfo_array_size, meminfo_vec, nrt]() { | ||
| for (size_t i = 0; i < meminfo_array_size; ++i) { | ||
| nrt->release(meminfo_vec[i]); | ||
| DPEXRT_DEBUG( | ||
| drt_debug_print("DPEXRT-DEBUG: released meminfo " | ||
| "from host_task.\n");); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| constexpr int result_ok = 0; | ||
|
|
||
| *status = result_ok; | ||
| auto e_ptr = new sycl::event(ht_ev); | ||
| return wrap<sycl::event>(e_ptr); | ||
| } catch (const std::exception &e) { | ||
| constexpr int result_std_exception = 1; | ||
|
|
||
| *status = result_std_exception; | ||
| return nullptr; | ||
| } | ||
|
|
||
| constexpr int result_other_abnormal = 2; | ||
|
|
||
| *status = result_other_abnormal; | ||
| return nullptr; | ||
| } | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
numba_dpex/core/runtime/experimental/nrt_reserve_meminfo.h
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,48 @@ | ||
| // SPDX-FileCopyrightText: 2023 Intel Corporation | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// Defines dpctl style function(s) that interruct with nrt meminfo and sycl. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef _EXPERIMENTAL_H_ | ||
| #define _EXPERIMENTAL_H_ | ||
|
|
||
| #include "dpctl_capi.h" | ||
| #include "numba/core/runtime/nrt_external.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" | ||
| { | ||
| #endif | ||
|
|
||
| /*! | ||
| * @brief Acquires meminfos and schedules a host task to release them. | ||
| * | ||
| * @param nrt NRT public API functions, | ||
| * @param QRef Queue reference, | ||
| * @param meminfo_array Array of meminfo pointers to perform actions on, | ||
| * @param meminfo_array_size Length of meminfo_array, | ||
| * @param depERefs Array of dependant events for the host task, | ||
| * @param nDepERefs Length of depERefs, | ||
| * @param status Variable to write status to. Same style as | ||
| * dpctl, | ||
| * @return {return} Event reference to the host task. | ||
| */ | ||
| DPCTLSyclEventRef | ||
| DPEXRT_nrt_acquire_meminfo_and_schedule_release(NRT_api_functions *nrt, | ||
ZzEeKkAa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| DPCTLSyclQueueRef QRef, | ||
| NRT_MemInfo **meminfo_array, | ||
| size_t meminfo_array_size, | ||
| DPCTLSyclEventRef *depERefs, | ||
| size_t nDepERefs, | ||
| int *status); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* _EXPERIMENTAL_H_ */ | ||
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,35 @@ | ||
| # SPDX-FileCopyrightText: 2023 Intel Corporation | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from numba.core import cgutils | ||
|
|
||
| from numba_dpex.core.runtime import context as dpexrt | ||
| from numba_dpex.core.types import DpctlSyclEvent | ||
|
|
||
|
|
||
| def wrap_event_reference(ctx, builder, eref): | ||
| """Wrap dpctl event reference into datamodel so it can be boxed to | ||
| Python.""" | ||
|
|
||
| ty_event = DpctlSyclEvent() | ||
|
|
||
| pyapi = ctx.get_python_api(builder) | ||
|
|
||
| event_struct_proxy = cgutils.create_struct_proxy(ty_event)(ctx, builder) | ||
|
|
||
| # Ref count after the call is equal to 1. | ||
| # TODO: get dpex RT from cached property once the PR is merged | ||
| # https://github.com/IntelPython/numba-dpex/pull/1027 | ||
| # ctx.dpexrt.eventstruct_init( # noqa: W0621 | ||
| dpexrt.DpexRTContext(ctx).eventstruct_init( | ||
| pyapi, | ||
| eref, | ||
| # calling _<method>() is by numba's design | ||
| event_struct_proxy._getpointer(), # pylint: disable=W0212 | ||
| ) | ||
|
|
||
| # calling _<method>() is by numba's design | ||
| event_value = event_struct_proxy._getvalue() # pylint: disable=W0212 | ||
|
|
||
| return event_value |
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
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.