Skip to content

Commit

Permalink
Enable creation of bindless images backed by host USM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
przemektmalon committed Jan 23, 2025
1 parent d3e9704 commit eeff9f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
image_res_desc.resType = CU_RESOURCE_TYPE_MIPMAPPED_ARRAY;
image_res_desc.res.mipmap.hMipmappedArray = (CUmipmappedArray)hImageMem;
}
} else if (mem_type == CU_MEMORYTYPE_DEVICE) {
// We have a USM pointer
} else if (mem_type == CU_MEMORYTYPE_DEVICE ||
mem_type == CU_MEMORYTYPE_HOST) {
// We have a USM pointer.
// Images may be created from device or host USM.
if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D) {
image_res_desc.resType = CU_RESOURCE_TYPE_LINEAR;
image_res_desc.res.linear.devPtr = (CUdeviceptr)hImageMem;
Expand Down

0 comments on commit eeff9f4

Please sign in to comment.