@@ -310,18 +310,6 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
310
310
}
311
311
312
312
PlatformCache.Compute = [](Result<PlatformVec> &result) {
313
- static std::once_flag ZeCallCountInitialized;
314
- try {
315
- std::call_once (ZeCallCountInitialized, []() {
316
- if (UrL0LeaksDebug) {
317
- ZeCallCount = new std::map<std::string, int >;
318
- }
319
- });
320
- } catch (...) {
321
- result = exceptionToResult (std::current_exception ());
322
- return ;
323
- }
324
-
325
313
uint32_t UserForcedSysManInit = 0 ;
326
314
// Check if the user has disabled the default L0 Env initialization.
327
315
const int UrSysManEnvInitEnabled = [&UserForcedSysManInit] {
@@ -523,97 +511,6 @@ void globalAdapterOnDemandCleanup() {
523
511
}
524
512
525
513
ur_result_t adapterStateTeardown () {
526
- // Print the balance of various create/destroy native calls.
527
- // The idea is to verify if the number of create(+) and destroy(-) calls are
528
- // matched.
529
- if (ZeCallCount && (UrL0LeaksDebug) != 0 ) {
530
- bool LeakFound = false ;
531
- // clang-format off
532
- //
533
- // The format of this table is such that each row accounts for a
534
- // specific type of objects, and all elements in the raw except the last
535
- // one are allocating objects of that type, while the last element is known
536
- // to deallocate objects of that type.
537
- //
538
- std::vector<std::vector<std::string>> CreateDestroySet = {
539
- {" zeContextCreate" , " zeContextDestroy" },
540
- {" zeCommandQueueCreate" , " zeCommandQueueDestroy" },
541
- {" zeModuleCreate" , " zeModuleDestroy" },
542
- {" zeKernelCreate" , " zeKernelDestroy" },
543
- {" zeEventPoolCreate" , " zeEventPoolDestroy" },
544
- {" zeCommandListCreateImmediate" , " zeCommandListCreate" , " zeCommandListDestroy" },
545
- {" zeEventCreate" , " zeEventDestroy" },
546
- {" zeFenceCreate" , " zeFenceDestroy" },
547
- {" zeImageCreate" ," zeImageViewCreateExt" , " zeImageDestroy" },
548
- {" zeSamplerCreate" , " zeSamplerDestroy" },
549
- {" zeMemAllocDevice" , " zeMemAllocHost" , " zeMemAllocShared" , " zeMemFree" },
550
- };
551
-
552
- // A sample output aimed below is this:
553
- // ------------------------------------------------------------------------
554
- // zeContextCreate = 1 \---> zeContextDestroy = 1
555
- // zeCommandQueueCreate = 1 \---> zeCommandQueueDestroy = 1
556
- // zeModuleCreate = 1 \---> zeModuleDestroy = 1
557
- // zeKernelCreate = 1 \---> zeKernelDestroy = 1
558
- // zeEventPoolCreate = 1 \---> zeEventPoolDestroy = 1
559
- // zeCommandListCreateImmediate = 1 |
560
- // zeCommandListCreate = 1 \---> zeCommandListDestroy = 1 ---> LEAK = 1
561
- // zeEventCreate = 2 \---> zeEventDestroy = 2
562
- // zeFenceCreate = 1 \---> zeFenceDestroy = 1
563
- // zeImageCreate = 0 \---> zeImageDestroy = 0
564
- // zeSamplerCreate = 0 \---> zeSamplerDestroy = 0
565
- // zeMemAllocDevice = 0 |
566
- // zeMemAllocHost = 1 |
567
- // zeMemAllocShared = 0 \---> zeMemFree = 1
568
- //
569
- // clang-format on
570
- // TODO: use logger to print this messages
571
- std::cerr << " Check balance of create/destroy calls\n " ;
572
- std::cerr << " ----------------------------------------------------------\n " ;
573
- std::stringstream ss;
574
- for (const auto &Row : CreateDestroySet) {
575
- int diff = 0 ;
576
- for (auto I = Row.begin (); I != Row.end ();) {
577
- const char *ZeName = (*I).c_str ();
578
- const auto &ZeCount = (*ZeCallCount)[*I];
579
-
580
- bool First = (I == Row.begin ());
581
- bool Last = (++I == Row.end ());
582
-
583
- if (Last) {
584
- ss << " \\ --->" ;
585
- diff -= ZeCount;
586
- } else {
587
- diff += ZeCount;
588
- if (!First) {
589
- ss << " | " ;
590
- std::cerr << ss.str () << " \n " ;
591
- ss.str (" " );
592
- ss.clear ();
593
- }
594
- }
595
- ss << std::setw (30 ) << std::right << ZeName;
596
- ss << " = " ;
597
- ss << std::setw (5 ) << std::left << ZeCount;
598
- }
599
-
600
- if (diff) {
601
- LeakFound = true ;
602
- ss << " ---> LEAK = " << diff;
603
- }
604
-
605
- std::cerr << ss.str () << ' \n ' ;
606
- ss.str (" " );
607
- ss.clear ();
608
- }
609
-
610
- ZeCallCount->clear ();
611
- delete ZeCallCount;
612
- ZeCallCount = nullptr ;
613
- if (LeakFound)
614
- return UR_RESULT_ERROR_INVALID_MEM_OBJECT;
615
- }
616
-
617
514
// Due to multiple DLLMain definitions with SYCL, register to cleanup the
618
515
// Global Adapter after refcnt is 0
619
516
#if defined(_WIN32)
0 commit comments