Skip to content

Commit 3fb0f1c

Browse files
authored
[CLN] Remove init_context function as unused (#3941)
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent cb5c745 commit 3fb0f1c

File tree

4 files changed

+2
-85
lines changed

4 files changed

+2
-85
lines changed

third_party/intel/backend/driver.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <cstddef>
1010
#include <iostream>
1111
#include <string>
12-
#include <unordered_map>
1312
#include <utility>
1413
#include <vector>
1514

@@ -25,8 +24,6 @@
2524
#include <Python.h>
2625
#include <numpy/arrayobject.h>
2726

28-
static SyclQueueMap g_sycl_queue_map;
29-
3027
static std::vector<ze_device_handle_t> g_devices;
3128
static std::vector<std::pair<sycl::device, ze_device_handle_t>>
3229
g_sycl_l0_device_list;
@@ -297,27 +294,6 @@ extern "C" EXPORT_FUNC PyObject *load_binary(PyObject *args) {
297294
}
298295
}
299296

300-
extern "C" EXPORT_FUNC PyObject *init_context(PyObject *cap) {
301-
void *queue = NULL;
302-
if (!(queue = PyLong_AsVoidPtr(cap)))
303-
return NULL;
304-
sycl::queue *sycl_queue = static_cast<sycl::queue *>(queue);
305-
if (g_sycl_queue_map.find(*sycl_queue) == g_sycl_queue_map.end()) {
306-
const auto updated_sycl_devices = update(*sycl_queue, g_sycl_queue_map);
307-
if (!updated_sycl_devices.empty()) {
308-
// Update global data
309-
const uint32_t deviceCount =
310-
std::min(updated_sycl_devices.size(), g_devices.size());
311-
for (uint32_t i = 0; i < deviceCount; ++i) {
312-
g_devices[i] = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(
313-
updated_sycl_devices[i]);
314-
}
315-
}
316-
}
317-
auto context = g_sycl_queue_map[*sycl_queue].context;
318-
return Py_BuildValue("(K)", (uint64_t)context);
319-
}
320-
321297
extern "C" EXPORT_FUNC PyObject *init_devices(PyObject *cap) {
322298
void *queue = NULL;
323299
if (!(queue = PyLong_AsVoidPtr(cap)))

third_party/intel/backend/driver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ class SpirvUtils:
186186

187187
def __init__(self, cache_path: str):
188188
self.shared_library = ctypes.PyDLL(cache_path)
189-
methods = ("init_context", "init_devices", "load_binary", "wait_on_sycl_queue")
189+
methods = ("init_devices", "load_binary", "wait_on_sycl_queue")
190190
for method in methods:
191191
getattr(self.shared_library, method).restype = ctypes.py_object
192192
getattr(self.shared_library, method).argtypes = (ctypes.py_object, )
193193
self.shared_library.get_device_properties.restype = ctypes.py_object
194194
self.shared_library.get_device_properties.argtypes = (ctypes.c_int, )
195195

196196
def __getattribute__(self, name):
197-
if name in ("get_device_properties", "init_context", "init_devices", "wait_on_sycl_queue"):
197+
if name in ("get_device_properties", "init_devices", "wait_on_sycl_queue"):
198198
shared_library = super().__getattribute__("shared_library")
199199
return getattr(shared_library, name)
200200

@@ -306,7 +306,6 @@ def __init__(self):
306306
self.mod = compile_module_from_src(Path(os.path.join(dirname, "driver.c")).read_text(), "spirv_utils")
307307
self.load_binary = self.mod.load_binary
308308
self.get_device_properties = self.mod.get_device_properties
309-
self.context = self.mod.init_context(self.get_sycl_queue())
310309
self.device_count = self.mod.init_devices(self.get_sycl_queue())
311310
self.wait_on_sycl_queue = self.mod.wait_on_sycl_queue
312311

third_party/intel/backend/include/sycl_functions.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <sstream>
1010
#include <string>
1111
#include <string_view>
12-
#include <unordered_map>
13-
#include <variant>
1412

1513
#include <level_zero/ze_api.h>
1614
#include <sycl/sycl.hpp>
@@ -22,8 +20,6 @@ typedef struct l0_resc_handles {
2220
ze_command_list_handle_t cmd_list;
2321
} l0_resc_handles;
2422

25-
using SyclQueueMap = std::unordered_map<sycl::queue, l0_resc_handles>;
26-
2723
// Create an exception handler for asynchronous SYCL exceptions
2824
auto exception_handler = [](sycl::exception_list e_list) {
2925
for (std::exception_ptr const &e : e_list) {
@@ -147,36 +143,4 @@ void printModuleKernelName(ze_module_handle_t hModule) {
147143
}
148144
}
149145

150-
std::vector<sycl::device> update(sycl::queue sycl_queue,
151-
SyclQueueMap &sycl_queue_map) {
152-
// Get l0-context
153-
auto sycl_context = sycl_queue.get_context();
154-
ze_context_handle_t hCtxt =
155-
sycl::get_native<sycl::backend::ext_oneapi_level_zero>(sycl_context);
156-
// Get l0-device
157-
const std::vector<sycl::device> &sycl_devices = sycl_context.get_devices();
158-
assert(sycl_devices.size() > 0);
159-
ze_device_handle_t hDev =
160-
sycl::get_native<sycl::backend::ext_oneapi_level_zero>(
161-
sycl_devices.front());
162-
// Get l0-queue
163-
bool immediate_cmd_list = false;
164-
std::variant<ze_command_queue_handle_t, ze_command_list_handle_t> queue_var =
165-
sycl::get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue);
166-
auto l0_queue = std::get_if<ze_command_queue_handle_t>(&queue_var);
167-
if (l0_queue == nullptr) {
168-
auto imm_cmd_list = std::get_if<ze_command_list_handle_t>(&queue_var);
169-
if (imm_cmd_list == nullptr) {
170-
return {};
171-
}
172-
immediate_cmd_list = true;
173-
sycl_queue_map[sycl_queue].cmd_list = *imm_cmd_list;
174-
}
175-
sycl_queue_map[sycl_queue].context = hCtxt;
176-
sycl_queue_map[sycl_queue].device = hDev;
177-
sycl_queue_map[sycl_queue].queue = immediate_cmd_list ? 0 : *l0_queue;
178-
179-
return sycl_devices;
180-
}
181-
182146
#endif // SYCL_FUNCTIONS_INCLUDE_H_

utils/SPIRVRunner/SPIRVRunner.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
#include "llvm_parser.h"
66
#include "sycl_functions.h"
7-
#include <algorithm>
87
#include <cstdlib>
98
#include <filesystem>
109
#include <fstream>
1110
#include <ios>
1211
#include <iostream>
1312
#include <nlohmann/json.hpp>
14-
#include <regex>
1513
#include <string>
1614
#include <vector>
1715
using json = nlohmann::json;
@@ -108,8 +106,6 @@ struct KernelArguments {
108106
};
109107

110108
/** SYCL Globals **/
111-
SyclQueueMap g_sycl_queue_map;
112-
113109
static std::vector<ze_device_handle_t> g_devices;
114110
static std::vector<std::pair<sycl::device, ze_device_handle_t>>
115111
g_sycl_l0_device_list;
@@ -188,23 +184,6 @@ loadBinary(const std::string &kernel_name, const std::string &build_flags,
188184
return std::make_tuple(mod, fun, n_regs, n_spills);
189185
}
190186

191-
ze_context_handle_t initContext(sycl::queue *sycl_queue) {
192-
if (g_sycl_queue_map.find(*sycl_queue) == g_sycl_queue_map.end()) {
193-
const auto updated_sycl_devices = update(*sycl_queue, g_sycl_queue_map);
194-
if (!updated_sycl_devices.empty()) {
195-
// Update global data
196-
const uint32_t deviceCount =
197-
std::min(updated_sycl_devices.size(), g_devices.size());
198-
for (uint32_t i = 0; i < deviceCount; ++i) {
199-
g_devices[i] = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(
200-
updated_sycl_devices[i]);
201-
}
202-
}
203-
}
204-
auto context = g_sycl_queue_map[*sycl_queue].context;
205-
return context;
206-
}
207-
208187
size_t initDevices(sycl::queue *sycl_queue) {
209188
auto sycl_context = sycl_queue->get_context();
210189

@@ -466,7 +445,6 @@ int main(int argc, char **argv) {
466445

467446
std::cout << "Running on device: "
468447
<< q.get_device().get_info<sycl::info::device::name>() << "\n";
469-
initContext(&q);
470448
initDevices(&q);
471449

472450
// Parse the JSON file and create argument dictionary

0 commit comments

Comments
 (0)