Skip to content

Commit de1e9f4

Browse files
authored
Rename the static build define from DYNAMIC_LOAD_LOADER to L0_STATIC_LOADER_BUILD (#339)
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 79ce2b5 commit de1e9f4

File tree

16 files changed

+458
-458
lines changed

16 files changed

+458
-458
lines changed

scripts/templates/libapi.cpp.mako

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ${th.make_func_name(n, tags, obj)}(
5656
{
5757
%if re.match("Init", obj['name']):
5858
%if re.match("zes", n):
59-
#ifdef DYNAMIC_LOAD_LOADER
59+
#ifdef L0_STATIC_LOADER_BUILD
6060
if (!${x}_lib::context) {
6161
${x}_lib::context = new ${x}_lib::context_t;
6262
}
@@ -87,7 +87,7 @@ ${th.make_func_name(n, tags, obj)}(
8787
%else:
8888
%if re.match("InitDrivers", obj['name']):
8989
${x}_result_t result = ${X}_RESULT_SUCCESS;
90-
#ifdef DYNAMIC_LOAD_LOADER
90+
#ifdef L0_STATIC_LOADER_BUILD
9191
if (!${x}_lib::context) {
9292
${x}_lib::context = new ${x}_lib::context_t;
9393
}
@@ -124,7 +124,7 @@ ${th.make_func_name(n, tags, obj)}(
124124
return result;
125125
%else:
126126
static ${x}_result_t result = ${X}_RESULT_SUCCESS;
127-
#ifdef DYNAMIC_LOAD_LOADER
127+
#ifdef L0_STATIC_LOADER_BUILD
128128
if (!${x}_lib::context) {
129129
${x}_lib::context = new ${x}_lib::context_t;
130130
}
@@ -160,7 +160,7 @@ ${th.make_func_name(n, tags, obj)}(
160160
}
161161
%endif
162162
%else:
163-
#ifdef DYNAMIC_LOAD_LOADER
163+
#ifdef L0_STATIC_LOADER_BUILD
164164
ze_result_t result = ${X}_RESULT_SUCCESS;
165165
if(ze_lib::destruction) {
166166
return ${X}_RESULT_ERROR_UNINITIALIZED;

scripts/templates/libddi.cpp.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ from templates import helper as th
1717
*
1818
*/
1919
#include "${x}_lib.h"
20-
#ifndef DYNAMIC_LOAD_LOADER
20+
#ifndef L0_STATIC_LOADER_BUILD
2121
#include "${n}_ddi.h"
2222
#endif
2323

2424
namespace ${x}_lib
2525
{
2626
///////////////////////////////////////////////////////////////////////////////
2727

28-
#ifdef DYNAMIC_LOAD_LOADER
28+
#ifdef L0_STATIC_LOADER_BUILD
2929
__zedlllocal ${x}_result_t context_t::${n}DdiTableInit(ze_api_version_t version)
3030
{
3131
${x}_result_t result = ${X}_RESULT_SUCCESS;

source/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (BUILD_STATIC)
1919
""
2020
${CMAKE_CURRENT_BINARY_DIR}/ZeLoaderVersion.rc
2121
)
22-
add_definitions(-DDYNAMIC_LOAD_LOADER="1")
22+
add_definitions(-DL0_STATIC_LOADER_BUILD="1")
2323
else()
2424
message(STATUS "Building loader as dynamic library")
2525
add_library(${TARGET_LOADER_NAME}

source/lib/linux/lib_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace ze_lib
1212
{
13-
#ifndef DYNAMIC_LOAD_LOADER
13+
#ifndef L0_STATIC_LOADER_BUILD
1414
void __attribute__((constructor)) createLibContext() {
1515
context = new context_t;
1616
}

source/lib/windows/lib_init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
*/
88

99
#include "../ze_lib.h"
10-
#ifndef DYNAMIC_LOAD_LOADER
10+
#ifndef L0_STATIC_LOADER_BUILD
1111
#include "../loader/ze_loader_internal.h"
1212
#endif
1313

1414
namespace ze_lib
1515
{
16-
#ifndef DYNAMIC_LOAD_LOADER
16+
#ifndef L0_STATIC_LOADER_BUILD
1717
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
1818
if (fdwReason == DLL_PROCESS_DETACH) {
1919
delete context;

source/lib/ze_lib.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ze_lib
1818
{
1919
///////////////////////////////////////////////////////////////////////////////
2020
context_t *context = nullptr;
21-
#ifdef DYNAMIC_LOAD_LOADER
21+
#ifdef L0_STATIC_LOADER_BUILD
2222
void context_at_exit_destructor()
2323
{
2424
if (ze_lib::context) {
@@ -69,7 +69,7 @@ namespace ze_lib
6969
///////////////////////////////////////////////////////////////////////////////
7070
__zedlllocal context_t::~context_t()
7171
{
72-
#ifdef DYNAMIC_LOAD_LOADER
72+
#ifdef L0_STATIC_LOADER_BUILD
7373
if (loaderTeardownRegistrationEnabled && !loaderTeardownCallbackReceived) {
7474
loaderTeardownCallback(loaderTeardownCallbackIndex);
7575
}
@@ -92,7 +92,7 @@ namespace ze_lib
9292
{
9393
ze_result_t result;
9494
ze_api_version_t version = ZE_API_VERSION_CURRENT;
95-
#ifdef DYNAMIC_LOAD_LOADER
95+
#ifdef L0_STATIC_LOADER_BUILD
9696
std::string loaderLibraryPath;
9797
auto loaderLibraryPathEnv = getenv_string("ZEL_LIBRARY_PATH");
9898
if (!loaderLibraryPathEnv.empty()) {
@@ -213,7 +213,7 @@ namespace ze_lib
213213

214214
// Given zesInit, then zesDrivers needs to be used as the sysmanInstanceDrivers;
215215
bool loaderContextAccessAllowed = true;
216-
#ifdef DYNAMIC_LOAD_LOADER
216+
#ifdef L0_STATIC_LOADER_BUILD
217217
loaderContextAccessAllowed = false;
218218
loader::context_t *loaderContext = nullptr;
219219
#else
@@ -264,7 +264,7 @@ namespace ze_lib
264264
// Init the stored ddi tables for the tracing layer
265265
if( ZE_RESULT_SUCCESS == result )
266266
{
267-
#ifdef DYNAMIC_LOAD_LOADER
267+
#ifdef L0_STATIC_LOADER_BUILD
268268
if (loaderTracingLayerInit) {
269269
result = loaderTracingLayerInit(this->pTracingZeDdiTable);
270270
}
@@ -280,7 +280,7 @@ namespace ze_lib
280280
// Check which drivers support the ze_driver_flag_t specified
281281
// No need to check if only initializing sysman
282282
bool requireDdiReinit = false;
283-
#ifdef DYNAMIC_LOAD_LOADER
283+
#ifdef L0_STATIC_LOADER_BUILD
284284
if (zeInitDriversSupport) {
285285
typedef ze_result_t (ZE_APICALL *zelLoaderDriverCheck_t)(ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly);
286286
auto loaderDriverCheck = reinterpret_cast<zelLoaderDriverCheck_t>(
@@ -341,7 +341,7 @@ namespace ze_lib
341341

342342
if( ZE_RESULT_SUCCESS == result )
343343
{
344-
#ifdef DYNAMIC_LOAD_LOADER
344+
#ifdef L0_STATIC_LOADER_BUILD
345345
// Init Dynamic Loader's Lib Context:
346346
auto initDriversLoader = reinterpret_cast<ze_pfnInitDrivers_t>(
347347
GET_FUNCTION_PTR(loader, "zeInitDrivers") );
@@ -378,7 +378,7 @@ namespace ze_lib
378378
#endif
379379
isInitialized = true;
380380
}
381-
#ifdef DYNAMIC_LOAD_LOADER
381+
#ifdef L0_STATIC_LOADER_BUILD
382382
std::call_once(ze_lib::context->initTeardownCallbacksOnce, [this]() {
383383
if (!delayContextDestruction) {
384384
std::atexit(context_at_exit_destructor);
@@ -416,7 +416,7 @@ zelLoaderGetVersions(
416416
size_t *num_elems, //Pointer to num versions to get.
417417
zel_component_version_t *versions) //Pointer to array of versions. If set to NULL, num_elems is returned
418418
{
419-
#ifdef DYNAMIC_LOAD_LOADER
419+
#ifdef L0_STATIC_LOADER_BUILD
420420
if(nullptr == ze_lib::context->loader)
421421
return ZE_RESULT_ERROR_UNINITIALIZED;
422422
typedef ze_result_t (ZE_APICALL *zelLoaderGetVersions_t)(size_t *num_elems, zel_component_version_t *versions);
@@ -436,7 +436,7 @@ zelLoaderTranslateHandle(
436436
void **handleOut)
437437

438438
{
439-
#ifdef DYNAMIC_LOAD_LOADER
439+
#ifdef L0_STATIC_LOADER_BUILD
440440
if(nullptr == ze_lib::context->loader)
441441
return ZE_RESULT_ERROR_UNINITIALIZED;
442442
typedef ze_result_t (ZE_APICALL *zelLoaderTranslateHandleInternal_t)(zel_handle_type_t handleType, void *handleIn, void **handleOut);
@@ -470,7 +470,7 @@ zelSetDriverTeardown()
470470
void ZE_APICALL
471471
zelSetDelayLoaderContextTeardown()
472472
{
473-
#ifdef DYNAMIC_LOAD_LOADER
473+
#ifdef L0_STATIC_LOADER_BUILD
474474
if (!ze_lib::delayContextDestruction) {
475475
ze_lib::delayContextDestruction = true;
476476
}
@@ -539,7 +539,7 @@ zelCheckIsLoaderInTearDown() {
539539
if (ze_lib::destruction || ze_lib::context == nullptr) {
540540
return true;
541541
}
542-
#if defined(DYNAMIC_LOAD_LOADER) && defined(_WIN32)
542+
#if defined(L0_STATIC_LOADER_BUILD) && defined(_WIN32)
543543
static bool loaderIsStable = true;
544544
if (!loaderIsStable) {
545545
if (ze_lib::context->debugTraceEnabled) {
@@ -594,7 +594,7 @@ zelCheckIsLoaderInTearDown() {
594594
void ZE_APICALL
595595
zelLoaderContextTeardown()
596596
{
597-
#ifdef DYNAMIC_LOAD_LOADER
597+
#ifdef L0_STATIC_LOADER_BUILD
598598
if (ze_lib::delayContextDestruction && ze_lib::context) {
599599
delete ze_lib::context;
600600
ze_lib::context = nullptr;
@@ -605,7 +605,7 @@ zelLoaderContextTeardown()
605605
ze_result_t ZE_APICALL
606606
zelEnableTracingLayer()
607607
{
608-
#ifdef DYNAMIC_LOAD_LOADER
608+
#ifdef L0_STATIC_LOADER_BUILD
609609
if(nullptr == ze_lib::context->loader)
610610
return ZE_RESULT_ERROR_UNINITIALIZED;
611611
typedef ze_result_t (ZE_APICALL *zelEnableTracingLayerInternal_t)();
@@ -626,7 +626,7 @@ zelEnableTracingLayer()
626626
ze_result_t ZE_APICALL
627627
zelDisableTracingLayer()
628628
{
629-
#ifdef DYNAMIC_LOAD_LOADER
629+
#ifdef L0_STATIC_LOADER_BUILD
630630
if(nullptr == ze_lib::context->loader)
631631
return ZE_RESULT_ERROR_UNINITIALIZED;
632632
typedef ze_result_t (ZE_APICALL *zelDisableTracingLayerInternal_t)();

source/lib/ze_lib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace ze_lib
3131
class __zedlllocal context_t
3232
{
3333
public:
34-
#ifdef DYNAMIC_LOAD_LOADER
34+
#ifdef L0_STATIC_LOADER_BUILD
3535
HMODULE loader = nullptr;
3636
#endif
3737

@@ -179,7 +179,7 @@ namespace ze_lib
179179
std::atomic<uint32_t> teardownCallbacksCount{0};
180180
std::map<uint32_t, zel_loader_teardown_callback_t> teardownCallbacks;
181181
std::mutex teardownCallbacksMutex;
182-
#ifdef DYNAMIC_LOAD_LOADER
182+
#ifdef L0_STATIC_LOADER_BUILD
183183
std::once_flag initTeardownCallbacksOnce;
184184
zel_application_teardown_callback_t loaderTeardownCallback = nullptr;
185185
uint32_t loaderTeardownCallbackIndex = 0;
@@ -188,7 +188,7 @@ namespace ze_lib
188188

189189
extern bool destruction;
190190
extern context_t *context;
191-
#ifdef DYNAMIC_LOAD_LOADER
191+
#ifdef L0_STATIC_LOADER_BUILD
192192
extern bool delayContextDestruction;
193193
extern bool loaderTeardownCallbackReceived;
194194
extern bool loaderTeardownRegistrationEnabled;

0 commit comments

Comments
 (0)