forked from intel/pti-gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.cc
71 lines (58 loc) · 1.59 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//==============================================================
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include "ze_debug_info_collector.h"
static ZeDebugInfoCollector* collector = nullptr;
// External Tool Interface ////////////////////////////////////////////////////
extern "C"
#if defined(_WIN32)
__declspec(dllexport)
#endif
void Usage() {
std::cout <<
"Usage: ./ze_debug_info[.exe] <application> <args>" <<
std::endl;
}
extern "C"
#if defined(_WIN32)
__declspec(dllexport)
#endif
int ParseArgs(int argc, char* argv[]) {
return 1;
}
extern "C"
#if defined(_WIN32)
__declspec(dllexport)
#endif
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;
}
}