Skip to content

Commit 6cd8f30

Browse files
authored
Move GTPin common code into utils directory (intel#50)
* Move common gtpin code to utils * Fix copyright * Version update
1 parent 9c9d7fc commit 6cd8f30

26 files changed

+243
-135
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.49.21
1+
0.49.22

chapters/binary_instrumentation/GTPin.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Binary Instrumentation with Graphics Technology Pin (GT Pin)
2+
3+
This chapter is outdated and describes deprecated interface GTPin v2. [Actual GTPin documentation](http://pin.iil.intel.com/pin/gtpin/Doxygen/html/)
4+
25
## Overview
36
This chapter describes **Graphics Technology Pin (GT Pin)** - the solution for binary code instrumentation on Intel(R) Processor Graphics. It is a [Pin](http://pintool.intel.com/) like system that instruments Gen execution unit (EU) binaries and is used to build architectural and software tools to analyze shaders or compute kernels running on Gen EUs.
47

samples/gpu_inst_count/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ if(CMAKE_INCLUDE_PATH)
2121
PUBLIC "${CMAKE_INCLUDE_PATH}")
2222
endif()
2323

24-
add_subdirectory(gtpin_dev_kit)
25-
FindGTPinDevKitHeaders(gput_inst_count)
26-
target_link_libraries(gput_inst_count gtpin_dev_kit)
24+
add_subdirectory("${PROJECT_SOURCE_DIR}/../../utils/gtpin_utils" gtpin_tool_utils)
25+
FindGTPinToolUtilsHeaders(gput_inst_count)
26+
target_link_libraries(gput_inst_count gtpin_tool_utils)
2727

2828
FindGTPinLibrary(gput_inst_count)
2929
FindGTPinHeaders(gput_inst_count)

samples/gpu_inst_count/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
This sample is a simple LD_PRELOAD based tool that allows to collect dynamic execution count for every OpenCL(TM) kernel instruction.
5+
This sample is a simple LD_PRELOAD based tool that allows to collect dynamic execution count for every GPU kernel instruction. The sample uses common code from utils/gtpin_utils.
66

77
As a result, assembly listing annotated with dynamic instruction count for each kernel will be printed.
88

@@ -83,10 +83,9 @@ As a result, assembly listing annotated with dynamic instruction count for each
8383

8484
## Prerequisites
8585

86-
- [CMake](https://cmake.org/) (version 3.12 and above)
86+
- [CMake](https://cmake.org/) (version 3.16 and above)
8787
- [Git](https://git-scm.com/) (version 1.8 and above)
88-
- [Python](https://www.python.org/) (version 2.7 and above)
89-
- [Graphics Technology Pin (GT Pin)](https://software.intel.com/content/www/us/en/develop/articles/gtpin.html)
88+
- [Graphics Technology Pin (GT Pin)](https://software.intel.com/content/www/us/en/develop/articles/gtpin.html) (version 3.7 and above)
9089

9190
## Build and Run
9291

samples/gpu_inst_count/gpu_inst_count.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
//==============================================================
2+
// Copyright (C) Intel Corporation
3+
//
4+
// SPDX-License-Identifier: MIT
5+
// =============================================================
16

27
#include "gpu_inst_count.hpp"
38

4-
using namespace gtpin_prof;
5-
using namespace gtpin;
9+
namespace gtpin {
10+
namespace gtpin_prof {
611

712
/********************
813
* Requered functions - should be implemented
@@ -61,7 +66,7 @@ PROF_STATUS GpuInstCountKernel::Instrument(IGtKernelInstrument& instrumentor) {
6166
GtGenProcedure proc;
6267
PointOfInterest poi(instrumentor, m_profileArray, bblIdx);
6368
poi.InstructionCounterAnalysis(offsetof(GpuInstCountRecord, count));
64-
poi.ClosePOI(proc);
69+
poi.FinishPOI(proc);
6570
instrumentor.InstrumentInstruction(it->second, GtIpoint::Before(), proc);
6671
}
6772

@@ -130,3 +135,6 @@ std::shared_ptr<InvocationData> GpuInstCountFactory::MakeInvocationData(
130135
std::shared_ptr<ResultData> GpuInstCountFactory::MakeResultData() {
131136
return std::make_shared<GpuInstCountResultData>();
132137
};
138+
139+
}
140+
}

samples/gpu_inst_count/gpu_inst_count.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//==============================================================
2+
// Copyright (C) Intel Corporation
3+
//
4+
// SPDX-License-Identifier: MIT
5+
// =============================================================
6+
17
#ifndef PLGG_GPU_INST_COUNT_H
28
#define PLGG_GPU_INST_COUNT_H
39

@@ -12,10 +18,9 @@
1218
* @file Header file for GTPin-based tool draft
1319
*/
1420

21+
namespace gtpin {
1522
namespace gtpin_prof {
1623

17-
using namespace gtpin;
18-
1924
/**
2025
* RESULTS classes
2126
* Extend tool-specific delivered classes with fields specific for the profiler.
@@ -146,5 +151,6 @@ class GpuInstCountProfiler : public GTPinProfilerBase {
146151
};
147152

148153
} // namespace gtpin_prof
154+
}
149155

150156
#endif // PLGG_GPU_INST_COUNT_H

samples/gpu_inst_count/gtpin_dev_kit/CMakeLists.txt

Lines changed: 0 additions & 33 deletions
This file was deleted.

samples/gpu_inst_count/tool.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "gpu_inst_count.hpp"
1212
#include "utils.h"
1313

14-
using namespace gtpin_prof;
1514
using namespace gtpin;
15+
using namespace gtpin_prof;
1616

1717
class GpuInstCountTxtWriter : public StreamGTPinDataWriter {
1818
public:

utils/gtpin_utils/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set(PTI_GTPIN_TOOL_BASE_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "")
2+
3+
include("../../build_utils/CMakeLists.txt")
4+
SetRequiredCMakeVersion()
5+
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})
6+
7+
macro(FindGTPinToolUtilsHeaders TARGET)
8+
target_include_directories(${TARGET}
9+
PUBLIC "${PTI_GTPIN_TOOL_BASE_DIR}/include")
10+
endmacro()
11+
12+
project(PTI_GTPin_tool_utils CXX)
13+
SetCompilerFlags()
14+
SetBuildType()
15+
16+
add_library(gtpin_tool_utils STATIC
17+
"${PTI_GTPIN_TOOL_BASE_DIR}/src/filter.cc"
18+
"${PTI_GTPIN_TOOL_BASE_DIR}/src/gtpin_capsules.cc"
19+
"${PTI_GTPIN_TOOL_BASE_DIR}/src/gtpin_tool.cc"
20+
"${PTI_GTPIN_TOOL_BASE_DIR}/src/prof_lib_gpu_gtpin.cc"
21+
"${PTI_GTPIN_TOOL_BASE_DIR}/src/writer.cc"
22+
)
23+
FindGTPinToolUtilsHeaders(gtpin_tool_utils)
24+
set_property(TARGET gtpin_tool_utils PROPERTY POSITION_INDEPENDENT_CODE ON)
25+
target_include_directories(gtpin_tool_utils
26+
PRIVATE "${PTI_GTPIN_TOOL_BASE_DIR}/../../sdk/src/utils")
27+
if(CMAKE_INCLUDE_PATH)
28+
target_include_directories(gtpin_tool_utils
29+
PUBLIC "${CMAKE_INCLUDE_PATH}")
30+
endif()
31+
32+
FindGTPinLibrary(gtpin_tool_utils)
33+
FindGTPinHeaders(gtpin_tool_utils)
34+
FindGTPinUtils(gtpin_tool_utils)

samples/gpu_inst_count/gtpin_dev_kit/include/def_gpu_gtpin.hpp renamed to utils/gtpin_utils/include/def_gpu_gtpin.hpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
#ifndef DEF_GPU_GTPIN_H
2-
#define DEF_GPU_GTPIN_H
1+
//==============================================================
2+
// Copyright (C) Intel Corporation
3+
//
4+
// SPDX-License-Identifier: MIT
5+
// =============================================================
6+
7+
#ifndef PTI_GTPIN_UTILS_H
8+
#define PTI_GTPIN_UTILS_H
39

410
#include <api/gtpin_api.h>
511
#include <stdint.h>
@@ -25,14 +31,13 @@
2531
#define MAX_SIMD_WIDTH 8 * MAX_SIMD_WIDTH_BYTES
2632
#define MAX_SIMD_WIDTH_STR STR(MAX_SIMD_WIDTH)
2733

28-
using namespace gtpin;
29-
34+
namespace gtpin {
3035
namespace gtpin_prof {
3136

3237
enum PROF_STATUS { PROF_STATUS_SUCCESS = 0, PROF_STATUS_ERROR, PROF_STATUS_NOTHING_TO_INSTRUMENT };
3338

3439
typedef uint32_t KernelRun;
35-
typedef uint32_t KernelId;
40+
typedef uint32_t KernelId; // TODO: rename into GTPin kernel ID
3641
typedef uint32_t InstructionOffset;
3742

3843
/**
@@ -88,18 +93,14 @@ struct GTPinKernelExecDesriptor : public KernelExecDesriptor {
8893

8994
GTPinKernelExecDesriptor(const IGtKernelDispatch& dispatcher, KernelRun runGlobalIdx,
9095
KernelRun runIdx = -1)
91-
: /// TODO: check that bug fixed, use next gtpinDispatchId instead of
92-
/// enqueue-based one gtpinDispatchId(dispatcher.DispatchId()),
93-
KernelExecDesriptor(dispatcher.Kernel().Name().Get(), dispatcher.Kernel().Id(),
94-
runGlobalIdx, runIdx) {
95-
GtKernelExecDesc execDesc;
96-
dispatcher.GetExecDescriptor(execDesc);
97-
gtpinDispatchId = execDesc.l0ExecDesc.enqueue_index;
98-
};
96+
: KernelExecDesriptor(dispatcher.Kernel().Name().Get(), dispatcher.Kernel().Id(),
97+
runGlobalIdx, runIdx),
98+
gtpinDispatchId(dispatcher.DispatchId()){};
9999

100100
uint64_t gtpinDispatchId = -1;
101101
};
102102

103103
} // namespace gtpin_prof
104+
} // namespace gtpin
104105

105-
#endif // DEF_GPU_GTPIN_H
106+
#endif // PTI_GTPIN_UTILS_H

0 commit comments

Comments
 (0)