@@ -23,12 +23,11 @@ uint8_t GImageStreamID;
2323#endif
2424
2525template <typename Param>
26- static bool checkImageValueRange (const std::vector<device> &Devices,
27- const size_t Value) {
28- return Value >= 1 && std::all_of (Devices.cbegin (), Devices.cend (),
29- [Value](const device &Dev) {
30- return Value <= Dev.get_info <Param>();
31- });
26+ static bool checkImageValueRange (devices_range Devices, const size_t Value) {
27+ return Value >= 1 &&
28+ std::all_of (Devices.begin (), Devices.end (), [Value](device_impl &Dev) {
29+ return Value <= Dev.get_info <Param>();
30+ });
3231}
3332
3433template <typename T, typename ... Args> static bool checkAnyImpl (T) {
@@ -345,46 +344,47 @@ void *image_impl::allocateMem(context_impl *Context, bool InitFromUserData,
345344
346345bool image_impl::checkImageDesc (const ur_image_desc_t &Desc,
347346 context_impl *Context, void *UserPtr) {
347+ devices_range Devices = Context ? Context->getDevices () : devices_range{};
348348 if (checkAny (Desc.type , UR_MEM_TYPE_IMAGE1D, UR_MEM_TYPE_IMAGE1D_ARRAY,
349349 UR_MEM_TYPE_IMAGE2D_ARRAY, UR_MEM_TYPE_IMAGE2D) &&
350- !checkImageValueRange<info::device::image2d_max_width>(
351- getDevices (Context), Desc.width ))
350+ !checkImageValueRange<info::device::image2d_max_width>(Devices,
351+ Desc.width ))
352352 throw exception (make_error_code (errc::invalid),
353353 " For a 1D/2D image/image array, the width must be a Value "
354354 " >= 1 and <= info::device::image2d_max_width" );
355355
356356 if (checkAny (Desc.type , UR_MEM_TYPE_IMAGE3D) &&
357- !checkImageValueRange<info::device::image3d_max_width>(
358- getDevices (Context), Desc.width ))
357+ !checkImageValueRange<info::device::image3d_max_width>(Devices,
358+ Desc.width ))
359359 throw exception (make_error_code (errc::invalid),
360360 " For a 3D image, the width must be a Value >= 1 and <= "
361361 " info::device::image3d_max_width" );
362362
363363 if (checkAny (Desc.type , UR_MEM_TYPE_IMAGE2D, UR_MEM_TYPE_IMAGE2D_ARRAY) &&
364- !checkImageValueRange<info::device::image2d_max_height>(
365- getDevices (Context), Desc.height ))
364+ !checkImageValueRange<info::device::image2d_max_height>(Devices,
365+ Desc.height ))
366366 throw exception (make_error_code (errc::invalid),
367367 " For a 2D image or image array, the height must be a Value "
368368 " >= 1 and <= info::device::image2d_max_height" );
369369
370370 if (checkAny (Desc.type , UR_MEM_TYPE_IMAGE3D) &&
371- !checkImageValueRange<info::device::image3d_max_height>(
372- getDevices (Context), Desc.height ))
371+ !checkImageValueRange<info::device::image3d_max_height>(Devices,
372+ Desc.height ))
373373 throw exception (make_error_code (errc::invalid),
374374 " For a 3D image, the heightmust be a Value >= 1 and <= "
375375 " info::device::image3d_max_height" );
376376
377377 if (checkAny (Desc.type , UR_MEM_TYPE_IMAGE3D) &&
378- !checkImageValueRange<info::device::image3d_max_depth>(
379- getDevices (Context), Desc.depth ))
378+ !checkImageValueRange<info::device::image3d_max_depth>(Devices,
379+ Desc.depth ))
380380 throw exception (make_error_code (errc::invalid),
381381 " For a 3D image, the depth must be a Value >= 1 and <= "
382382 " info::device::image2d_max_depth" );
383383
384384 if (checkAny (Desc.type , UR_MEM_TYPE_IMAGE1D_ARRAY,
385385 UR_MEM_TYPE_IMAGE2D_ARRAY) &&
386- !checkImageValueRange<info::device::image_max_array_size>(
387- getDevices (Context), Desc.arraySize ))
386+ !checkImageValueRange<info::device::image_max_array_size>(Devices,
387+ Desc.arraySize ))
388388 throw exception (make_error_code (errc::invalid),
389389 " For a 1D and 2D image array, the array_size must be a "
390390 " Value >= 1 and <= info::device::image_max_array_size." );
@@ -451,12 +451,6 @@ bool image_impl::checkImageFormat(const ur_image_format_t &Format,
451451 return true ;
452452}
453453
454- std::vector<device> image_impl::getDevices (context_impl *Context) {
455- if (!Context)
456- return {};
457- return Context->get_info <info::context::devices>();
458- }
459-
460454void image_impl::sampledImageConstructorNotification (
461455 const detail::code_location &CodeLoc, void *UserObj, const void *HostObj,
462456 uint32_t Dim, size_t Range[3 ], image_format Format,
0 commit comments