-
Notifications
You must be signed in to change notification settings - Fork 56
/
tool.cc
55 lines (41 loc) · 1.5 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
//==============================================================
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include "cl_debug_info_collector.h"
static ClDebugInfoCollector* collector = nullptr;
// External Tool Interface ////////////////////////////////////////////////////
extern "C" PTI_EXPORT void Usage() {
std::cout << "Usage: ./cl_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() {}
// 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) {
ClDebugInfoCollector::PrintKernelDebugInfo(pair.first, pair.second);
}
}
// Internal Tool Interface ////////////////////////////////////////////////////
void EnableProfiling() {
cl_device_id device = utils::cl::GetIntelDevice(CL_DEVICE_TYPE_GPU);
if (device == nullptr) {
std::cerr << "[WARNING] Unable to find target GPU device for tracing" << std::endl;
return;
}
collector = ClDebugInfoCollector::Create(device);
}
void DisableProfiling() {
if (collector != nullptr) {
collector->DisableTracing();
PrintResults();
delete collector;
}
}