Skip to content

Commit

Permalink
sort image formats before printing (#101)
Browse files Browse the repository at this point in the history
Sorting the queried image formats can make it easier to diff results
across drivers and devices.
  • Loading branch information
bashbaug authored Jan 17, 2024
1 parent fa3f959 commit e79d724
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions samples/images/00_enumimageformats/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <CL/opencl.hpp>

#include <algorithm>

#define CASE_TO_STRING(_e) case _e: return #_e;

const char* mem_object_type_to_string(cl_mem_object_type mem_object_type)
Expand Down Expand Up @@ -200,6 +202,13 @@ int main(
std::vector<cl::ImageFormat> imageFormats;
context.getSupportedImageFormats( imageAccess, imageType, &imageFormats );

std::sort(std::begin(imageFormats), std::end(imageFormats),
[](cl::ImageFormat a, cl::ImageFormat b) {
return a.image_channel_order < b.image_channel_order ||
(a.image_channel_order == b.image_channel_data_type &&
a.image_channel_data_type < b.image_channel_data_type);
});

printf("\nFor image access %s (%04X), image type %s (%04X):\n",
mem_flags_to_string(imageAccess),
(cl_uint)imageAccess,
Expand Down

0 comments on commit e79d724

Please sign in to comment.