Skip to content

Commit eeff9f4

Browse files
committed
Enable creation of bindless images backed by host USM
Small patch to enable bindless images backed by host USM in the CUDA adapter. Host and Device USM pointers are usable across the host and device for all versions of CUDA that we support. There is no need to provide the `CU_MEMHOSTALLOC_DEVICEMAP` flag during allocation, or calling `cuMemHostGetDevicePointer` to retrieve a device usable address. Passing a `CU_MEMHOSTALLOC_WRITECOMBINED` flag to the host USM allocation will enhance performance in certain scenarios, however, an extension allowing this is not yet available.
1 parent d3e9704 commit eeff9f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/adapters/cuda/image.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
533533
image_res_desc.resType = CU_RESOURCE_TYPE_MIPMAPPED_ARRAY;
534534
image_res_desc.res.mipmap.hMipmappedArray = (CUmipmappedArray)hImageMem;
535535
}
536-
} else if (mem_type == CU_MEMORYTYPE_DEVICE) {
537-
// We have a USM pointer
536+
} else if (mem_type == CU_MEMORYTYPE_DEVICE ||
537+
mem_type == CU_MEMORYTYPE_HOST) {
538+
// We have a USM pointer.
539+
// Images may be created from device or host USM.
538540
if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D) {
539541
image_res_desc.resType = CU_RESOURCE_TYPE_LINEAR;
540542
image_res_desc.res.linear.devPtr = (CUdeviceptr)hImageMem;

0 commit comments

Comments
 (0)