Skip to content

Commit 4d3e329

Browse files
committed
Change the API to return an array of uint32_t to fix the L0 v2 implementation
1 parent 6b63f88 commit 4d3e329

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

include/ur_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5997,7 +5997,7 @@ typedef enum ur_kernel_info_t {
59975997
/// [uint32_t][optional-query] Return the number of registers used by the
59985998
/// compiled kernel.
59995999
UR_KERNEL_INFO_NUM_REGS = 6,
6000-
/// [uint32_t][optional-query] Return the spill memory size allocated by
6000+
/// [uint32_t[]][optional-query] Return the spill memory size allocated by
60016001
/// the compiler.
60026002
UR_KERNEL_INFO_SPILL_MEM_SIZE = 7,
60036003
/// @cond

include/ur_print.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8876,17 +8876,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
88768876
os << ")";
88778877
} break;
88788878
case UR_KERNEL_INFO_SPILL_MEM_SIZE: {
8879-
const uint32_t *tptr = (const uint32_t *)ptr;
8880-
if (sizeof(uint32_t) > size) {
8881-
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t)
8882-
<< ")";
8883-
return UR_RESULT_ERROR_INVALID_SIZE;
8884-
}
8885-
os << (const void *)(tptr) << " (";
88868879

8887-
os << *tptr;
8880+
const uint32_t *tptr = (const uint32_t *)ptr;
8881+
os << "{";
8882+
size_t nelems = size / sizeof(uint32_t);
8883+
for (size_t i = 0; i < nelems; ++i) {
8884+
if (i != 0) {
8885+
os << ", ";
8886+
}
88888887

8889-
os << ")";
8888+
os << tptr[i];
8889+
}
8890+
os << "}";
88908891
} break;
88918892
default:
88928893
os << "unknown enumerator";

scripts/core/kernel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ etors:
126126
- name: NUM_REGS
127127
desc: "[uint32_t][optional-query] Return the number of registers used by the compiled kernel."
128128
- name: SPILL_MEM_SIZE
129-
desc: "[uint32_t][optional-query] Return the spill memory size allocated by the compiler."
129+
desc: "[uint32_t[]][optional-query] Return the spill memory size allocated by the compiler."
130130
--- #--------------------------------------------------------------------------
131131
type: enum
132132
desc: "Get Kernel Work Group information"

source/adapters/level_zero/kernel.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,9 @@ ur_result_t urKernelGetInfo(
752752
case UR_KERNEL_INFO_NUM_ARGS:
753753
return ReturnValue(uint32_t{Kernel->ZeKernelProperties->numKernelArgs});
754754
case UR_KERNEL_INFO_SPILL_MEM_SIZE:
755-
return ReturnValue(uint32_t{Kernel->ZeKernelProperties->spillMemSize});
755+
return ReturnValue(static_cast<const uint32_t *>(
756+
&(Kernel->ZeKernelProperties->spillMemSize)),
757+
1ul);
756758
case UR_KERNEL_INFO_REFERENCE_COUNT:
757759
return ReturnValue(uint32_t{Kernel->RefCount.load()});
758760
case UR_KERNEL_INFO_ATTRIBUTES:

source/adapters/level_zero/v2/kernel.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,16 @@ ur_result_t urKernelGetInfo(ur_kernel_handle_t hKernel,
624624
case UR_KERNEL_INFO_NUM_REGS:
625625
case UR_KERNEL_INFO_NUM_ARGS:
626626
return ReturnValue(uint32_t{hKernel->getCommonProperties().numKernelArgs});
627-
case UR_KERNEL_INFO_SPILL_MEM_SIZE:
628-
return ReturnValue(uint32_t{hKernel->getProperties().spillMemSize});
627+
case UR_KERNEL_INFO_SPILL_MEM_SIZE: {
628+
std::shared_lock<ur_shared_mutex> Guard(hKernel->getProgramHandle()->Mutex);
629+
auto devices = hKernel->getProgramHandle()->AssociatedDevices;
630+
std::vector<uint32_t> spills(devices.size());
631+
for (size_t i = 0; i < spills.size(); ++i) {
632+
spills[i] = uint32_t{hKernel->getProperties(devices[i]).spillMemSize};
633+
}
634+
return ReturnValue(static_cast<const uint32_t *>(spills.data()),
635+
spills.size());
636+
}
629637
case UR_KERNEL_INFO_REFERENCE_COUNT:
630638
return ReturnValue(uint32_t{hKernel->RefCount.load()});
631639
case UR_KERNEL_INFO_ATTRIBUTES: {

0 commit comments

Comments
 (0)