5
5
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
*/
7
7
8
- #include " level_zero_helpers .h"
8
+ #include " utils_level_zero .h"
9
9
10
10
#include < memory>
11
11
#include < stdlib.h>
@@ -297,7 +297,7 @@ int InitLevelZeroOps() {
297
297
}
298
298
#endif // USE_DLOPEN
299
299
300
- static int init_level_zero_lib (void ) {
300
+ static int utils_ze_init_level_zero_lib (void ) {
301
301
ze_init_flag_t flags = ZE_INIT_FLAG_GPU_ONLY;
302
302
ze_result_t result = libze_ops.zeInit (flags);
303
303
if (result != ZE_RESULT_SUCCESS) {
@@ -309,29 +309,30 @@ static int init_level_zero_lib(void) {
309
309
static UTIL_ONCE_FLAG level_zero_init_flag = UTIL_ONCE_FLAG_INIT;
310
310
static int InitResult;
311
311
312
- static void init_level_zero_once (void ) {
312
+ static void utils_ze_init_level_zero_once (void ) {
313
313
InitResult = InitLevelZeroOps ();
314
314
if (InitResult != 0 ) {
315
315
return ;
316
316
}
317
- InitResult = init_level_zero_lib ();
317
+ InitResult = utils_ze_init_level_zero_lib ();
318
318
}
319
319
320
- static int init_level_zero (void ) {
321
- utils_init_once (&level_zero_init_flag, init_level_zero_once );
320
+ int utils_ze_init_level_zero (void ) {
321
+ utils_init_once (&level_zero_init_flag, utils_ze_init_level_zero_once );
322
322
323
323
return InitResult;
324
324
}
325
325
326
- int get_drivers (uint32_t *drivers_num_, ze_driver_handle_t **drivers_) {
326
+ int utils_ze_get_drivers (uint32_t *drivers_num_,
327
+ ze_driver_handle_t **drivers_) {
327
328
int ret = 0 ;
328
329
ze_result_t ze_result;
329
330
ze_driver_handle_t *drivers = NULL ;
330
331
uint32_t drivers_num = 0 ;
331
332
332
- ret = init_level_zero ();
333
+ ret = utils_ze_init_level_zero ();
333
334
if (ret != 0 ) {
334
- fprintf (stderr, " init_level_zero () failed!\n " );
335
+ fprintf (stderr, " utils_ze_init_level_zero () failed!\n " );
335
336
goto init_fail;
336
337
}
337
338
@@ -375,16 +376,16 @@ int get_drivers(uint32_t *drivers_num_, ze_driver_handle_t **drivers_) {
375
376
return ret;
376
377
}
377
378
378
- int get_devices (ze_driver_handle_t driver, uint32_t *devices_num_,
379
- ze_device_handle_t **devices_) {
379
+ int utils_ze_get_devices (ze_driver_handle_t driver, uint32_t *devices_num_,
380
+ ze_device_handle_t **devices_) {
380
381
ze_result_t ze_result;
381
382
int ret = 0 ;
382
383
uint32_t devices_num = 0 ;
383
384
ze_device_handle_t *devices = NULL ;
384
385
385
- ret = init_level_zero ();
386
+ ret = utils_ze_init_level_zero ();
386
387
if (ret != 0 ) {
387
- fprintf (stderr, " init_level_zero () failed!\n " );
388
+ fprintf (stderr, " utils_ze_init_level_zero () failed!\n " );
388
389
goto init_fail;
389
390
}
390
391
@@ -427,15 +428,16 @@ int get_devices(ze_driver_handle_t driver, uint32_t *devices_num_,
427
428
return ret;
428
429
}
429
430
430
- int find_driver_with_gpu (uint32_t *driver_idx, ze_driver_handle_t *driver_) {
431
+ int utils_ze_find_driver_with_gpu (uint32_t *driver_idx,
432
+ ze_driver_handle_t *driver_) {
431
433
int ret = 0 ;
432
434
ze_result_t ze_result;
433
435
uint32_t drivers_num = 0 ;
434
436
ze_device_handle_t *devices = NULL ;
435
437
ze_driver_handle_t *drivers = NULL ;
436
438
ze_driver_handle_t driver_with_gpus = NULL ;
437
439
438
- ret = get_drivers (&drivers_num, &drivers);
440
+ ret = utils_ze_get_drivers (&drivers_num, &drivers);
439
441
if (ret) {
440
442
goto fn_fail;
441
443
}
@@ -445,7 +447,7 @@ int find_driver_with_gpu(uint32_t *driver_idx, ze_driver_handle_t *driver_) {
445
447
uint32_t devices_num = 0 ;
446
448
ze_driver_handle_t driver = drivers[i];
447
449
448
- ret = get_devices (driver, &devices_num, &devices);
450
+ ret = utils_ze_get_devices (driver, &devices_num, &devices);
449
451
if (ret) {
450
452
goto fn_fail;
451
453
}
@@ -494,13 +496,14 @@ int find_driver_with_gpu(uint32_t *driver_idx, ze_driver_handle_t *driver_) {
494
496
return ret;
495
497
}
496
498
497
- int find_gpu_device (ze_driver_handle_t driver, ze_device_handle_t *device_) {
499
+ int utils_ze_find_gpu_device (ze_driver_handle_t driver,
500
+ ze_device_handle_t *device_) {
498
501
int ret = -1 ;
499
502
uint32_t devices_num = 0 ;
500
503
ze_device_handle_t *devices = NULL ;
501
504
ze_device_handle_t device;
502
505
503
- ret = get_devices (driver, &devices_num, &devices);
506
+ ret = utils_ze_get_devices (driver, &devices_num, &devices);
504
507
if (ret) {
505
508
return ret;
506
509
}
@@ -532,9 +535,9 @@ int find_gpu_device(ze_driver_handle_t driver, ze_device_handle_t *device_) {
532
535
return ret;
533
536
}
534
537
535
- int level_zero_fill (ze_context_handle_t context, ze_device_handle_t device ,
536
- void *ptr, size_t size, const void *pattern ,
537
- size_t pattern_size) {
538
+ int utils_ze_level_zero_fill (ze_context_handle_t context,
539
+ ze_device_handle_t device, void *ptr, size_t size,
540
+ const void *pattern, size_t pattern_size) {
538
541
int ret = 0 ;
539
542
540
543
ze_command_queue_desc_t commandQueueDesc = {
@@ -618,8 +621,9 @@ int level_zero_fill(ze_context_handle_t context, ze_device_handle_t device,
618
621
return ret;
619
622
}
620
623
621
- int level_zero_copy (ze_context_handle_t context, ze_device_handle_t device,
622
- void *dst_ptr, const void *src_ptr, size_t size) {
624
+ int utils_ze_level_zero_copy (ze_context_handle_t context,
625
+ ze_device_handle_t device, void *dst_ptr,
626
+ const void *src_ptr, size_t size) {
623
627
int ret = 0 ;
624
628
ze_command_queue_desc_t commandQueueDesc = {
625
629
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC,
@@ -701,7 +705,8 @@ int level_zero_copy(ze_context_handle_t context, ze_device_handle_t device,
701
705
return ret;
702
706
}
703
707
704
- int create_context (ze_driver_handle_t driver, ze_context_handle_t *context) {
708
+ int utils_ze_create_context (ze_driver_handle_t driver,
709
+ ze_context_handle_t *context) {
705
710
ze_result_t ze_result;
706
711
ze_context_desc_t ctxtDesc;
707
712
ctxtDesc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC;
@@ -717,7 +722,7 @@ int create_context(ze_driver_handle_t driver, ze_context_handle_t *context) {
717
722
return 0 ;
718
723
}
719
724
720
- int destroy_context (ze_context_handle_t context) {
725
+ int utils_ze_destroy_context (ze_context_handle_t context) {
721
726
ze_result_t ze_result;
722
727
ze_result = libze_ops.zeContextDestroy (context);
723
728
if (ze_result != ZE_RESULT_SUCCESS) {
@@ -728,7 +733,7 @@ int destroy_context(ze_context_handle_t context) {
728
733
return 0 ;
729
734
}
730
735
731
- ze_memory_type_t get_mem_type (ze_context_handle_t context, void *ptr) {
736
+ ze_memory_type_t utils_ze_get_mem_type (ze_context_handle_t context, void *ptr) {
732
737
ze_device_handle_t device = NULL ;
733
738
ze_memory_allocation_properties_t alloc_props;
734
739
alloc_props.stype = ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES;
0 commit comments