From 17af7935544898c08331045c392678f639c00c1f Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Mon, 7 Jul 2025 10:25:49 +0100 Subject: [PATCH 1/2] [UR][CTS] Spec wording around `PROGRAM_INFO_BINARIES` and test The wording of the spec was a bit confusing, so it has been clarified. The conformance test was also updated to be more robust, which unfortunately exposes failures in HIP and Cuda. --- unified-runtime/include/ur_api.h | 4 ++-- unified-runtime/include/ur_print.hpp | 2 +- unified-runtime/scripts/core/program.yml | 2 +- .../test/conformance/program/urProgramGetInfo.cpp | 9 +++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index 6b996c1a4ebb..8a2dc3afce9b 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -5779,8 +5779,8 @@ typedef enum ur_program_info_t { UR_PROGRAM_INFO_IL = 4, /// [size_t[]] Return program binary sizes for each device. UR_PROGRAM_INFO_BINARY_SIZES = 5, - /// [unsigned char[]] Return program binaries for all devices for this - /// Program. These are not null-terminated. + /// [unsigned char *[]] Write program binaries into caller-provided + /// buffers for each device. These are not null-terminated. UR_PROGRAM_INFO_BINARIES = 6, /// [size_t][optional-query] Number of kernels in Program, return type /// size_t. diff --git a/unified-runtime/include/ur_print.hpp b/unified-runtime/include/ur_print.hpp index ddf0af88ebbe..071c0bc416f3 100644 --- a/unified-runtime/include/ur_print.hpp +++ b/unified-runtime/include/ur_print.hpp @@ -9060,7 +9060,7 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, } break; case UR_PROGRAM_INFO_BINARIES: { - const unsigned char *tptr = (const unsigned char *)ptr; + const unsigned char **tptr = (const unsigned char **)ptr; printPtr(os, tptr); } break; case UR_PROGRAM_INFO_NUM_KERNELS: { diff --git a/unified-runtime/scripts/core/program.yml b/unified-runtime/scripts/core/program.yml index 807b06038bed..c6c2a9f83d3b 100644 --- a/unified-runtime/scripts/core/program.yml +++ b/unified-runtime/scripts/core/program.yml @@ -385,7 +385,7 @@ etors: - name: BINARY_SIZES desc: "[size_t[]] Return program binary sizes for each device." - name: BINARIES - desc: "[unsigned char[]] Return program binaries for all devices for this Program. These are not null-terminated." + desc: "[unsigned char *[]] Write program binaries into caller-provided buffers for each device. These are not null-terminated." - name: NUM_KERNELS desc: "[size_t][optional-query] Number of kernels in Program, return type size_t." - name: KERNEL_NAMES diff --git a/unified-runtime/test/conformance/program/urProgramGetInfo.cpp b/unified-runtime/test/conformance/program/urProgramGetInfo.cpp index 2a2d4ab234a8..27fda5c804f9 100644 --- a/unified-runtime/test/conformance/program/urProgramGetInfo.cpp +++ b/unified-runtime/test/conformance/program/urProgramGetInfo.cpp @@ -153,6 +153,10 @@ TEST_P(urProgramGetInfoTest, SuccessBinarySizes) { } TEST_P(urProgramGetInfoTest, SuccessBinaries) { + // Not implemented correctly on these targets - they copy their own pointer into the output rather than copying the + // binary + UUR_KNOWN_FAILURE_ON(uur::HIP{}, uur::CUDA{}); + size_t binary_sizes_len = 0; std::vector property_value(0); @@ -175,6 +179,11 @@ TEST_P(urProgramGetInfoTest, SuccessBinaries) { urProgramGetInfo(program, UR_PROGRAM_INFO_BINARIES, sizeof(binaries[0]), binaries, nullptr), UR_PROGRAM_INFO_BINARIES); + + // We assume that there is at least 1 non-zero byte in the binary + bool nonzero_found = std::any_of(property_value.begin(), property_value.end(), + [](char c) { return c != 0; }); + ASSERT_TRUE(nonzero_found); } TEST_P(urProgramGetInfoTest, SuccessNumKernels) { From 2d8c5636f20e67d18e4c2df086c8d1eaa709f18e Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Mon, 7 Jul 2025 12:10:45 +0100 Subject: [PATCH 2/2] Fix printing --- unified-runtime/include/ur_print.hpp | 2 +- unified-runtime/scripts/templates/print.hpp.mako | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unified-runtime/include/ur_print.hpp b/unified-runtime/include/ur_print.hpp index 071c0bc416f3..f0e7e96c23ee 100644 --- a/unified-runtime/include/ur_print.hpp +++ b/unified-runtime/include/ur_print.hpp @@ -9060,7 +9060,7 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, } break; case UR_PROGRAM_INFO_BINARIES: { - const unsigned char **tptr = (const unsigned char **)ptr; + const unsigned char *const *tptr = (const unsigned char *const *)ptr; printPtr(os, tptr); } break; case UR_PROGRAM_INFO_NUM_KERNELS: { diff --git a/unified-runtime/scripts/templates/print.hpp.mako b/unified-runtime/scripts/templates/print.hpp.mako index 81d9d795b8a1..4481847130cb 100644 --- a/unified-runtime/scripts/templates/print.hpp.mako +++ b/unified-runtime/scripts/templates/print.hpp.mako @@ -284,7 +284,7 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool %>case ${ename}: { %if th.value_traits.is_array(vtype): <% atype = th.value_traits.get_array_name(vtype) %> - %if 'void' in atype: + %if 'void' in atype or '*' in atype: const ${atype} const *tptr = (const ${atype} const*)ptr; %else: const ${atype} *tptr = (const ${atype} *)ptr;