19 #ifdef XPTI_ENABLE_INSTRUMENTATION
20 uint8_t GBufferStreamID;
22 void *buffer_impl::allocateMem(
ContextImplPtr Context,
bool InitFromUserData,
24 bool HostPtrReadOnly =
false;
25 BaseT::determineHostPtr(Context, InitFromUserData, HostPtr, HostPtrReadOnly);
27 assert(!(
nullptr == HostPtr && BaseT::useHostPtr() && Context->is_host()) &&
28 "Internal error. Allocating memory on the host "
29 "while having use_host_ptr property");
30 return MemoryManager::allocateMemBuffer(
31 std::move(Context),
this, HostPtr, HostPtrReadOnly,
32 BaseT::getSizeInBytes(), BaseT::MInteropEvent, BaseT::MInteropContext,
33 MProps, OutEventToWait);
36 void *UserObj,
const void *HostObj,
37 const void *Type, uint32_t Dim,
38 uint32_t ElemSize,
size_t Range[3]) {
39 XPTIRegistry::bufferConstructorNotification(UserObj, CodeLoc, HostObj, Type,
40 Dim, ElemSize, Range);
43 void buffer_impl::destructorNotification(
void *UserObj) {
44 XPTIRegistry::bufferDestructorNotification(UserObj);
47 void buffer_impl::addInteropObject(
48 std::vector<pi_native_handle> &Handles)
const {
50 if (std::find(Handles.begin(), Handles.end(),
51 pi::cast<pi_native_handle>(MInteropMemObject)) ==
55 pi::cast<RT::PiMem>(MInteropMemObject));
56 Handles.push_back(pi::cast<pi_native_handle>(MInteropMemObject));
61 std::vector<pi_native_handle>
62 buffer_impl::getNativeVector(
backend BackendName)
const {
63 std::vector<pi_native_handle> Handles{};
65 addInteropObject(Handles);
69 for (
auto &Cmd : MRecord->MAllocaCommands) {
70 RT::PiMem NativeMem = pi::cast<RT::PiMem>(Cmd->getMemAllocation());
71 auto Ctx = Cmd->getWorkerContext();
72 auto Platform = Ctx->getPlatformImpl();
77 auto Plugin = Platform->getPlugin();
79 if (Plugin.getBackend() != BackendName)
81 if (Plugin.getBackend() == backend::opencl) {
87 Handles.push_back(Handle);
90 addInteropObject(Handles);