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) {
@@ -306,31 +306,33 @@ static int init_level_zero_lib(void) {
306
306
return 0 ;
307
307
}
308
308
309
- UTIL_ONCE_FLAG level_zero_init_flag;
310
- int InitResult;
311
- void init_level_zero_once () {
309
+ static UTIL_ONCE_FLAG level_zero_init_flag = UTIL_ONCE_FLAG_INIT;
310
+ static int InitResult;
311
+
312
+ static void utils_ze_init_level_zero_once (void ) {
312
313
InitResult = InitLevelZeroOps ();
313
314
if (InitResult != 0 ) {
314
315
return ;
315
316
}
316
- InitResult = init_level_zero_lib ();
317
+ InitResult = utils_ze_init_level_zero_lib ();
317
318
}
318
319
319
- int init_level_zero ( ) {
320
- 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 );
321
322
322
323
return InitResult;
323
324
}
324
325
325
- 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_) {
326
328
int ret = 0 ;
327
329
ze_result_t ze_result;
328
330
ze_driver_handle_t *drivers = NULL ;
329
331
uint32_t drivers_num = 0 ;
330
332
331
- ret = init_level_zero ();
333
+ ret = utils_ze_init_level_zero ();
332
334
if (ret != 0 ) {
333
- fprintf (stderr, " init_level_zero () failed!\n " );
335
+ fprintf (stderr, " utils_ze_init_level_zero () failed!\n " );
334
336
goto init_fail;
335
337
}
336
338
@@ -374,16 +376,16 @@ int get_drivers(uint32_t *drivers_num_, ze_driver_handle_t **drivers_) {
374
376
return ret;
375
377
}
376
378
377
- int get_devices (ze_driver_handle_t driver, uint32_t *devices_num_,
378
- 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_) {
379
381
ze_result_t ze_result;
380
382
int ret = 0 ;
381
383
uint32_t devices_num = 0 ;
382
384
ze_device_handle_t *devices = NULL ;
383
385
384
- ret = init_level_zero ();
386
+ ret = utils_ze_init_level_zero ();
385
387
if (ret != 0 ) {
386
- fprintf (stderr, " init_level_zero () failed!\n " );
388
+ fprintf (stderr, " utils_ze_init_level_zero () failed!\n " );
387
389
goto init_fail;
388
390
}
389
391
@@ -426,15 +428,16 @@ int get_devices(ze_driver_handle_t driver, uint32_t *devices_num_,
426
428
return ret;
427
429
}
428
430
429
- 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_) {
430
433
int ret = 0 ;
431
434
ze_result_t ze_result;
432
435
uint32_t drivers_num = 0 ;
433
436
ze_device_handle_t *devices = NULL ;
434
437
ze_driver_handle_t *drivers = NULL ;
435
438
ze_driver_handle_t driver_with_gpus = NULL ;
436
439
437
- ret = get_drivers (&drivers_num, &drivers);
440
+ ret = utils_ze_get_drivers (&drivers_num, &drivers);
438
441
if (ret) {
439
442
goto fn_fail;
440
443
}
@@ -444,7 +447,7 @@ int find_driver_with_gpu(uint32_t *driver_idx, ze_driver_handle_t *driver_) {
444
447
uint32_t devices_num = 0 ;
445
448
ze_driver_handle_t driver = drivers[i];
446
449
447
- ret = get_devices (driver, &devices_num, &devices);
450
+ ret = utils_ze_get_devices (driver, &devices_num, &devices);
448
451
if (ret) {
449
452
goto fn_fail;
450
453
}
@@ -493,13 +496,14 @@ int find_driver_with_gpu(uint32_t *driver_idx, ze_driver_handle_t *driver_) {
493
496
return ret;
494
497
}
495
498
496
- 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_) {
497
501
int ret = -1 ;
498
502
uint32_t devices_num = 0 ;
499
503
ze_device_handle_t *devices = NULL ;
500
504
ze_device_handle_t device;
501
505
502
- ret = get_devices (driver, &devices_num, &devices);
506
+ ret = utils_ze_get_devices (driver, &devices_num, &devices);
503
507
if (ret) {
504
508
return ret;
505
509
}
@@ -531,9 +535,9 @@ int find_gpu_device(ze_driver_handle_t driver, ze_device_handle_t *device_) {
531
535
return ret;
532
536
}
533
537
534
- int level_zero_fill (ze_context_handle_t context, ze_device_handle_t device ,
535
- void *ptr, size_t size, const void *pattern ,
536
- 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) {
537
541
int ret = 0 ;
538
542
539
543
ze_command_queue_desc_t commandQueueDesc = {
@@ -617,8 +621,9 @@ int level_zero_fill(ze_context_handle_t context, ze_device_handle_t device,
617
621
return ret;
618
622
}
619
623
620
- int level_zero_copy (ze_context_handle_t context, ze_device_handle_t device,
621
- 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) {
622
627
int ret = 0 ;
623
628
ze_command_queue_desc_t commandQueueDesc = {
624
629
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC,
@@ -700,7 +705,8 @@ int level_zero_copy(ze_context_handle_t context, ze_device_handle_t device,
700
705
return ret;
701
706
}
702
707
703
- 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) {
704
710
ze_result_t ze_result;
705
711
ze_context_desc_t ctxtDesc;
706
712
ctxtDesc.stype = ZE_STRUCTURE_TYPE_CONTEXT_DESC;
@@ -716,7 +722,7 @@ int create_context(ze_driver_handle_t driver, ze_context_handle_t *context) {
716
722
return 0 ;
717
723
}
718
724
719
- int destroy_context (ze_context_handle_t context) {
725
+ int utils_ze_destroy_context (ze_context_handle_t context) {
720
726
ze_result_t ze_result;
721
727
ze_result = libze_ops.zeContextDestroy (context);
722
728
if (ze_result != ZE_RESULT_SUCCESS) {
@@ -727,7 +733,7 @@ int destroy_context(ze_context_handle_t context) {
727
733
return 0 ;
728
734
}
729
735
730
- 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) {
731
737
ze_device_handle_t device = NULL ;
732
738
ze_memory_allocation_properties_t alloc_props;
733
739
alloc_props.stype = ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES;
0 commit comments