@@ -379,6 +379,35 @@ void *OneapiDevice::kernel_globals_device_pointer()
379
379
return kg_memory_device_;
380
380
}
381
381
382
+ void *OneapiDevice::host_alloc (const MemoryType type, const size_t size)
383
+ {
384
+ void *host_pointer = GPUDevice::host_alloc (type, size);
385
+
386
+ # ifdef SYCL_EXT_ONEAPI_COPY_OPTIMIZE
387
+ if (host_pointer) {
388
+ /* Import host_pointer into USM memory for faster host<->device data transfers. */
389
+ if (type == MEM_READ_WRITE || type == MEM_READ_ONLY) {
390
+ sycl::queue *queue = reinterpret_cast <sycl::queue *>(device_queue_);
391
+ sycl::ext::oneapi::experimental::prepare_for_device_copy (host_pointer, size, *queue);
392
+ }
393
+ }
394
+ # endif
395
+
396
+ return host_pointer;
397
+ }
398
+
399
+ void OneapiDevice::host_free (const MemoryType type, void *host_pointer, const size_t size)
400
+ {
401
+ # ifdef SYCL_EXT_ONEAPI_COPY_OPTIMIZE
402
+ if (type == MEM_READ_WRITE || type == MEM_READ_ONLY) {
403
+ sycl::queue *queue = reinterpret_cast <sycl::queue *>(device_queue_);
404
+ sycl::ext::oneapi::experimental::release_from_device_copy (host_pointer, *queue);
405
+ }
406
+ # endif
407
+
408
+ GPUDevice::host_free (type, host_pointer, size);
409
+ }
410
+
382
411
void OneapiDevice::mem_alloc (device_memory &mem)
383
412
{
384
413
if (mem.type == MEM_TEXTURE) {
@@ -394,14 +423,6 @@ void OneapiDevice::mem_alloc(device_memory &mem)
394
423
<< string_human_readable_size (mem.memory_size ()) << " )" ;
395
424
}
396
425
generic_alloc (mem);
397
- # ifdef SYCL_EXT_ONEAPI_COPY_OPTIMIZE
398
- /* Import host_pointer into USM memory for faster host<->device data transfers. */
399
- if (mem.type == MEM_READ_WRITE || mem.type == MEM_READ_ONLY) {
400
- sycl::queue *queue = reinterpret_cast <sycl::queue *>(device_queue_);
401
- sycl::ext::oneapi::experimental::prepare_for_device_copy (
402
- mem.host_pointer , mem.memory_size (), *queue);
403
- }
404
- # endif
405
426
}
406
427
}
407
428
@@ -543,12 +564,6 @@ void OneapiDevice::mem_free(device_memory &mem)
543
564
tex_free ((device_texture &)mem);
544
565
}
545
566
else {
546
- # ifdef SYCL_EXT_ONEAPI_COPY_OPTIMIZE
547
- if (mem.type == MEM_READ_WRITE || mem.type == MEM_READ_ONLY) {
548
- sycl::queue *queue = reinterpret_cast <sycl::queue *>(device_queue_);
549
- sycl::ext::oneapi::experimental::release_from_device_copy (mem.host_pointer , *queue);
550
- }
551
- # endif
552
567
generic_free (mem);
553
568
}
554
569
}
0 commit comments