|
2 | 2 | // Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
|
3 | 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
4 | 4 |
|
5 |
| -#include <dlfcn.h> |
6 |
| -#include <level_zero/ze_api.h> |
| 5 | +#define NOMINMAX |
| 6 | +#include <ze_api.h> |
7 | 7 |
|
8 | 8 | #include "pool.hpp"
|
9 | 9 | #include "umf/providers/provider_level_zero.h"
|
| 10 | +#include "utils_load_library.h" |
10 | 11 |
|
11 | 12 | using umf_test::test;
|
12 | 13 | using namespace umf_test;
|
@@ -66,63 +67,66 @@ struct umfLevelZeroProviderTest : umf_test::test {
|
66 | 67 | // NOTE that we use RTLD_GLOBAL which add all loaded symbols to the
|
67 | 68 | // global symbol table. These symbols would be used by the Level Zero
|
68 | 69 | // provider later
|
69 |
| - zeDlHandle = dlopen("libze_loader.so", RTLD_GLOBAL | RTLD_LAZY); |
70 |
| - |
71 |
| - *(void **)&libze_ops.zeInit = dlsym(zeDlHandle, "zeInit"); |
| 70 | + #ifdef _WIN32 |
| 71 | + zeDlHandle = util_open_library("ze_loader.dll"); |
| 72 | + #else |
| 73 | + zeDlHandle = util_open_library("libze_loader.so"); |
| 74 | + #endif |
| 75 | + *(void **)&libze_ops.zeInit = util_get_symbol_addr(zeDlHandle, "zeInit"); |
72 | 76 | ASSERT_NE(libze_ops.zeInit, nullptr);
|
73 |
| - *(void **)&libze_ops.zeDriverGet = dlsym(zeDlHandle, "zeDriverGet"); |
| 77 | + *(void **)&libze_ops.zeDriverGet = util_get_symbol_addr(zeDlHandle, "zeDriverGet"); |
74 | 78 | ASSERT_NE(libze_ops.zeDriverGet, nullptr);
|
75 |
| - *(void **)&libze_ops.zeDeviceGet = dlsym(zeDlHandle, "zeDeviceGet"); |
| 79 | + *(void **)&libze_ops.zeDeviceGet = util_get_symbol_addr(zeDlHandle, "zeDeviceGet"); |
76 | 80 | ASSERT_NE(libze_ops.zeDeviceGet, nullptr);
|
77 | 81 | *(void **)&libze_ops.zeDeviceGetProperties =
|
78 |
| - dlsym(zeDlHandle, "zeDeviceGetProperties"); |
| 82 | + util_get_symbol_addr(zeDlHandle, "zeDeviceGetProperties"); |
79 | 83 | ASSERT_NE(libze_ops.zeDeviceGetProperties, nullptr);
|
80 | 84 | *(void **)&libze_ops.zeContextCreate =
|
81 |
| - dlsym(zeDlHandle, "zeContextCreate"); |
| 85 | + util_get_symbol_addr(zeDlHandle, "zeContextCreate"); |
82 | 86 | ASSERT_NE(libze_ops.zeContextCreate, nullptr);
|
83 | 87 | *(void **)&libze_ops.zeContextDestroy =
|
84 |
| - dlsym(zeDlHandle, "zeContextDestroy"); |
| 88 | + util_get_symbol_addr(zeDlHandle, "zeContextDestroy"); |
85 | 89 | ASSERT_NE(libze_ops.zeContextDestroy, nullptr);
|
86 | 90 | *(void **)&libze_ops.zeCommandQueueCreate =
|
87 |
| - dlsym(zeDlHandle, "zeCommandQueueCreate"); |
| 91 | + util_get_symbol_addr(zeDlHandle, "zeCommandQueueCreate"); |
88 | 92 | ASSERT_NE(libze_ops.zeCommandQueueCreate, nullptr);
|
89 | 93 | *(void **)&libze_ops.zeCommandQueueDestroy =
|
90 |
| - dlsym(zeDlHandle, "zeCommandQueueDestroy"); |
| 94 | + util_get_symbol_addr(zeDlHandle, "zeCommandQueueDestroy"); |
91 | 95 | ASSERT_NE(libze_ops.zeCommandQueueDestroy, nullptr);
|
92 | 96 | *(void **)&libze_ops.zeCommandQueueExecuteCommandLists =
|
93 |
| - dlsym(zeDlHandle, "zeCommandQueueExecuteCommandLists"); |
| 97 | + util_get_symbol_addr(zeDlHandle, "zeCommandQueueExecuteCommandLists"); |
94 | 98 | ASSERT_NE(libze_ops.zeCommandQueueExecuteCommandLists, nullptr);
|
95 | 99 | *(void **)&libze_ops.zeCommandQueueSynchronize =
|
96 |
| - dlsym(zeDlHandle, "zeCommandQueueSynchronize"); |
| 100 | + util_get_symbol_addr(zeDlHandle, "zeCommandQueueSynchronize"); |
97 | 101 | ASSERT_NE(libze_ops.zeCommandQueueSynchronize, nullptr);
|
98 | 102 | *(void **)&libze_ops.zeCommandListCreate =
|
99 |
| - dlsym(zeDlHandle, "zeCommandListCreate"); |
| 103 | + util_get_symbol_addr(zeDlHandle, "zeCommandListCreate"); |
100 | 104 | ASSERT_NE(libze_ops.zeCommandListCreate, nullptr);
|
101 | 105 | *(void **)&libze_ops.zeCommandListDestroy =
|
102 |
| - dlsym(zeDlHandle, "zeCommandListDestroy"); |
| 106 | + util_get_symbol_addr(zeDlHandle, "zeCommandListDestroy"); |
103 | 107 | ASSERT_NE(libze_ops.zeCommandListDestroy, nullptr);
|
104 | 108 | *(void **)&libze_ops.zeCommandListClose =
|
105 |
| - dlsym(zeDlHandle, "zeCommandListClose"); |
| 109 | + util_get_symbol_addr(zeDlHandle, "zeCommandListClose"); |
106 | 110 | ASSERT_NE(libze_ops.zeCommandListClose, nullptr);
|
107 | 111 | *(void **)&libze_ops.zeCommandListAppendMemoryCopy =
|
108 |
| - dlsym(zeDlHandle, "zeCommandListAppendMemoryCopy"); |
| 112 | + util_get_symbol_addr(zeDlHandle, "zeCommandListAppendMemoryCopy"); |
109 | 113 | ASSERT_NE(libze_ops.zeCommandListAppendMemoryCopy, nullptr);
|
110 | 114 | *(void **)&libze_ops.zeCommandListAppendMemoryFill =
|
111 |
| - dlsym(zeDlHandle, "zeCommandListAppendMemoryFill"); |
| 115 | + util_get_symbol_addr(zeDlHandle, "zeCommandListAppendMemoryFill"); |
112 | 116 | ASSERT_NE(libze_ops.zeCommandListAppendMemoryFill, nullptr);
|
113 | 117 | *(void **)&libze_ops.zeMemGetAllocProperties =
|
114 |
| - dlsym(zeDlHandle, "zeMemGetAllocProperties"); |
| 118 | + util_get_symbol_addr(zeDlHandle, "zeMemGetAllocProperties"); |
115 | 119 | ASSERT_NE(libze_ops.zeMemGetAllocProperties, nullptr);
|
116 | 120 | *(void **)&libze_ops.zeMemAllocDevice =
|
117 |
| - dlsym(zeDlHandle, "zeMemAllocDevice"); |
| 121 | + util_get_symbol_addr(zeDlHandle, "zeMemAllocDevice"); |
118 | 122 | ASSERT_NE(libze_ops.zeMemAllocDevice, nullptr);
|
119 |
| - *(void **)&libze_ops.zeMemFree = dlsym(zeDlHandle, "zeMemFree"); |
| 123 | + *(void **)&libze_ops.zeMemFree = util_get_symbol_addr(zeDlHandle, "zeMemFree"); |
120 | 124 | ASSERT_NE(libze_ops.zeMemFree, nullptr);
|
121 | 125 | }
|
122 | 126 |
|
123 | 127 | void DestroyLevelZeroOps() {
|
124 | 128 | // Just close the handle here
|
125 |
| - dlclose(zeDlHandle); |
| 129 | + util_close_library(zeDlHandle); |
126 | 130 | }
|
127 | 131 | #else // USE_DLOPEN
|
128 | 132 | void InitLevelZeroOps() {
|
|
0 commit comments