Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Move urMemImageGetInfo success test from a switch to individual test" #2613

Merged
merged 1 commit into from
Jan 24, 2025
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
10 changes: 2 additions & 8 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -3324,12 +3324,6 @@ typedef enum ur_image_info_t {
UR_IMAGE_INFO_HEIGHT = 5,
/// [size_t] image depth
UR_IMAGE_INFO_DEPTH = 6,
/// [size_t] array size
UR_IMAGE_INFO_ARRAY_SIZE = 7,
/// [uint32_t] number of MIP levels
UR_IMAGE_INFO_NUM_MIP_LEVELS = 8,
/// [uint32_t] number of samples
UR_IMAGE_INFO_NUM_SAMPLES = 9,
/// @cond
UR_IMAGE_INFO_FORCE_UINT32 = 0x7fffffff
/// @endcond
Expand Down Expand Up @@ -3843,7 +3837,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hMemory`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_IMAGE_INFO_NUM_SAMPLES < propName`
/// + `::UR_IMAGE_INFO_DEPTH < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down Expand Up @@ -9505,7 +9499,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_IMAGE_INFO_NUM_SAMPLES < propName`
/// + `::UR_IMAGE_INFO_DEPTH < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
48 changes: 0 additions & 48 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6466,15 +6466,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_image_info_t value) {
case UR_IMAGE_INFO_DEPTH:
os << "UR_IMAGE_INFO_DEPTH";
break;
case UR_IMAGE_INFO_ARRAY_SIZE:
os << "UR_IMAGE_INFO_ARRAY_SIZE";
break;
case UR_IMAGE_INFO_NUM_MIP_LEVELS:
os << "UR_IMAGE_INFO_NUM_MIP_LEVELS";
break;
case UR_IMAGE_INFO_NUM_SAMPLES:
os << "UR_IMAGE_INFO_NUM_SAMPLES";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -6583,45 +6574,6 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,

os << ")";
} break;
case UR_IMAGE_INFO_ARRAY_SIZE: {
const size_t *tptr = (const size_t *)ptr;
if (sizeof(size_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(size_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_IMAGE_INFO_NUM_MIP_LEVELS: {
const uint32_t *tptr = (const uint32_t *)ptr;
if (sizeof(uint32_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_IMAGE_INFO_NUM_SAMPLES: {
const uint32_t *tptr = (const uint32_t *)ptr;
if (sizeof(uint32_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
default:
os << "unknown enumerator";
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down
6 changes: 0 additions & 6 deletions scripts/core/memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ etors:
desc: "[size_t] image height"
- name: DEPTH
desc: "[size_t] image depth"
- name: ARRAY_SIZE
desc: "[size_t] array size"
- name: NUM_MIP_LEVELS
desc: "[uint32_t] number of MIP levels"
- name: NUM_SAMPLES
desc: "[uint32_t] number of samples"
--- #--------------------------------------------------------------------------
type: struct
desc: "Image format including channel layout and data type"
Expand Down
99 changes: 0 additions & 99 deletions source/adapters/opencl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,92 +10,6 @@

#include "common.hpp"

#include <unordered_map>

const std::unordered_map<ur_image_channel_order_t, cl_channel_order>
ChannelOrderMap = {
{UR_IMAGE_CHANNEL_ORDER_A, CL_A},
{UR_IMAGE_CHANNEL_ORDER_R, CL_R},
{UR_IMAGE_CHANNEL_ORDER_RG, CL_RG},
{UR_IMAGE_CHANNEL_ORDER_RA, CL_RA},
{UR_IMAGE_CHANNEL_ORDER_RGB, CL_RGB},
{UR_IMAGE_CHANNEL_ORDER_RGBA, CL_RGBA},
{UR_IMAGE_CHANNEL_ORDER_BGRA, CL_BGRA},
{UR_IMAGE_CHANNEL_ORDER_ARGB, CL_ARGB},
{UR_IMAGE_CHANNEL_ORDER_ABGR, CL_ABGR},
{UR_IMAGE_CHANNEL_ORDER_INTENSITY, CL_INTENSITY},
{UR_IMAGE_CHANNEL_ORDER_LUMINANCE, CL_LUMINANCE},
{UR_IMAGE_CHANNEL_ORDER_RX, CL_Rx},
{UR_IMAGE_CHANNEL_ORDER_RGX, CL_RGx},
{UR_IMAGE_CHANNEL_ORDER_RGBX, CL_RGBx},
{UR_IMAGE_CHANNEL_ORDER_SRGBA, CL_sRGBA},
};

const std::unordered_map<ur_image_channel_type_t, cl_channel_type>
ChannelTypeMap = {
{UR_IMAGE_CHANNEL_TYPE_SNORM_INT8, CL_SNORM_INT8},
{UR_IMAGE_CHANNEL_TYPE_SNORM_INT16, CL_SNORM_INT16},
{UR_IMAGE_CHANNEL_TYPE_UNORM_INT8, CL_UNORM_INT8},
{UR_IMAGE_CHANNEL_TYPE_UNORM_INT16, CL_UNORM_INT16},
{UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565, CL_UNORM_SHORT_565},
{UR_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555, CL_UNORM_SHORT_555},
{UR_IMAGE_CHANNEL_TYPE_INT_101010, CL_UNORM_INT_101010},
{UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8, CL_SIGNED_INT8},
{UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16, CL_SIGNED_INT16},
{UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32, CL_SIGNED_INT32},
{UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8, CL_UNSIGNED_INT8},
{UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16, CL_UNSIGNED_INT16},
{UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32, CL_UNSIGNED_INT32},
{UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT, CL_HALF_FLOAT},
{UR_IMAGE_CHANNEL_TYPE_FLOAT, CL_FLOAT},
};

cl_image_format mapURImageFormatToCL(const ur_image_format_t &PImageFormat) {
cl_image_format CLImageFormat = {UR_IMAGE_CHANNEL_ORDER_FORCE_UINT32,
UR_IMAGE_CHANNEL_TYPE_FORCE_UINT32};

auto channelOrderIt = ChannelOrderMap.find(PImageFormat.channelOrder);
if (channelOrderIt != ChannelOrderMap.end()) {
CLImageFormat.image_channel_order = channelOrderIt->second;
}

auto channelTypeIt = ChannelTypeMap.find(PImageFormat.channelType);
if (channelTypeIt != ChannelTypeMap.end()) {
CLImageFormat.image_channel_data_type = channelTypeIt->second;
}

return CLImageFormat;
}

ur_image_format_t mapCLImageFormatToUR(const cl_image_format *PImageFormat) {
ur_image_format_t URImageFormat = {UR_IMAGE_CHANNEL_ORDER_FORCE_UINT32,
UR_IMAGE_CHANNEL_TYPE_FORCE_UINT32};

auto reverseChannelOrderIt =
std::find_if(ChannelOrderMap.begin(), ChannelOrderMap.end(),
[PImageFormat](const auto &pair) {
return pair.second == PImageFormat->image_channel_order;
});
if (reverseChannelOrderIt != ChannelOrderMap.end()) {
URImageFormat.channelOrder = reverseChannelOrderIt->first;
}

URImageFormat.channelOrder = (reverseChannelOrderIt != ChannelOrderMap.end())
? reverseChannelOrderIt->first
: UR_IMAGE_CHANNEL_ORDER_FORCE_UINT32;

auto reverseChannelTypeIt = std::find_if(
ChannelTypeMap.begin(), ChannelTypeMap.end(),
[PImageFormat](const auto &pair) {
return pair.second == PImageFormat->image_channel_data_type;
});
if (reverseChannelTypeIt != ChannelTypeMap.end()) {
URImageFormat.channelType = reverseChannelTypeIt->first;
}

return URImageFormat;
}

cl_image_format mapURImageFormatToCL(const ur_image_format_t *PImageFormat) {
cl_image_format CLImageFormat;
switch (PImageFormat->channelOrder) {
Expand Down Expand Up @@ -260,12 +174,6 @@ cl_int mapURMemImageInfoToCL(ur_image_info_t URPropName) {
return CL_IMAGE_HEIGHT;
case UR_IMAGE_INFO_DEPTH:
return CL_IMAGE_DEPTH;
case UR_IMAGE_INFO_ARRAY_SIZE:
return CL_IMAGE_ARRAY_SIZE;
case UR_IMAGE_INFO_NUM_MIP_LEVELS:
return CL_IMAGE_NUM_MIP_LEVELS;
case UR_IMAGE_INFO_NUM_SAMPLES:
return CL_IMAGE_NUM_SAMPLES;
default:
return -1;
}
Expand Down Expand Up @@ -489,14 +397,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
CL_RETURN_ON_FAILURE(ClResult);
if (pPropSizeRet) {
*pPropSizeRet = CheckPropSize;
} else {
if (propName == UR_IMAGE_INFO_FORMAT) {
ur_image_format_t format = mapCLImageFormatToUR(
reinterpret_cast<const cl_image_format *>(pPropValue));
return ReturnValue(format);
}
}

return UR_RESULT_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ __urdlllocal ur_result_t UR_APICALL urMemImageGetInfo(
if (pPropValue == NULL && pPropSizeRet == NULL)
return UR_RESULT_ERROR_INVALID_NULL_POINTER;

if (UR_IMAGE_INFO_NUM_SAMPLES < propName)
if (UR_IMAGE_INFO_DEPTH < propName)
return UR_RESULT_ERROR_INVALID_ENUMERATION;

if (propSize == 0 && pPropValue != NULL)
Expand Down Expand Up @@ -7069,7 +7069,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
if (pPropValue == NULL && pPropSizeRet == NULL)
return UR_RESULT_ERROR_INVALID_NULL_POINTER;

if (UR_IMAGE_INFO_NUM_SAMPLES < propName)
if (UR_IMAGE_INFO_DEPTH < propName)
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

Expand Down
4 changes: 2 additions & 2 deletions source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,7 @@ ur_result_t UR_APICALL urMemGetInfo(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hMemory`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_IMAGE_INFO_NUM_SAMPLES < propName`
/// + `::UR_IMAGE_INFO_DEPTH < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down Expand Up @@ -7120,7 +7120,7 @@ ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_IMAGE_INFO_NUM_SAMPLES < propName`
/// + `::UR_IMAGE_INFO_DEPTH < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
4 changes: 2 additions & 2 deletions source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ ur_result_t UR_APICALL urMemGetInfo(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hMemory`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_IMAGE_INFO_NUM_SAMPLES < propName`
/// + `::UR_IMAGE_INFO_DEPTH < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down Expand Up @@ -6249,7 +6249,7 @@ ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_IMAGE_INFO_NUM_SAMPLES < propName`
/// + `::UR_IMAGE_INFO_DEPTH < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
Loading
Loading