Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,32 +455,40 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(

// Allocate a cuArray
if (pImageDesc->numMipLevel == 1) {
CUarray ImageArray;
CUarray ImageArray{};

try {
UR_CHECK_ERROR(cuArray3DCreate(&ImageArray, &array_desc));
*phImageMem = (ur_exp_image_mem_native_handle_t)ImageArray;
} catch (ur_result_t Err) {
cuArrayDestroy(ImageArray);
if (ImageArray != CUarray{}) {
UR_CHECK_ERROR(cuArrayDestroy(ImageArray));
}
return Err;
} catch (...) {
cuArrayDestroy(ImageArray);
if (ImageArray != CUarray{}) {
UR_CHECK_ERROR(cuArrayDestroy(ImageArray));
}
return UR_RESULT_ERROR_UNKNOWN;
}
} else // Allocate a cuMipmappedArray
{
CUmipmappedArray mip_array;
CUmipmappedArray mip_array{};
array_desc.Flags = CUDA_ARRAY3D_SURFACE_LDST;

try {
UR_CHECK_ERROR(cuMipmappedArrayCreate(&mip_array, &array_desc,
pImageDesc->numMipLevel));
*phImageMem = (ur_exp_image_mem_native_handle_t)mip_array;
} catch (ur_result_t Err) {
cuMipmappedArrayDestroy(mip_array);
if (mip_array) {
UR_CHECK_ERROR(cuMipmappedArrayDestroy(mip_array));
}
return Err;
} catch (...) {
cuMipmappedArrayDestroy(mip_array);
if (mip_array) {
UR_CHECK_ERROR(cuMipmappedArrayDestroy(mip_array));
}
return UR_RESULT_ERROR_UNKNOWN;
}
}
Expand Down
6 changes: 3 additions & 3 deletions source/adapters/cuda/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ ur_result_t allocateMemObjOnDeviceIfNeeded(ur_mem_handle_t Mem,
UR_CHECK_ERROR(cuMemAlloc(&DevPtr, Buffer.Size));
}
} else {
CUarray ImageArray;
CUarray ImageArray{};
CUsurfObject Surface;
try {
auto &Image = std::get<SurfaceMem>(Mem->Mem);
Expand All @@ -465,12 +465,12 @@ ur_result_t allocateMemObjOnDeviceIfNeeded(ur_mem_handle_t Mem,
UR_CHECK_ERROR(cuSurfObjectCreate(&Surface, &ImageResDesc));
Image.SurfObjs[DeviceIdx] = Surface;
} catch (ur_result_t Err) {
if (ImageArray) {
if (ImageArray != CUarray{}) {
UR_CHECK_ERROR(cuArrayDestroy(ImageArray));
}
return Err;
} catch (...) {
if (ImageArray) {
if (ImageArray != CUarray{}) {
UR_CHECK_ERROR(cuArrayDestroy(ImageArray));
}
return UR_RESULT_ERROR_UNKNOWN;
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/hip/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ ur_result_t allocateMemObjOnDeviceIfNeeded(ur_mem_handle_t Mem,
UR_CHECK_ERROR(hipMalloc(&DevPtr, Buffer.Size));
}
} else {
hipArray *ImageArray;
hipArray *ImageArray{};
hipSurfaceObject_t Surface;
try {
auto &Image = std::get<SurfaceMem>(Mem->Mem);
Expand Down