Skip to content

Commit 6b9fa1e

Browse files
committed
Add ddi_getter support
1 parent e2d4415 commit 6b9fa1e

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

unified-runtime/source/adapters/offload/common.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010

1111
#pragma once
1212

13+
#include "ur/ur.hpp"
1314
#include <atomic>
1415

1516
namespace ur::offload {
16-
struct handle_base {};
17+
struct ddi_getter {
18+
const static ur_dditable_t *value();
19+
};
20+
using handle_base = ur::handle_base<ur::offload::ddi_getter>;
1721
} // namespace ur::offload
1822

1923
struct RefCounted : ur::offload::handle_base {

unified-runtime/source/adapters/offload/ur_interface_loader.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//
99
//===----------------------------------------------------------------------===//
1010

11+
#include "common.hpp"
1112
#include <ur_api.h>
1213
#include <ur_ddi.h>
1314

@@ -409,4 +410,42 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable(
409410

410411
return UR_RESULT_SUCCESS;
411412
}
413+
414+
UR_DLLEXPORT ur_result_t UR_APICALL urAllAddrTable(ur_api_version_t version,
415+
ur_dditable_t *pDdiTable) {
416+
urGetGlobalProcAddrTable(version, &pDdiTable->Global);
417+
urGetBindlessImagesExpProcAddrTable(version, &pDdiTable->BindlessImagesExp);
418+
urGetCommandBufferExpProcAddrTable(version, &pDdiTable->CommandBufferExp);
419+
urGetContextProcAddrTable(version, &pDdiTable->Context);
420+
urGetEnqueueProcAddrTable(version, &pDdiTable->Enqueue);
421+
urGetEnqueueExpProcAddrTable(version, &pDdiTable->EnqueueExp);
422+
urGetEventProcAddrTable(version, &pDdiTable->Event);
423+
urGetKernelProcAddrTable(version, &pDdiTable->Kernel);
424+
urGetKernelExpProcAddrTable(version, &pDdiTable->KernelExp);
425+
urGetMemProcAddrTable(version, &pDdiTable->Mem);
426+
urGetPhysicalMemProcAddrTable(version, &pDdiTable->PhysicalMem);
427+
urGetPlatformProcAddrTable(version, &pDdiTable->Platform);
428+
urGetProgramProcAddrTable(version, &pDdiTable->Program);
429+
urGetProgramExpProcAddrTable(version, &pDdiTable->ProgramExp);
430+
urGetQueueProcAddrTable(version, &pDdiTable->Queue);
431+
urGetSamplerProcAddrTable(version, &pDdiTable->Sampler);
432+
urGetUSMProcAddrTable(version, &pDdiTable->USM);
433+
urGetUSMExpProcAddrTable(version, &pDdiTable->USMExp);
434+
urGetUsmP2PExpProcAddrTable(version, &pDdiTable->UsmP2PExp);
435+
urGetVirtualMemProcAddrTable(version, &pDdiTable->VirtualMem);
436+
urGetDeviceProcAddrTable(version, &pDdiTable->Device);
437+
urGetAdapterProcAddrTable(version, &pDdiTable->Adapter);
438+
439+
return UR_RESULT_SUCCESS;
440+
}
441+
412442
} // extern "C"
443+
444+
const ur_dditable_t *ur::offload::ddi_getter::value() {
445+
static std::once_flag flag;
446+
static ur_dditable_t table;
447+
448+
std::call_once(flag,
449+
[]() { urAllAddrTable(UR_API_VERSION_CURRENT, &table); });
450+
return &table;
451+
}

0 commit comments

Comments
 (0)