-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add async kernel kenel submition support
- Loading branch information
Showing
9 changed files
with
445 additions
and
37 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
71 changes: 71 additions & 0 deletions
71
numba_dpex/core/runtime/experimental/nrt_reserve_meminfo.cpp
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,71 @@ | ||
// SPDX-FileCopyrightText: 2023 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "nrt_reserve_meminfo.h" | ||
|
||
#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 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, | ||
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 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
Oops, something went wrong.