-
Notifications
You must be signed in to change notification settings - Fork 56
/
tool.cc
52 lines (39 loc) · 1.47 KB
/
tool.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//==============================================================
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include "ze_debug_info_collector.h"
static ZeDebugInfoCollector* collector = nullptr;
// External Tool Interface ////////////////////////////////////////////////////
extern "C" PTI_EXPORT void Usage() {
std::cout << "Usage: ./ze_debug_info[.exe] <application> <args>" << std::endl;
}
extern "C" PTI_EXPORT int ParseArgs(int argc, char* argv[]) { return 1; }
extern "C" PTI_EXPORT void SetToolEnv() { utils::SetEnv("ZE_ENABLE_TRACING_LAYER", "1"); }
// Internal Tool Functionality ////////////////////////////////////////////////
static void PrintResults() {
PTI_ASSERT(collector != nullptr);
const KernelDebugInfoMap& debug_info_map = collector->GetKernelDebugInfoMap();
if (debug_info_map.size() == 0) {
return;
}
std::cerr << std::endl;
for (auto pair : debug_info_map) {
ZeDebugInfoCollector::PrintKernelDebugInfo(pair.first, pair.second);
}
}
// Internal Tool Interface ////////////////////////////////////////////////////
void EnableProfiling() {
ze_result_t status = ZE_RESULT_SUCCESS;
status = zeInit(ZE_INIT_FLAG_GPU_ONLY);
PTI_ASSERT(status == ZE_RESULT_SUCCESS);
collector = ZeDebugInfoCollector::Create();
}
void DisableProfiling() {
if (collector != nullptr) {
collector->DisableTracing();
PrintResults();
delete collector;
}
}