Skip to content

Commit 5e914c5

Browse files
authored
Merge pull request #1088 from hdelan/ifdef-hip-5.6
[HIP] Ifdef entry point introduced in HIP 5.6
2 parents 41228d3 + f6c476d commit 5e914c5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

source/adapters/hip/memory.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(ur_mem_handle_t hMemory,
273273
UR_CHECK_ERROR(hipMemGetAddressRange(&BasePtr, &AllocSize, Mem.Ptr));
274274
return AllocSize;
275275
} else if constexpr (std::is_same_v<T, SurfaceMem>) {
276+
#if HIP_VERSION < 50600000
277+
throw UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
278+
#else
276279
HIP_ARRAY3D_DESCRIPTOR ArrayDescriptor;
277-
UR_CHECK_ERROR(hipArray3DGetDescriptor(&ArrayDescriptor, Mem.Array));
280+
UR_CHECK_ERROR(
281+
hipArray3DGetDescriptor(&ArrayDescriptor, Mem.getArray()));
278282
const auto PixelSizeBytes =
279283
GetHipFormatPixelSize(ArrayDescriptor.Format) *
280284
ArrayDescriptor.NumChannels;
@@ -284,6 +288,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(ur_mem_handle_t hMemory,
284288
(ArrayDescriptor.Height ? ArrayDescriptor.Height : 1) *
285289
(ArrayDescriptor.Depth ? ArrayDescriptor.Depth : 1);
286290
return ImageSizeBytes;
291+
#endif
287292
} else {
288293
static_assert(ur_always_false_t<T>, "Not exhaustive visitor!");
289294
}
@@ -535,10 +540,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
535540
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
536541

537542
try {
538-
539543
HIP_ARRAY3D_DESCRIPTOR ArrayInfo;
544+
#if HIP_VERSION >= 50600000
540545
UR_CHECK_ERROR(hipArray3DGetDescriptor(
541-
&ArrayInfo, std::get<SurfaceMem>(hMemory->Mem).Array));
546+
&ArrayInfo, std::get<SurfaceMem>(hMemory->Mem).getArray()));
547+
#else
548+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
549+
#endif
542550

543551
const auto hip2urFormat =
544552
[](hipArray_Format HipFormat) -> ur_image_channel_type_t {

0 commit comments

Comments
 (0)