Skip to content
Closed
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
112 changes: 63 additions & 49 deletions include/ur_api.h

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,9 +1454,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) {
case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
os << "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR";
break;
case UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED:
os << "UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED";
break;
case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE:
os << "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE";
break;
Expand Down Expand Up @@ -5466,9 +5463,6 @@ inline ur_result_t printFlag<ur_mem_flag_t>(std::ostream &os, uint32_t flag) {
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value) {
switch (value) {
case UR_MEM_TYPE_BUFFER:
os << "UR_MEM_TYPE_BUFFER";
break;
case UR_MEM_TYPE_IMAGE2D:
os << "UR_MEM_TYPE_IMAGE2D";
break;
Expand All @@ -5484,9 +5478,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value) {
case UR_MEM_TYPE_IMAGE1D_ARRAY:
os << "UR_MEM_TYPE_IMAGE1D_ARRAY";
break;
case UR_MEM_TYPE_IMAGE1D_BUFFER:
os << "UR_MEM_TYPE_IMAGE1D_BUFFER";
break;
case UR_MEM_TYPE_IMAGE_CUBEMAP_EXP:
os << "UR_MEM_TYPE_IMAGE_CUBEMAP_EXP";
break;
Expand Down
2 changes: 0 additions & 2 deletions scripts/core/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ etors:
desc: "Invalid image size"
- name: ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR
desc: "Invalid image format descriptor"
- name: ERROR_IMAGE_FORMAT_NOT_SUPPORTED
desc: "Image format not supported"
- name: ERROR_MEM_OBJECT_ALLOCATION_FAILURE
desc: "Memory object allocation failure"
- name: ERROR_INVALID_PROGRAM_EXECUTABLE
Expand Down
10 changes: 5 additions & 5 deletions scripts/core/exp-bindless-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ returns:
- $X_RESULT_ERROR_INVALID_CONTEXT
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`"
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
- $X_RESULT_ERROR_INVALID_OPERATION
--- #--------------------------------------------------------------------------
Expand Down Expand Up @@ -442,7 +442,7 @@ returns:
- $X_RESULT_ERROR_INVALID_CONTEXT
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`"
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
- $X_RESULT_ERROR_INVALID_OPERATION
--- #--------------------------------------------------------------------------
Expand Down Expand Up @@ -479,7 +479,7 @@ returns:
- $X_RESULT_ERROR_INVALID_CONTEXT
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`"
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
- $X_RESULT_ERROR_INVALID_SAMPLER
- $X_RESULT_ERROR_INVALID_OPERATION
Expand Down Expand Up @@ -542,7 +542,7 @@ returns:
- $X_RESULT_ERROR_INVALID_QUEUE
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`"
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
- $X_RESULT_ERROR_INVALID_OPERATION
--- #--------------------------------------------------------------------------
Expand Down Expand Up @@ -679,7 +679,7 @@ returns:
- $X_RESULT_ERROR_INVALID_CONTEXT
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`"
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
- $X_RESULT_ERROR_INVALID_OPERATION
- $X_RESULT_ERROR_OUT_OF_RESOURCES
Expand Down
16 changes: 11 additions & 5 deletions scripts/core/memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ desc: "Memory types"
class: $xMem
name: $x_mem_type_t
etors:
- name: BUFFER
desc: "Buffer object"
- name: IMAGE2D
desc: "2D image object"
- name: IMAGE3D
Expand All @@ -53,8 +51,6 @@ etors:
desc: "1D image object"
- name: IMAGE1D_ARRAY
desc: "1D image array object"
- name: IMAGE1D_BUFFER
desc: "1D image buffer object"
--- #--------------------------------------------------------------------------
type: enum
desc: "Memory Information type"
Expand Down Expand Up @@ -213,6 +209,15 @@ name: ImageCreate
ordinal: "0"
analogue:
- "**clCreateImage**"
details:
- |
The primary $x_image_format_t that must be supported by all the adapters are {UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_UNORM_INT8},
{UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_UNORM_INT16}, {UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_SNORM_INT8},
{UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_SNORM_INT16}, {UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8},
{UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16}, {UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32},
{UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8}, {UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16},
{UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32}, {UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT},
{UR_IMAGE_CHANNEL_ORDER_RGBA, UR_IMAGE_CHANNEL_TYPE_FLOAT}.
params:
- type: $x_context_handle_t
name: hContext
Expand All @@ -236,12 +241,13 @@ returns:
- $X_RESULT_ERROR_INVALID_CONTEXT
- $X_RESULT_ERROR_INVALID_VALUE
- $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR:
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_BUFFER < pImageDesc->type`"
- "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`"
- $X_RESULT_ERROR_INVALID_IMAGE_SIZE
- $X_RESULT_ERROR_INVALID_OPERATION
- $X_RESULT_ERROR_INVALID_HOST_PTR:
- "`pHost == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0`"
- "`pHost != NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) == 0`"
- $X_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
- $X_RESULT_ERROR_OUT_OF_RESOURCES
--- #--------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ur_result_t urCalculateNumChannels(ur_image_channel_order_t order,
*NumChannels = 2;
return UR_RESULT_SUCCESS;
case ur_image_channel_order_t::UR_IMAGE_CHANNEL_ORDER_RGB:
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
case ur_image_channel_order_t::UR_IMAGE_CHANNEL_ORDER_RGBA:
case ur_image_channel_order_t::UR_IMAGE_CHANNEL_ORDER_ARGB:
case ur_image_channel_order_t::UR_IMAGE_CHANNEL_ORDER_BGRA:
Expand All @@ -49,7 +49,7 @@ ur_result_t urCalculateNumChannels(ur_image_channel_order_t order,
case ur_image_channel_order_t::UR_IMAGE_CHANNEL_ORDER_INTENSITY:
case ur_image_channel_order_t::UR_IMAGE_CHANNEL_ORDER_LUMINANCE:
default:
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
}
}

Expand Down Expand Up @@ -147,7 +147,7 @@ urToCudaImageChannelFormat(ur_image_channel_type_t image_channel_type,
cuda_format = cuda_format_and_size.first;
pixel_size_bytes = cuda_format_and_size.second;
} catch (const std::out_of_range &) {
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
}
}

Expand Down Expand Up @@ -228,7 +228,7 @@ cudaToUrImageChannelFormat(CUarray_format cuda_format,
#endif
#undef MAP
default:
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
}
}

Expand Down
7 changes: 5 additions & 2 deletions source/adapters/cuda/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(

UR_ASSERT(pImageDesc->stype == UR_STRUCTURE_TYPE_IMAGE_DESC,
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_BUFFER,
UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_ARRAY,
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
UR_ASSERT(pImageDesc->numMipLevel == 0,
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
Expand All @@ -227,11 +227,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(
// We only support RBGA channel order
// TODO: check SYCL CTS and spec. May also have to support BGRA
UR_ASSERT(pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGBA,
UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT);

auto URMemObj = std::unique_ptr<ur_mem_handle_t_>(
new ur_mem_handle_t_{hContext, flags, *pImageFormat, *pImageDesc, pHost});

UR_ASSERT(std::get<SurfaceMem>(URMemObj->Mem).PixelTypeSizeBytes,
UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT);

try {
if (PerformInitialCopy) {
for (const auto &Device : hContext->getDevices()) {
Expand Down
6 changes: 4 additions & 2 deletions source/adapters/cuda/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct SurfaceMem {
CUDA_ARRAY3D_DESCRIPTOR ArrayDesc;
size_t PixelTypeSizeBytes;
void *HostPtr;
ur_result_t error = UR_RESULT_SUCCESS;

SurfaceMem(ur_context_handle_t Context, ur_mem_handle_t OuterMemStruct,
ur_image_format_t ImageFormat, ur_image_desc_t ImageDesc,
Expand Down Expand Up @@ -219,6 +220,7 @@ struct SurfaceMem {
ArrayDesc.Format = CU_AD_FORMAT_UNSIGNED_INT8;
PixelTypeSizeBytes = 1;
break;
case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8:
ArrayDesc.Format = CU_AD_FORMAT_SIGNED_INT8;
PixelTypeSizeBytes = 1;
Expand All @@ -228,6 +230,7 @@ struct SurfaceMem {
ArrayDesc.Format = CU_AD_FORMAT_UNSIGNED_INT16;
PixelTypeSizeBytes = 2;
break;
case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16:
ArrayDesc.Format = CU_AD_FORMAT_SIGNED_INT16;
PixelTypeSizeBytes = 2;
Expand All @@ -249,8 +252,7 @@ struct SurfaceMem {
PixelTypeSizeBytes = 4;
break;
default:
detail::ur::die(
"urMemImageCreate given unsupported image_channel_data_type");
break;
}
}

Expand Down
28 changes: 26 additions & 2 deletions source/adapters/hip/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ size_t imageElementByteSize(hipArray_Format ArrayFormat) {
return 0;
}

ur_result_t
checkSupportedImageChannelType(ur_image_channel_type_t ImageChannelType) {
switch (ImageChannelType) {
case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8:
case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16:
case UR_IMAGE_CHANNEL_TYPE_UNORM_INT8:
case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8:
case UR_IMAGE_CHANNEL_TYPE_UNORM_INT16:
case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16:
case UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT:
case UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32:
case UR_IMAGE_CHANNEL_TYPE_FLOAT:
return UR_RESULT_SUCCESS;
default:
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
}
return UR_RESULT_SUCCESS;
}

/// Decreases the reference count of the Mem object.
/// If this is zero, calls the relevant HIP Free function
/// \return UR_RESULT_SUCCESS unless deallocation error
Expand Down Expand Up @@ -339,7 +361,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(

UR_ASSERT(pImageDesc->stype == UR_STRUCTURE_TYPE_IMAGE_DESC,
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_BUFFER,
UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_ARRAY,
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
UR_ASSERT(pImageDesc->numMipLevel == 0,
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
Expand All @@ -355,7 +377,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(
// We only support RBGA channel order
// TODO: check SYCL CTS and spec. May also have to support BGRA
UR_ASSERT(pImageFormat->channelOrder == UR_IMAGE_CHANNEL_ORDER_RGBA,
UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT);

UR_CHECK_ERROR(checkSupportedImageChannelType(pImageFormat->channelType));

auto URMemObj = std::unique_ptr<ur_mem_handle_t_>(
new ur_mem_handle_t_{hContext, flags, *pImageFormat, *pImageDesc, pHost});
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/hip/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ struct SurfaceMem {
ArrayDesc.Format = HIP_AD_FORMAT_UNSIGNED_INT8;
PixelTypeSizeBytes = 1;
break;
case UR_IMAGE_CHANNEL_TYPE_SNORM_INT8:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8:
ArrayDesc.Format = HIP_AD_FORMAT_SIGNED_INT8;
PixelTypeSizeBytes = 1;
Expand All @@ -219,6 +220,7 @@ struct SurfaceMem {
ArrayDesc.Format = HIP_AD_FORMAT_UNSIGNED_INT16;
PixelTypeSizeBytes = 2;
break;
case UR_IMAGE_CHANNEL_TYPE_SNORM_INT16:
case UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16:
ArrayDesc.Format = HIP_AD_FORMAT_SIGNED_INT16;
PixelTypeSizeBytes = 2;
Expand Down
Loading