forked from intel/pti-gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.cc
67 lines (54 loc) · 1.54 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
//==============================================================
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include "gpu_inst_count_collector.h"
static GpuInstCountCollector* collector = nullptr;
// External Tool Interface ////////////////////////////////////////////////////
extern "C"
#if defined(_WIN32)
__declspec(dllexport)
#endif
void Usage() {
std::cout <<
"Usage: ./gpu_inst_count[.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("ZET_ENABLE_API_TRACING_EXP", "1");
utils::SetEnv("ZET_ENABLE_PROGRAM_INSTRUMENTATION", "1");
}
// Internal Tool Functionality ////////////////////////////////////////////////
static void PrintResults() {
PTI_ASSERT(collector != nullptr);
const KernelDataMap& kernel_data_map = collector->GetKernelDataMap();
if (kernel_data_map.size() == 0) {
std::cerr << "[WARNING] No kernels were collected" << std::endl;
return;
}
std::cerr << std::endl;
GpuInstCountCollector::PrintResults(kernel_data_map);
}
// Internal Tool Interface ////////////////////////////////////////////////////
void EnableProfiling() {
PTI_ASSERT(collector == nullptr);
collector = GpuInstCountCollector::Create();
}
void DisableProfiling() {
if (collector != nullptr) {
PrintResults();
delete collector;
}
}