DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
memory_manager.cpp
Go to the documentation of this file.
1 //==-------------- memory_manager.cpp --------------------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include <detail/context_impl.hpp>
11 #include <detail/event_impl.hpp>
12 #include <detail/queue_impl.hpp>
13 
14 #include <algorithm>
15 #include <cassert>
16 #include <cstring>
17 #include <vector>
18 
20 namespace sycl {
21 namespace detail {
22 
23 static void waitForEvents(const std::vector<EventImplPtr> &Events) {
24  // Assuming all events will be on the same device or
25  // devices associated with the same Backend.
26  if (!Events.empty()) {
27  const detail::plugin &Plugin = Events[0]->getPlugin();
28  std::vector<RT::PiEvent> PiEvents(Events.size());
29  std::transform(Events.begin(), Events.end(), PiEvents.begin(),
30  [](const EventImplPtr &EventImpl) {
31  return EventImpl->getHandleRef();
32  });
33  Plugin.call<PiApiKind::piEventsWait>(PiEvents.size(), &PiEvents[0]);
34  }
35 }
36 
37 void MemoryManager::release(ContextImplPtr TargetContext, SYCLMemObjI *MemObj,
38  void *MemAllocation,
39  std::vector<EventImplPtr> DepEvents,
40  RT::PiEvent &OutEvent) {
41  // There is no async API for memory releasing. Explicitly wait for all
42  // dependency events and return empty event.
43  waitForEvents(DepEvents);
44  OutEvent = nullptr;
45  MemObj->releaseMem(TargetContext, MemAllocation);
46 }
47 
48 void MemoryManager::releaseImageBuffer(ContextImplPtr TargetContext,
49  void *ImageBuf) {
50  (void)TargetContext;
51  (void)ImageBuf;
52  // TODO remove when ABI breaking changes are allowed.
53  throw runtime_error("Deprecated release operation", PI_INVALID_OPERATION);
54 }
55 
56 void MemoryManager::releaseMemObj(ContextImplPtr TargetContext,
57  SYCLMemObjI *MemObj, void *MemAllocation,
58  void *UserPtr) {
59  if (UserPtr == MemAllocation) {
60  // Do nothing as it's user provided memory.
61  return;
62  }
63 
64  if (TargetContext->is_host()) {
65  MemObj->releaseHostMem(MemAllocation);
66  return;
67  }
68 
69  const detail::plugin &Plugin = TargetContext->getPlugin();
70  Plugin.call<PiApiKind::piMemRelease>(pi::cast<RT::PiMem>(MemAllocation));
71 }
72 
73 void *MemoryManager::allocate(ContextImplPtr TargetContext, SYCLMemObjI *MemObj,
74  bool InitFromUserData, void *HostPtr,
75  std::vector<EventImplPtr> DepEvents,
76  RT::PiEvent &OutEvent) {
77  // There is no async API for memory allocation. Explicitly wait for all
78  // dependency events and return empty event.
79  waitForEvents(DepEvents);
80  OutEvent = nullptr;
81 
82  return MemObj->allocateMem(TargetContext, InitFromUserData, HostPtr,
83  OutEvent);
84 }
85 
86 void *MemoryManager::wrapIntoImageBuffer(ContextImplPtr TargetContext,
87  void *MemBuf, SYCLMemObjI *MemObj) {
88  (void)TargetContext;
89  (void)MemBuf;
90  (void)MemObj;
91  // TODO remove when ABI breaking changes are allowed.
92  throw runtime_error("Deprecated allocation operation", PI_INVALID_OPERATION);
93 }
94 
95 void *MemoryManager::allocateHostMemory(SYCLMemObjI *MemObj, void *UserPtr,
96  bool HostPtrReadOnly, size_t Size,
97  const sycl::property_list &) {
98  // Can return user pointer directly if it points to writable memory.
99  if (UserPtr && HostPtrReadOnly == false)
100  return UserPtr;
101 
102  void *NewMem = MemObj->allocateHostMem();
103 
104  // Need to initialize new memory if user provides pointer to read only
105  // memory.
106  if (UserPtr && HostPtrReadOnly == true)
107  std::memcpy((char *)NewMem, (char *)UserPtr, Size);
108  return NewMem;
109 }
110 
111 void *MemoryManager::allocateInteropMemObject(
112  ContextImplPtr TargetContext, void *UserPtr,
113  const EventImplPtr &InteropEvent, const ContextImplPtr &InteropContext,
114  const sycl::property_list &, RT::PiEvent &OutEventToWait) {
115  (void)TargetContext;
116  (void)InteropContext;
117  // If memory object is created with interop c'tor return cl_mem as is.
118  assert(TargetContext == InteropContext && "Expected matching contexts");
119  OutEventToWait = InteropEvent->getHandleRef();
120  // Retain the event since it will be released during alloca command
121  // destruction
122  if (nullptr != OutEventToWait) {
123  const detail::plugin &Plugin = InteropEvent->getPlugin();
124  Plugin.call<PiApiKind::piEventRetain>(OutEventToWait);
125  }
126  return UserPtr;
127 }
128 
130  bool HostPtrReadOnly) {
131  // Create read_write mem object to handle arbitrary uses.
132  RT::PiMemFlags Result =
134  if (UserPtr)
135  Result |= HostPtrReadOnly ? PI_MEM_FLAGS_HOST_PTR_COPY
137  return Result;
138 }
139 
140 void *MemoryManager::allocateImageObject(ContextImplPtr TargetContext,
141  void *UserPtr, bool HostPtrReadOnly,
142  const RT::PiMemImageDesc &Desc,
143  const RT::PiMemImageFormat &Format,
144  const sycl::property_list &) {
145  RT::PiMemFlags CreationFlags =
146  getMemObjCreationFlags(UserPtr, HostPtrReadOnly);
147 
148  RT::PiMem NewMem;
149  const detail::plugin &Plugin = TargetContext->getPlugin();
150  Plugin.call<PiApiKind::piMemImageCreate>(TargetContext->getHandleRef(),
151  CreationFlags, &Format, &Desc,
152  UserPtr, &NewMem);
153  return NewMem;
154 }
155 
156 void *
157 MemoryManager::allocateBufferObject(ContextImplPtr TargetContext, void *UserPtr,
158  bool HostPtrReadOnly, const size_t Size,
159  const sycl::property_list &PropsList) {
160  RT::PiMemFlags CreationFlags =
161  getMemObjCreationFlags(UserPtr, HostPtrReadOnly);
162  if (PropsList.has_property<
164  CreationFlags |= PI_MEM_FLAGS_HOST_PTR_ALLOC;
165 
166  RT::PiMem NewMem = nullptr;
167  const detail::plugin &Plugin = TargetContext->getPlugin();
168  Plugin.call<PiApiKind::piMemBufferCreate>(TargetContext->getHandleRef(),
169  CreationFlags, Size, UserPtr,
170  &NewMem, nullptr);
171  return NewMem;
172 }
173 
174 void *MemoryManager::allocateMemBuffer(ContextImplPtr TargetContext,
175  SYCLMemObjI *MemObj, void *UserPtr,
176  bool HostPtrReadOnly, size_t Size,
177  const EventImplPtr &InteropEvent,
178  const ContextImplPtr &InteropContext,
179  const sycl::property_list &PropsList,
180  RT::PiEvent &OutEventToWait) {
181  if (TargetContext->is_host())
182  return allocateHostMemory(MemObj, UserPtr, HostPtrReadOnly, Size,
183  PropsList);
184  if (UserPtr && InteropContext)
185  return allocateInteropMemObject(TargetContext, UserPtr, InteropEvent,
186  InteropContext, PropsList, OutEventToWait);
187  return allocateBufferObject(TargetContext, UserPtr, HostPtrReadOnly, Size,
188  PropsList);
189 }
190 
191 void *MemoryManager::allocateMemImage(
192  ContextImplPtr TargetContext, SYCLMemObjI *MemObj, void *UserPtr,
193  bool HostPtrReadOnly, size_t Size, const RT::PiMemImageDesc &Desc,
194  const RT::PiMemImageFormat &Format, const EventImplPtr &InteropEvent,
195  const ContextImplPtr &InteropContext, const sycl::property_list &PropsList,
196  RT::PiEvent &OutEventToWait) {
197  if (TargetContext->is_host())
198  return allocateHostMemory(MemObj, UserPtr, HostPtrReadOnly, Size,
199  PropsList);
200  if (UserPtr && InteropContext)
201  return allocateInteropMemObject(TargetContext, UserPtr, InteropEvent,
202  InteropContext, PropsList, OutEventToWait);
203  return allocateImageObject(TargetContext, UserPtr, HostPtrReadOnly, Desc,
204  Format, PropsList);
205 }
206 
207 void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext,
208  void *ParentMemObj, size_t ElemSize,
209  size_t Offset, range<3> Range,
210  std::vector<EventImplPtr> DepEvents,
211  RT::PiEvent &OutEvent) {
212  waitForEvents(DepEvents);
213  OutEvent = nullptr;
214 
215  if (TargetContext->is_host())
216  return static_cast<void *>(static_cast<char *>(ParentMemObj) + Offset);
217 
218  size_t SizeInBytes = ElemSize;
219  for (size_t I = 0; I < 3; ++I)
220  SizeInBytes *= Range[I];
221 
222  RT::PiResult Error = PI_SUCCESS;
223  pi_buffer_region_struct Region{Offset, SizeInBytes};
224  RT::PiMem NewMem;
225  const detail::plugin &Plugin = TargetContext->getPlugin();
227  pi::cast<RT::PiMem>(ParentMemObj), PI_MEM_FLAGS_ACCESS_RW,
228  PI_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem);
229  if (Error == PI_MISALIGNED_SUB_BUFFER_OFFSET)
230  throw invalid_object_error(
231  "Specified offset of the sub-buffer being constructed is not a "
232  "multiple of the memory base address alignment",
234 
235  if (Error != PI_SUCCESS) {
236  Plugin.reportPiError(Error, "allocateMemSubBuffer()");
237  }
238 
239  return NewMem;
240 }
241 
243  int XTerm;
244  int YTerm;
245  int ZTerm;
246 };
247 void prepTermPositions(TermPositions &pos, int Dimensions,
249  // For buffers, the offsets/ranges coming from accessor are always
250  // id<3>/range<3> But their organization varies by dimension:
251  // 1 ==> {width, 1, 1}
252  // 2 ==> {height, width, 1}
253  // 3 ==> {depth, height, width}
254  // Some callers schedule 0 as DimDst/DimSrc.
255 
256  if (Type == detail::SYCLMemObjI::MemObjType::Buffer) {
257  if (Dimensions == 3) {
258  pos.XTerm = 2, pos.YTerm = 1, pos.ZTerm = 0;
259  } else if (Dimensions == 2) {
260  pos.XTerm = 1, pos.YTerm = 0, pos.ZTerm = 2;
261  } else { // Dimension is 1 or 0
262  pos.XTerm = 0, pos.YTerm = 1, pos.ZTerm = 2;
263  }
264  } else { // While range<>/id<> use by images is different than buffers, it's
265  // consistent with their accessors.
266  pos.XTerm = 0;
267  pos.YTerm = 1;
268  pos.ZTerm = 2;
269  }
270 }
271 
272 void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr,
273  unsigned int DimSrc, sycl::range<3> SrcSize,
274  sycl::range<3> SrcAccessRange, sycl::id<3> SrcOffset,
275  unsigned int SrcElemSize, RT::PiMem DstMem, QueueImplPtr TgtQueue,
276  unsigned int DimDst, sycl::range<3> DstSize,
277  sycl::range<3> DstAccessRange, sycl::id<3> DstOffset,
278  unsigned int DstElemSize, std::vector<RT::PiEvent> DepEvents,
279  RT::PiEvent &OutEvent) {
280  (void)SrcAccessRange;
281  assert(SYCLMemObj && "The SYCLMemObj is nullptr");
282 
283  const RT::PiQueue Queue = TgtQueue->getHandleRef();
284  const detail::plugin &Plugin = TgtQueue->getPlugin();
285 
286  detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType();
287  TermPositions SrcPos, DstPos;
288  prepTermPositions(SrcPos, DimSrc, MemType);
289  prepTermPositions(DstPos, DimDst, MemType);
290 
291  size_t DstXOffBytes = DstOffset[DstPos.XTerm] * DstElemSize;
292  size_t SrcXOffBytes = SrcOffset[SrcPos.XTerm] * SrcElemSize;
293  size_t DstAccessRangeWidthBytes = DstAccessRange[DstPos.XTerm] * DstElemSize;
294  size_t DstSzWidthBytes = DstSize[DstPos.XTerm] * DstElemSize;
295  size_t SrcSzWidthBytes = SrcSize[SrcPos.XTerm] * SrcElemSize;
296 
297  if (MemType == detail::SYCLMemObjI::MemObjType::Buffer) {
298  if (1 == DimDst && 1 == DimSrc) {
300  Queue, DstMem,
301  /*blocking_write=*/CL_FALSE, DstXOffBytes, DstAccessRangeWidthBytes,
302  SrcMem + SrcXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent);
303  } else {
304  size_t BufferRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes;
305  size_t BufferSlicePitch =
306  (3 == DimDst) ? DstSzWidthBytes * DstSize[DstPos.YTerm] : 0;
307  size_t HostRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes;
308  size_t HostSlicePitch =
309  (3 == DimSrc) ? SrcSzWidthBytes * SrcSize[SrcPos.YTerm] : 0;
310 
311  pi_buff_rect_offset_struct BufferOffset{
312  DstXOffBytes, DstOffset[DstPos.YTerm], DstOffset[DstPos.ZTerm]};
313  pi_buff_rect_offset_struct HostOffset{
314  SrcXOffBytes, SrcOffset[SrcPos.YTerm], SrcOffset[SrcPos.ZTerm]};
315  pi_buff_rect_region_struct RectRegion{DstAccessRangeWidthBytes,
316  DstAccessRange[DstPos.YTerm],
317  DstAccessRange[DstPos.ZTerm]};
318 
320  Queue, DstMem,
321  /*blocking_write=*/CL_FALSE, &BufferOffset, &HostOffset, &RectRegion,
322  BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch,
323  SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent);
324  }
325  } else {
326  size_t InputRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes;
327  size_t InputSlicePitch =
328  (3 == DimDst) ? DstSzWidthBytes * DstSize[DstPos.YTerm] : 0;
329 
330  pi_image_offset_struct Origin{DstOffset[DstPos.XTerm],
331  DstOffset[DstPos.YTerm],
332  DstOffset[DstPos.ZTerm]};
333  pi_image_region_struct Region{DstAccessRange[DstPos.XTerm],
334  DstAccessRange[DstPos.YTerm],
335  DstAccessRange[DstPos.ZTerm]};
336 
338  Queue, DstMem,
339  /*blocking_write=*/CL_FALSE, &Origin, &Region, InputRowPitch,
340  InputSlicePitch, SrcMem, DepEvents.size(), DepEvents.data(), &OutEvent);
341  }
342 }
343 
344 void copyD2H(SYCLMemObjI *SYCLMemObj, RT::PiMem SrcMem, QueueImplPtr SrcQueue,
345  unsigned int DimSrc, sycl::range<3> SrcSize,
346  sycl::range<3> SrcAccessRange, sycl::id<3> SrcOffset,
347  unsigned int SrcElemSize, char *DstMem, QueueImplPtr,
348  unsigned int DimDst, sycl::range<3> DstSize,
349  sycl::range<3> DstAccessRange, sycl::id<3> DstOffset,
350  unsigned int DstElemSize, std::vector<RT::PiEvent> DepEvents,
351  RT::PiEvent &OutEvent) {
352  (void)DstAccessRange;
353  assert(SYCLMemObj && "The SYCLMemObj is nullptr");
354 
355  const RT::PiQueue Queue = SrcQueue->getHandleRef();
356  const detail::plugin &Plugin = SrcQueue->getPlugin();
357 
358  detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType();
359  TermPositions SrcPos, DstPos;
360  prepTermPositions(SrcPos, DimSrc, MemType);
361  prepTermPositions(DstPos, DimDst, MemType);
362 
363  // For a given buffer, the various mem copy routines (copyD2H, copyH2D,
364  // copyD2D) will usually have the same values for AccessRange, Size,
365  // Dimension, Offset, etc. EXCEPT when the dtor for ~SYCLMemObjT is called.
366  // Essentially, it schedules a copyBack of chars thus in copyD2H the
367  // Dimension will then be 1 and DstAccessRange[0] and DstSize[0] will be
368  // sized to bytes with a DstElemSize of 1.
369  size_t DstXOffBytes = DstOffset[DstPos.XTerm] * DstElemSize;
370  size_t SrcXOffBytes = SrcOffset[SrcPos.XTerm] * SrcElemSize;
371  size_t SrcAccessRangeWidthBytes = SrcAccessRange[SrcPos.XTerm] * SrcElemSize;
372  size_t DstSzWidthBytes = DstSize[DstPos.XTerm] * DstElemSize;
373  size_t SrcSzWidthBytes = SrcSize[SrcPos.XTerm] * SrcElemSize;
374 
375  if (MemType == detail::SYCLMemObjI::MemObjType::Buffer) {
376  if (1 == DimDst && 1 == DimSrc) {
378  Queue, SrcMem,
379  /*blocking_read=*/CL_FALSE, SrcXOffBytes, SrcAccessRangeWidthBytes,
380  DstMem + DstXOffBytes, DepEvents.size(), DepEvents.data(), &OutEvent);
381  } else {
382  size_t BufferRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes;
383  size_t BufferSlicePitch =
384  (3 == DimSrc) ? SrcSzWidthBytes * SrcSize[SrcPos.YTerm] : 0;
385  size_t HostRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes;
386  size_t HostSlicePitch =
387  (3 == DimDst) ? DstSzWidthBytes * DstSize[DstPos.YTerm] : 0;
388 
389  pi_buff_rect_offset_struct BufferOffset{
390  SrcXOffBytes, SrcOffset[SrcPos.YTerm], SrcOffset[SrcPos.ZTerm]};
391  pi_buff_rect_offset_struct HostOffset{
392  DstXOffBytes, DstOffset[DstPos.YTerm], DstOffset[DstPos.ZTerm]};
393  pi_buff_rect_region_struct RectRegion{SrcAccessRangeWidthBytes,
394  SrcAccessRange[SrcPos.YTerm],
395  SrcAccessRange[SrcPos.ZTerm]};
396 
398  Queue, SrcMem,
399  /*blocking_read=*/CL_FALSE, &BufferOffset, &HostOffset, &RectRegion,
400  BufferRowPitch, BufferSlicePitch, HostRowPitch, HostSlicePitch,
401  DstMem, DepEvents.size(), DepEvents.data(), &OutEvent);
402  }
403  } else {
404  size_t RowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes;
405  size_t SlicePitch =
406  (3 == DimSrc) ? SrcSzWidthBytes * SrcSize[SrcPos.YTerm] : 0;
407 
408  pi_image_offset_struct Offset{SrcOffset[SrcPos.XTerm],
409  SrcOffset[SrcPos.YTerm],
410  SrcOffset[SrcPos.ZTerm]};
411  pi_image_region_struct Region{SrcAccessRange[SrcPos.XTerm],
412  SrcAccessRange[SrcPos.YTerm],
413  SrcAccessRange[SrcPos.ZTerm]};
414 
416  Queue, SrcMem, CL_FALSE, &Offset, &Region, RowPitch, SlicePitch, DstMem,
417  DepEvents.size(), DepEvents.data(), &OutEvent);
418  }
419 }
420 
421 void copyD2D(SYCLMemObjI *SYCLMemObj, RT::PiMem SrcMem, QueueImplPtr SrcQueue,
422  unsigned int DimSrc, sycl::range<3> SrcSize,
423  sycl::range<3> SrcAccessRange, sycl::id<3> SrcOffset,
424  unsigned int SrcElemSize, RT::PiMem DstMem, QueueImplPtr,
425  unsigned int DimDst, sycl::range<3> DstSize, sycl::range<3>,
426  sycl::id<3> DstOffset, unsigned int DstElemSize,
427  std::vector<RT::PiEvent> DepEvents, RT::PiEvent &OutEvent) {
428  assert(SYCLMemObj && "The SYCLMemObj is nullptr");
429 
430  const RT::PiQueue Queue = SrcQueue->getHandleRef();
431  const detail::plugin &Plugin = SrcQueue->getPlugin();
432 
433  detail::SYCLMemObjI::MemObjType MemType = SYCLMemObj->getType();
434  TermPositions SrcPos, DstPos;
435  prepTermPositions(SrcPos, DimSrc, MemType);
436  prepTermPositions(DstPos, DimDst, MemType);
437 
438  size_t DstXOffBytes = DstOffset[DstPos.XTerm] * DstElemSize;
439  size_t SrcXOffBytes = SrcOffset[SrcPos.XTerm] * SrcElemSize;
440  size_t SrcAccessRangeWidthBytes = SrcAccessRange[SrcPos.XTerm] * SrcElemSize;
441  size_t DstSzWidthBytes = DstSize[DstPos.XTerm] * DstElemSize;
442  size_t SrcSzWidthBytes = SrcSize[SrcPos.XTerm] * SrcElemSize;
443 
444  if (MemType == detail::SYCLMemObjI::MemObjType::Buffer) {
445  if (1 == DimDst && 1 == DimSrc) {
447  Queue, SrcMem, DstMem, SrcXOffBytes, DstXOffBytes,
448  SrcAccessRangeWidthBytes, DepEvents.size(), DepEvents.data(),
449  &OutEvent);
450  } else {
451  // passing 0 for pitches not allowed. Because clEnqueueCopyBufferRect will
452  // calculate both src and dest pitch using region[0], which is not correct
453  // if src and dest are not the same size.
454  size_t SrcRowPitch = SrcSzWidthBytes;
455  size_t SrcSlicePitch = (DimSrc <= 1)
456  ? SrcSzWidthBytes
457  : SrcSzWidthBytes * SrcSize[SrcPos.YTerm];
458  size_t DstRowPitch = DstSzWidthBytes;
459  size_t DstSlicePitch = (DimDst <= 1)
460  ? DstSzWidthBytes
461  : DstSzWidthBytes * DstSize[DstPos.YTerm];
462 
463  pi_buff_rect_offset_struct SrcOrigin{
464  SrcXOffBytes, SrcOffset[SrcPos.YTerm], SrcOffset[SrcPos.ZTerm]};
465  pi_buff_rect_offset_struct DstOrigin{
466  DstXOffBytes, DstOffset[DstPos.YTerm], DstOffset[DstPos.ZTerm]};
467  pi_buff_rect_region_struct Region{SrcAccessRangeWidthBytes,
468  SrcAccessRange[SrcPos.YTerm],
469  SrcAccessRange[SrcPos.ZTerm]};
470 
472  Queue, SrcMem, DstMem, &SrcOrigin, &DstOrigin, &Region, SrcRowPitch,
473  SrcSlicePitch, DstRowPitch, DstSlicePitch, DepEvents.size(),
474  DepEvents.data(), &OutEvent);
475  }
476  } else {
477  pi_image_offset_struct SrcOrigin{SrcOffset[SrcPos.XTerm],
478  SrcOffset[SrcPos.YTerm],
479  SrcOffset[SrcPos.ZTerm]};
480  pi_image_offset_struct DstOrigin{DstOffset[DstPos.XTerm],
481  DstOffset[DstPos.YTerm],
482  DstOffset[DstPos.ZTerm]};
483  pi_image_region_struct Region{SrcAccessRange[SrcPos.XTerm],
484  SrcAccessRange[SrcPos.YTerm],
485  SrcAccessRange[SrcPos.ZTerm]};
486 
488  Queue, SrcMem, DstMem, &SrcOrigin, &DstOrigin, &Region,
489  DepEvents.size(), DepEvents.data(), &OutEvent);
490  }
491 }
492 
493 static void copyH2H(SYCLMemObjI *, char *SrcMem, QueueImplPtr,
494  unsigned int DimSrc, sycl::range<3> SrcSize,
495  sycl::range<3> SrcAccessRange, sycl::id<3> SrcOffset,
496  unsigned int SrcElemSize, char *DstMem, QueueImplPtr,
497  unsigned int DimDst, sycl::range<3> DstSize,
498  sycl::range<3> DstAccessRange, sycl::id<3> DstOffset,
499  unsigned int DstElemSize, std::vector<RT::PiEvent>,
500  RT::PiEvent &) {
501  if ((DimSrc != 1 || DimDst != 1) &&
502  (SrcOffset != id<3>{0, 0, 0} || DstOffset != id<3>{0, 0, 0} ||
503  SrcSize != SrcAccessRange || DstSize != DstAccessRange)) {
504  throw runtime_error("Not supported configuration of memcpy requested",
506  }
507 
508  SrcMem += SrcOffset[0] * SrcElemSize;
509  DstMem += DstOffset[0] * DstElemSize;
510 
511  if (SrcMem == DstMem)
512  return;
513 
514  size_t BytesToCopy =
515  SrcAccessRange[0] * SrcElemSize * SrcAccessRange[1] * SrcAccessRange[2];
516  std::memcpy(DstMem, SrcMem, BytesToCopy);
517 }
518 
519 // Copies memory between: host and device, host and host,
520 // device and device if memory objects bound to the one context.
521 void MemoryManager::copy(SYCLMemObjI *SYCLMemObj, void *SrcMem,
522  QueueImplPtr SrcQueue, unsigned int DimSrc,
523  sycl::range<3> SrcSize, sycl::range<3> SrcAccessRange,
524  sycl::id<3> SrcOffset, unsigned int SrcElemSize,
525  void *DstMem, QueueImplPtr TgtQueue,
526  unsigned int DimDst, sycl::range<3> DstSize,
527  sycl::range<3> DstAccessRange, sycl::id<3> DstOffset,
528  unsigned int DstElemSize,
529  std::vector<RT::PiEvent> DepEvents,
530  RT::PiEvent &OutEvent) {
531 
532  if (SrcQueue->is_host()) {
533  if (TgtQueue->is_host())
534  copyH2H(SYCLMemObj, (char *)SrcMem, std::move(SrcQueue), DimSrc, SrcSize,
535  SrcAccessRange, SrcOffset, SrcElemSize, (char *)DstMem,
536  std::move(TgtQueue), DimDst, DstSize, DstAccessRange, DstOffset,
537  DstElemSize, std::move(DepEvents), OutEvent);
538 
539  else
540  copyH2D(SYCLMemObj, (char *)SrcMem, std::move(SrcQueue), DimSrc, SrcSize,
541  SrcAccessRange, SrcOffset, SrcElemSize,
542  pi::cast<RT::PiMem>(DstMem), std::move(TgtQueue), DimDst, DstSize,
543  DstAccessRange, DstOffset, DstElemSize, std::move(DepEvents),
544  OutEvent);
545  } else {
546  if (TgtQueue->is_host())
547  copyD2H(SYCLMemObj, pi::cast<RT::PiMem>(SrcMem), std::move(SrcQueue),
548  DimSrc, SrcSize, SrcAccessRange, SrcOffset, SrcElemSize,
549  (char *)DstMem, std::move(TgtQueue), DimDst, DstSize,
550  DstAccessRange, DstOffset, DstElemSize, std::move(DepEvents),
551  OutEvent);
552  else
553  copyD2D(SYCLMemObj, pi::cast<RT::PiMem>(SrcMem), std::move(SrcQueue),
554  DimSrc, SrcSize, SrcAccessRange, SrcOffset, SrcElemSize,
555  pi::cast<RT::PiMem>(DstMem), std::move(TgtQueue), DimDst, DstSize,
556  DstAccessRange, DstOffset, DstElemSize, std::move(DepEvents),
557  OutEvent);
558  }
559 }
560 
561 void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue,
562  size_t PatternSize, const char *Pattern,
563  unsigned int Dim, sycl::range<3>, sycl::range<3> Range,
564  sycl::id<3> Offset, unsigned int ElementSize,
565  std::vector<RT::PiEvent> DepEvents,
566  RT::PiEvent &OutEvent) {
567  assert(SYCLMemObj && "The SYCLMemObj is nullptr");
568 
569  const detail::plugin &Plugin = Queue->getPlugin();
570  if (SYCLMemObj->getType() == detail::SYCLMemObjI::MemObjType::Buffer) {
571  if (Dim == 1) {
573  Queue->getHandleRef(), pi::cast<RT::PiMem>(Mem), Pattern, PatternSize,
574  Offset[0] * ElementSize, Range[0] * ElementSize, DepEvents.size(),
575  DepEvents.data(), &OutEvent);
576  return;
577  }
578  throw runtime_error("Not supported configuration of fill requested",
580  } else {
582  Queue->getHandleRef(), pi::cast<RT::PiMem>(Mem), Pattern, &Offset[0],
583  &Range[0], DepEvents.size(), DepEvents.data(), &OutEvent);
584  }
585 }
586 
587 void *MemoryManager::map(SYCLMemObjI *, void *Mem, QueueImplPtr Queue,
588  access::mode AccessMode, unsigned int, sycl::range<3>,
589  sycl::range<3> AccessRange, sycl::id<3> AccessOffset,
590  unsigned int ElementSize,
591  std::vector<RT::PiEvent> DepEvents,
592  RT::PiEvent &OutEvent) {
593  if (Queue->is_host()) {
594  throw runtime_error("Not supported configuration of map requested",
596  }
597 
598  pi_map_flags Flags = 0;
599 
600  switch (AccessMode) {
601  case access::mode::read:
602  Flags |= PI_MAP_READ;
603  break;
604  case access::mode::write:
605  Flags |= PI_MAP_WRITE;
606  break;
607  case access::mode::read_write:
608  case access::mode::atomic:
609  Flags = PI_MAP_WRITE | PI_MAP_READ;
610  break;
611  case access::mode::discard_write:
612  case access::mode::discard_read_write:
614  break;
615  }
616 
617  AccessOffset[0] *= ElementSize;
618  AccessRange[0] *= ElementSize;
619 
620  // TODO: Handle offset
621  assert(AccessOffset[0] == 0 && "Handle offset");
622 
623  void *MappedPtr = nullptr;
624  const size_t BytesToMap = AccessRange[0] * AccessRange[1] * AccessRange[2];
625  const detail::plugin &Plugin = Queue->getPlugin();
627  Queue->getHandleRef(), pi::cast<RT::PiMem>(Mem), CL_FALSE, Flags,
628  AccessOffset[0], BytesToMap, DepEvents.size(), DepEvents.data(),
629  &OutEvent, &MappedPtr);
630  return MappedPtr;
631 }
632 
633 void MemoryManager::unmap(SYCLMemObjI *, void *Mem, QueueImplPtr Queue,
634  void *MappedPtr, std::vector<RT::PiEvent> DepEvents,
635  RT::PiEvent &OutEvent) {
636 
637  // Host queue is not supported here.
638  // All DepEvents are to the same Context.
639  // Using the plugin of the Queue.
640 
641  const detail::plugin &Plugin = Queue->getPlugin();
643  Queue->getHandleRef(), pi::cast<RT::PiMem>(Mem), MappedPtr,
644  DepEvents.size(), DepEvents.data(), &OutEvent);
645 }
646 
647 void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue,
648  size_t Len, void *DstMem,
649  std::vector<RT::PiEvent> DepEvents,
650  RT::PiEvent &OutEvent) {
651  sycl::context Context = SrcQueue->get_context();
652 
653  if (!Len) { // no-op, but ensure DepEvents will still be waited on
654  if (!Context.is_host() && !DepEvents.empty()) {
655  SrcQueue->getPlugin().call<PiApiKind::piEnqueueEventsWait>(
656  SrcQueue->getHandleRef(), DepEvents.size(), DepEvents.data(),
657  &OutEvent);
658  }
659  return;
660  }
661 
662  if (!SrcMem || !DstMem)
663  throw runtime_error("NULL pointer argument in memory copy operation.",
665 
666  if (Context.is_host()) {
667  std::memcpy(DstMem, SrcMem, Len);
668  } else {
669  const detail::plugin &Plugin = SrcQueue->getPlugin();
670  Plugin.call<PiApiKind::piextUSMEnqueueMemcpy>(SrcQueue->getHandleRef(),
671  /* blocking */ false, DstMem,
672  SrcMem, Len, DepEvents.size(),
673  DepEvents.data(), &OutEvent);
674  }
675 }
676 
677 void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length,
678  int Pattern, std::vector<RT::PiEvent> DepEvents,
679  RT::PiEvent &OutEvent) {
680  sycl::context Context = Queue->get_context();
681 
682  if (!Length) { // no-op, but ensure DepEvents will still be waited on
683  if (!Context.is_host() && !DepEvents.empty()) {
684  Queue->getPlugin().call<PiApiKind::piEnqueueEventsWait>(
685  Queue->getHandleRef(), DepEvents.size(), DepEvents.data(), &OutEvent);
686  }
687  return;
688  }
689 
690  if (!Mem)
691  throw runtime_error("NULL pointer argument in memory fill operation.",
693 
694  if (Context.is_host()) {
695  std::memset(Mem, Pattern, Length);
696  } else {
697  const detail::plugin &Plugin = Queue->getPlugin();
699  Queue->getHandleRef(), Mem, Pattern, Length, DepEvents.size(),
700  DepEvents.data(), &OutEvent);
701  }
702 }
703 
704 void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length,
705  std::vector<RT::PiEvent> DepEvents,
706  RT::PiEvent &OutEvent) {
707  sycl::context Context = Queue->get_context();
708 
709  if (Context.is_host()) {
710  // TODO: Potentially implement prefetch on the host.
711  } else {
712  const detail::plugin &Plugin = Queue->getPlugin();
714  Queue->getHandleRef(), Mem, Length, _pi_usm_migration_flags(0),
715  DepEvents.size(), DepEvents.data(), &OutEvent);
716  }
717 }
718 
719 void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue,
720  size_t Length, pi_mem_advice Advice,
721  std::vector<RT::PiEvent> /*DepEvents*/,
722  RT::PiEvent &OutEvent) {
723  sycl::context Context = Queue->get_context();
724 
725  if (!Context.is_host()) {
726  const detail::plugin &Plugin = Queue->getPlugin();
727  Plugin.call<PiApiKind::piextUSMEnqueueMemAdvise>(Queue->getHandleRef(), Mem,
728  Length, Advice, &OutEvent);
729  }
730 }
731 
732 } // namespace detail
733 } // namespace sycl
734 } // __SYCL_INLINE_NAMESPACE(cl)
_pi_mem
PI Mem mapping to CUDA memory allocations, both data and texture/surface.
Definition: pi_cuda.hpp:208
PI_MAP_WRITE
constexpr pi_map_flags PI_MAP_WRITE
Definition: pi.h:559
event_impl.hpp
PI_SUCCESS
@ PI_SUCCESS
Definition: pi.h:82
pi_buff_rect_offset_struct
Definition: pi.h:800
cl::sycl::detail::ContextImplPtr
std::shared_ptr< detail::context_impl > ContextImplPtr
Definition: memory_manager.hpp:31
cl::sycl::detail::getMemObjCreationFlags
static RT::PiMemFlags getMemObjCreationFlags(void *UserPtr, bool HostPtrReadOnly)
Definition: memory_manager.cpp:129
context_impl.hpp
cl::sycl::detail::SYCLMemObjI::releaseHostMem
virtual void releaseHostMem(void *Ptr)=0
PI_INVALID_OPERATION
@ PI_INVALID_OPERATION
Definition: pi.h:84
PI_MEM_FLAGS_HOST_PTR_COPY
constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_COPY
Definition: pi.h:553
cl::sycl::id< 3 >
_pi_mem_advice
_pi_mem_advice
Definition: pi.h:441
cl::sycl::detail::TermPositions::XTerm
int XTerm
Definition: memory_manager.cpp:243
piEnqueueMemBufferCopy
pi_result piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, pi_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1236
_pi_result
_pi_result
Definition: pi.h:81
piEnqueueMemUnmap
pi_result piEnqueueMemUnmap(pi_queue command_queue, pi_mem memobj, void *mapped_ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1262
cl::sycl::detail::copyD2D
void copyD2D(SYCLMemObjI *SYCLMemObj, RT::PiMem SrcMem, QueueImplPtr SrcQueue, unsigned int DimSrc, sycl::range< 3 > SrcSize, sycl::range< 3 > SrcAccessRange, sycl::id< 3 > SrcOffset, unsigned int SrcElemSize, RT::PiMem DstMem, QueueImplPtr, unsigned int DimDst, sycl::range< 3 > DstSize, sycl::range< 3 >, sycl::id< 3 > DstOffset, unsigned int DstElemSize, std::vector< RT::PiEvent > DepEvents, RT::PiEvent &OutEvent)
Definition: memory_manager.cpp:421
cl::sycl::property_list::has_property
bool has_property() const
Definition: property_list.hpp:51
cl::sycl::detail::copyH2H
static void copyH2H(SYCLMemObjI *, char *SrcMem, QueueImplPtr, unsigned int DimSrc, sycl::range< 3 > SrcSize, sycl::range< 3 > SrcAccessRange, sycl::id< 3 > SrcOffset, unsigned int SrcElemSize, char *DstMem, QueueImplPtr, unsigned int DimDst, sycl::range< 3 > DstSize, sycl::range< 3 > DstAccessRange, sycl::id< 3 > DstOffset, unsigned int DstElemSize, std::vector< RT::PiEvent >, RT::PiEvent &)
Definition: memory_manager.cpp:493
cl::sycl::detail::pi::PiMemFlags
::pi_mem_flags PiMemFlags
Definition: pi.hpp:112
cl::sycl::property_list
Objects of the property_list class are containers for the SYCL properties.
Definition: property_list.hpp:25
piEnqueueMemImageFill
pi_result piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, const void *fill_color, const size_t *origin, const size_t *region, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1317
queue_impl.hpp
cl::sycl::detail::copyH2D
void copyH2D(SYCLMemObjI *SYCLMemObj, char *SrcMem, QueueImplPtr, unsigned int DimSrc, sycl::range< 3 > SrcSize, sycl::range< 3 > SrcAccessRange, sycl::id< 3 > SrcOffset, unsigned int SrcElemSize, RT::PiMem DstMem, QueueImplPtr TgtQueue, unsigned int DimDst, sycl::range< 3 > DstSize, sycl::range< 3 > DstAccessRange, sycl::id< 3 > DstOffset, unsigned int DstElemSize, std::vector< RT::PiEvent > DepEvents, RT::PiEvent &OutEvent)
Definition: memory_manager.cpp:272
cl::sycl::detail::plugin::call_nocheck
RT::PiResult call_nocheck(ArgsT... Args) const
Calls the PiApi, traces the call, and returns the result.
Definition: plugin.hpp:141
cl::sycl::detail::write
void write(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const char *Str, unsigned Len, unsigned Padding=0)
Definition: stream.hpp:110
cl::sycl::range< 3 >
cl::sycl::detail::SYCLMemObjI::getType
virtual MemObjType getType() const =0
cl::sycl::detail::SYCLMemObjI::MemObjType
MemObjType
Definition: sycl_mem_obj_i.hpp:32
cl::sycl::detail::memcpy
void memcpy(void *Dst, const void *Src, std::size_t Size)
cl::sycl::range::size
size_t size() const
Definition: range.hpp:50
cl::sycl::detail::prepTermPositions
void prepTermPositions(TermPositions &pos, int Dimensions, detail::SYCLMemObjI::MemObjType Type)
Definition: memory_manager.cpp:247
PI_MEM_ACCESS_READ_ONLY
constexpr pi_mem_flags PI_MEM_ACCESS_READ_ONLY
Definition: pi.h:550
piextUSMEnqueueMemcpy
pi_result piextUSMEnqueueMemcpy(pi_queue queue, pi_bool blocking, void *dst_ptr, const void *src_ptr, size_t size, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
USM Memcpy API.
Definition: pi_esimd_emulator.cpp:1480
piMemBufferPartition
pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, void *buffer_create_info, pi_mem *ret_mem)
Definition: pi_esimd_emulator.cpp:1323
piextUSMEnqueueMemAdvise
pi_result piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, size_t length, pi_mem_advice advice, pi_event *event)
USM Memadvise API.
Definition: pi_esimd_emulator.cpp:1485
piEventsWait
pi_result piEventsWait(pi_uint32 num_events, const pi_event *event_list)
Definition: pi_esimd_emulator.cpp:1087
_pi_queue
PI queue mapping on to CUstream objects.
Definition: pi_cuda.hpp:379
PI_MAP_READ
constexpr pi_map_flags PI_MAP_READ
Definition: pi.h:558
piEnqueueMemBufferReadRect
pi_result piEnqueueMemBufferReadRect(pi_queue command_queue, pi_mem buffer, pi_bool blocking_read, pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset, pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1214
pi_buff_rect_region_struct
Definition: pi.h:809
piMemRelease
pi_result piMemRelease(pi_mem mem)
Definition: pi_esimd_emulator.cpp:825
piEnqueueMemBufferCopyRect
pi_result piEnqueueMemBufferCopyRect(pi_queue command_queue, pi_mem src_buffer, pi_mem dst_buffer, pi_buff_rect_offset src_origin, pi_buff_rect_offset dst_origin, pi_buff_rect_region region, size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, size_t dst_slice_pitch, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1242
piEnqueueMemBufferWrite
pi_result piEnqueueMemBufferWrite(pi_queue command_queue, pi_mem buffer, pi_bool blocking_write, size_t offset, size_t size, const void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1222
PI_MISALIGNED_SUB_BUFFER_OFFSET
@ PI_MISALIGNED_SUB_BUFFER_OFFSET
Definition: pi.h:102
piEnqueueMemImageRead
pi_result piEnqueueMemImageRead(pi_queue command_queue, pi_mem image, pi_bool blocking_read, pi_image_offset origin, pi_image_region region, size_t row_pitch, size_t slice_pitch, void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1271
cl::sycl::context::is_host
bool is_host() const
Gets OpenCL interoperability context.
Definition: context.cpp:119
cl::sycl::detail::EventImplPtr
std::shared_ptr< detail::event_impl > EventImplPtr
Definition: memory_manager.hpp:30
cl::sycl::detail::TermPositions::YTerm
int YTerm
Definition: memory_manager.cpp:244
cl::sycl::detail::plugin::call
void call(ArgsT... Args) const
Calls the API, traces the call, checks the result.
Definition: plugin.hpp:182
cl::sycl::detail::copyD2H
void copyD2H(SYCLMemObjI *SYCLMemObj, RT::PiMem SrcMem, QueueImplPtr SrcQueue, unsigned int DimSrc, sycl::range< 3 > SrcSize, sycl::range< 3 > SrcAccessRange, sycl::id< 3 > SrcOffset, unsigned int SrcElemSize, char *DstMem, QueueImplPtr, unsigned int DimDst, sycl::range< 3 > DstSize, sycl::range< 3 > DstAccessRange, sycl::id< 3 > DstOffset, unsigned int DstElemSize, std::vector< RT::PiEvent > DepEvents, RT::PiEvent &OutEvent)
Definition: memory_manager.cpp:344
piEnqueueMemBufferFill
pi_result piEnqueueMemBufferFill(pi_queue command_queue, pi_mem buffer, const void *pattern, size_t pattern_size, size_t offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1250
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
PI_MEM_FLAGS_HOST_PTR_USE
constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_USE
Definition: pi.h:552
cl::sycl::detail::waitForEvents
static void waitForEvents(const std::vector< EventImplPtr > &Events)
Definition: memory_manager.cpp:23
cl::sycl::detail::plugin
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
Definition: plugin.hpp:89
piextUSMEnqueueMemset
pi_result piextUSMEnqueueMemset(pi_queue queue, void *ptr, pi_int32 value, size_t count, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
USM Memset API.
Definition: pi_esimd_emulator.cpp:1475
PI_MEM_FLAGS_ACCESS_RW
constexpr pi_mem_flags PI_MEM_FLAGS_ACCESS_RW
Definition: pi.h:549
piMemImageCreate
pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, const pi_image_format *image_format, const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem)
Definition: pi_esimd_emulator.cpp:883
_pi_image_format
Definition: pi.h:876
cl::sycl::detail::QueueImplPtr
std::shared_ptr< detail::queue_impl > QueueImplPtr
Definition: memory_manager.hpp:29
cl::sycl::detail::SYCLMemObjI::allocateHostMem
virtual void * allocateHostMem()=0
piEnqueueMemBufferMap
pi_result piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, pi_map_flags map_flags, size_t offset, size_t size, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event, void **ret_map)
Definition: pi_esimd_emulator.cpp:1256
cl::sycl::detail::SYCLMemObjI::allocateMem
virtual void * allocateMem(ContextImplPtr Context, bool InitFromUserData, void *HostPtr, RT::PiEvent &InteropEvent)=0
piEnqueueMemBufferRead
pi_result piEnqueueMemBufferRead(pi_queue queue, pi_mem buffer, pi_bool blocking_read, size_t offset, size_t size, void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1175
PI_INVALID_VALUE
@ PI_INVALID_VALUE
Definition: pi.h:87
piEnqueueEventsWait
pi_result piEnqueueEventsWait(pi_queue command_queue, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1165
piextUSMEnqueuePrefetch
pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, pi_usm_migration_flags flags, pi_uint32 num_events_in_waitlist, const pi_event *events_waitlist, pi_event *event)
Hint to migrate memory to the device.
Definition: pi_esimd_emulator.cpp:1521
PI_MEM_FLAGS_HOST_PTR_ALLOC
constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_ALLOC
Definition: pi.h:554
pi_buffer_region_struct
Definition: pi.h:792
_pi_image_desc
Definition: pi.h:881
piEventRetain
pi_result piEventRetain(pi_event event)
Definition: pi_esimd_emulator.cpp:1112
_pi_event
PI Event mapping to CUevent.
Definition: pi_cuda.hpp:419
piMemBufferCreate
pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, void *host_ptr, pi_mem *ret_mem, const pi_mem_properties *properties=nullptr)
Definition: pi_esimd_emulator.cpp:758
PI_MAP_WRITE_INVALIDATE_REGION
constexpr pi_map_flags PI_MAP_WRITE_INVALIDATE_REGION
Definition: pi.h:560
PI_BUFFER_CREATE_TYPE_REGION
@ PI_BUFFER_CREATE_TYPE_REGION
Definition: pi.h:483
piEnqueueMemBufferWriteRect
pi_result piEnqueueMemBufferWriteRect(pi_queue command_queue, pi_mem buffer, pi_bool blocking_write, pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset, pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, const void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1228
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:35
pi_image_offset_struct
Definition: pi.h:818
pi_image_region_struct
Definition: pi.h:827
_pi_usm_migration_flags
_pi_usm_migration_flags
Definition: pi.h:1588
cl::sycl::detail::TermPositions::ZTerm
int ZTerm
Definition: memory_manager.cpp:245
cl::sycl::access::mode
mode
Definition: access.hpp:28
cl::sycl::detail::TermPositions
Definition: memory_manager.cpp:242
piEnqueueMemImageCopy
pi_result piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image, pi_mem dst_image, pi_image_offset src_origin, pi_image_offset dst_origin, pi_image_region region, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1311
cl::sycl::ext::oneapi::property::buffer::use_pinned_host_memory
Definition: buffer_properties.hpp:61
cl::sycl::detail::plugin::reportPiError
void reportPiError(RT::PiResult pi_result, const char *context) const
Definition: plugin.hpp:120
piEnqueueMemImageWrite
pi_result piEnqueueMemImageWrite(pi_queue command_queue, pi_mem image, pi_bool blocking_write, pi_image_offset origin, pi_image_region region, size_t input_row_pitch, size_t input_slice_pitch, const void *ptr, pi_uint32 num_events_in_wait_list, const pi_event *event_wait_list, pi_event *event)
Definition: pi_esimd_emulator.cpp:1305
pi_map_flags
pi_bitfield pi_map_flags
Definition: pi.h:557
cl::sycl::detail::SYCLMemObjI
Definition: sycl_mem_obj_i.hpp:28
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12
cl::sycl::detail::SYCLMemObjI::releaseMem
virtual void releaseMem(ContextImplPtr Context, void *Ptr)=0
memory_manager.hpp