Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 488651b

Browse files
committed
Adreno, PowerVR support for Android
Adreno support PowerVR support i915 - extended supported event set perf stacks collection on Linux dtrace stacks collection on OSX tasks from samples reconstruction python auto instrumentation extended with memory collection sea.py made python 2/3 compatible bin folder location is normalized between installed and developer versions installer cmake script part made cleared changed approach to Win symbols unwinding (made more efficient) added note about cmake to readme tests updated to collect stacks collection with stacks skips aliens by default (non-system-wide) added runtool execution tracing (for dbugging purposes) internal API: overlapped tasks support secure compilation flags verbose compilation mode for buildall.py added include and lib folders to installer bugfixes
1 parent e28cc2a commit 488651b

24 files changed

+1168
-630
lines changed

CMakeLists.txt

+139-17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cmake_minimum_required(VERSION 2.8)
1919

2020
project(IntelSEAPI)
2121

22+
set(CMAKE_MACOSX_RPATH 1)
2223
OPTION(JDK "Enable Java build")
2324
OPTION(FORCE_32 "Force a 32bit compile on 64bit" OFF)
2425

@@ -63,7 +64,7 @@ foreach (Flag ${Flags})
6364
message(STATUS "${Flag} = ${${Flag}}")
6465
endforeach()
6566

66-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
67+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../bin)
6768

6869
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
6970
set(LIBRARY_OUTPUT_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
@@ -99,36 +100,157 @@ else()
99100
endif()
100101
endif()
101102

102-
add_subdirectory(sea_itt_lib)
103-
add_subdirectory(ittnotify)
104-
105-
TARGET_LINK_LIBRARIES(IntelSEAPI ittnotify)
106103

107-
target_include_directories(IntelSEAPI
108-
PUBLIC ittnotify/include
109-
)
110104

111105
if (WIN32)
112106
TARGET_LINK_LIBRARIES(IntelSEAPI)
113-
if(NOT ARCH_64 AND CMAKE_BUILD_TYPE STREQUAL "Debug") #Compiler Automated Instrumentation
114-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gh /GH")
107+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /MP")
108+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
109+
110+
#SDL:
111+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /sdl")
112+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS /sdl")
113+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NXCompat /DynamicBase")
114+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NXCompat /DynamicBase")
115+
if(NOT ARCH_64)
116+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SafeSEH")
117+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SafeSEH")
115118
endif()
116-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi") #in release as well
119+
117120
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG") #in release as well
118121
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG") #in release as well
119122
elseif (APPLE)
120123
TARGET_LINK_LIBRARIES(IntelSEAPI dl)
121-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11 -fPIC -Wno-unused-parameter")
124+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11 -fPIC -Wno-unused-parameter -fstack-protector-strong -fPIE -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security")
125+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIE -Wl")
126+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -Wl")
122127
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
123128
elseif (ANDROID_NDK)
124129
TARGET_LINK_LIBRARIES(IntelSEAPI dl)
125-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIE -pthread")
126-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIE -pie -Wl,--no-undefined")
127-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
130+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIE -pthread -fstack-protector-strong -fPIE -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security")
131+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIE -pie -Wl,--no-undefined -z noexecstack -z relro -z now")
132+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie -Wl,--no-undefined -z noexecstack -z relro -z now")
133+
if (ARM AND ARCH_64)
134+
add_definitions(-DITT_ARCH=ITT_ARCH_PPC64)
135+
endif()
128136
else()
129137
TARGET_LINK_LIBRARIES(IntelSEAPI dl)
130-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -pthread")
131-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie -Wl,--no-undefined")
138+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -pthread -fstack-protector-strong -fPIE -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security")
139+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie -Wl,--no-undefined -z noexecstack -z relro -z now")
140+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie -Wl,--no-undefined -z noexecstack -z relro -z now")
141+
endif()
142+
143+
add_subdirectory(ittnotify)
144+
add_subdirectory(sea_itt_lib)
145+
if (WIN32)
146+
if(NOT ARCH_64 AND CMAKE_BUILD_TYPE STREQUAL "Debug") #Compiler Automated Instrumentation
147+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gh /GH")
148+
endif()
149+
else()
132150
#SET_TARGET_PROPERTIES(IntelSEAPI PROPERTIES COMPILE_FLAGS "-finstrument-functions")
133151
endif()
134152

153+
TARGET_LINK_LIBRARIES(IntelSEAPI ittnotify)
154+
155+
target_include_directories(IntelSEAPI
156+
PUBLIC ittnotify/include
157+
)
158+
159+
################################################### INSTALLER #########################################################
160+
161+
set(CPACK_PACKAGE_NAME "IntelSEAPI")
162+
set(CPACK_PACKAGE_VENDOR "Intel")
163+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Intel(R) Single Event API")
164+
set(CPACK_PACKAGE_VERSION "1.0.0")
165+
set(CPACK_PACKAGE_INSTALL_DIRECTORY "IntelSEAPI")
166+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Intel(R) Single Event API")
167+
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.txt")
168+
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/sea_itt_lib/Copyright.txt")
169+
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.txt")
170+
set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/README.txt")
171+
172+
install(
173+
FILES
174+
${PROJECT_SOURCE_DIR}/README.txt
175+
DESTINATION .
176+
)
177+
178+
install(
179+
DIRECTORY "${PROJECT_SOURCE_DIR}/ittnotify/include"
180+
DESTINATION .
181+
)
182+
183+
install(
184+
FILES
185+
"${PROJECT_SOURCE_DIR}/itt_notify.hpp"
186+
DESTINATION include
187+
)
188+
189+
set(SEA_PROJECT_BIN ${PROJECT_SOURCE_DIR}/bin)
190+
191+
function(InstallWildCard what where)
192+
install(
193+
CODE "
194+
file(GLOB SEA_INSTALL_FILES ${what})
195+
file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${where}\" TYPE FILE FILES \${SEA_INSTALL_FILES})
196+
string(REGEX REPLACE \";\" \"\\n\\t\\t\" SEA_INSTALL_FILES_MSG \"\${SEA_INSTALL_FILES}\")
197+
message(\"\\n###\tInstall ${what} to ${where}:\\n\\t\\t\${SEA_INSTALL_FILES_MSG}\")
198+
"
199+
)
200+
endfunction()
201+
202+
InstallWildCard("${PROJECT_SOURCE_DIR}/runtool/*.py" "runtool")
203+
InstallWildCard("${PROJECT_SOURCE_DIR}/runtool/importers/*.py" "runtool/importers")
204+
InstallWildCard("${PROJECT_SOURCE_DIR}/runtool/exporters/*.py" "runtool/exporters")
205+
InstallWildCard("${PROJECT_SOURCE_DIR}/runtool/collectors/*.py" "runtool/collectors")
206+
InstallWildCard("${PROJECT_SOURCE_DIR}/runtool/decoders/*.py" "runtool/decoders")
207+
208+
if (WIN32)
209+
InstallWildCard("${SEA_PROJECT_BIN}/*ittnotify*.lib" "lib")
210+
InstallWildCard("${SEA_PROJECT_BIN}/*.dll" "bin")
211+
InstallWildCard("${SEA_PROJECT_BIN}/*.exe" "bin")
212+
InstallWildCard("${SEA_PROJECT_BIN}/*.pdb" "bin")
213+
214+
install(
215+
FILES
216+
sea_itt_lib/IntelSEAPI.man
217+
sea_itt_lib/IntelSEAPI.wprp
218+
sea_itt_lib/IntelSEAPI_roi.xml
219+
sea_itt_lib/IntelSEAPI.wpaProfile
220+
sea_itt_lib/register.bat
221+
DESTINATION ETW
222+
)
223+
224+
set(CPACK_GENERATOR NSIS)
225+
226+
#run at exit:
227+
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "ETW")
228+
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "register.bat")
229+
set(CPACK_NSIS_DISPLAY_NAME "Intel(R) Single Event API")
230+
231+
set(CPACK_NSIS_CONTACT "[email protected]")
232+
233+
SET(CPACK_NSIS_INSTALL_ROOT "c:\\\\Intel")
234+
235+
else()
236+
237+
set(CPACK_BUNDLE_NAME "IntelSEAPI")
238+
set(CPACK_GENERATOR STGZ)
239+
install(
240+
DIRECTORY "${SEA_PROJECT_BIN}"
241+
DESTINATION .
242+
PATTERN "*.a" EXCLUDE
243+
)
244+
245+
InstallWildCard("${SEA_PROJECT_BIN}/*ittnotify*.a" "lib")
246+
247+
if(APPLE)
248+
install(
249+
FILES
250+
"${PROJECT_SOURCE_DIR}/sea_itt_lib/IntelSEAPI.instrument"
251+
DESTINATION dtrace
252+
)
253+
endif()
254+
endif()
255+
256+
include(CPack)

README.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ After your code is instrumented with itt, to load up the library follow these st
2222
OR you can use sea_runtool.py, see examples in test_<OS>.<bat/sh>
2323

2424
Bulding:
25+
Make sure you have cmake (https://cmake.org) in PATH
2526
All platforms except Android:
2627
>> python buildall.py -i
2728
this will produce installer
28-
on Windows requires Visual Studio 2013 and NSIS (http://nsis.sourceforge.net/) installed
29+
on Windows requires Visual Studio 2013 and NSIS (http://nsis.sourceforge.net) installed
2930
for Yocto just run this script in the Yocto build environment
3031
Android:
3132
requires ANDROID_NDK to be set in environment to the Android NDK path
@@ -54,7 +55,7 @@ Open Source Intel® SEAPI currently supports these formats:
5455
To enable: use systrace from AndroidStudio/Eclipse.
5556

5657
* Json google trace format - All platforms: https://www.chromium.org/developers/how-tos/trace-event-profiling-tool
57-
Cons: no correlation with OSX system events (yet)
58+
Cons: no concerns, excellent viewer
5859
Pros: any platform; Corellation with ftrace (Android, Yocto, Linux), ETW (Windows). Supported: object state tracing, counters, tasks (sync and async) - immediate and with clock domains...
5960
To enable set environment variable INTEL_SEA_SAVE_TO=<any path>/<trace name>
6061
Use runtool to transform the SEA directory into json format with next command:

buildall.py

+31-23
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_share_folder():
3333

3434

3535
def run_shell(cmd):
36-
print "\n>>", cmd
36+
print("\n>>", cmd)
3737
os.system(cmd)
3838

3939

@@ -47,14 +47,14 @@ def replace_in_file(file, what_by):
4747

4848

4949
def get_yocto():
50-
if not os.environ.has_key('CXX'):
50+
if 'CXX' not in os.environ:
5151
return None
5252
cxx = os.environ['CXX']
5353
if '-poky' not in cxx:
5454
return None
5555
if '-m32' in cxx:
56-
return {'bits':'32'}
57-
return {'bits':'64'}
56+
return {'bits': '32'}
57+
return {'bits': '64'}
5858

5959

6060
def GetJDKPath():
@@ -64,7 +64,7 @@ def GetJDKPath():
6464
try:
6565
aKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
6666
except WindowsError:
67-
print "No key:", path
67+
print("No key:", path)
6868
return None
6969
subkeys = []
7070
try:
@@ -75,22 +75,22 @@ def GetJDKPath():
7575
except WindowsError:
7676
pass
7777
if not subkeys:
78-
print "No subkeys for:", path
78+
print("No subkeys for:", path)
7979
return None
8080
subkeys.sort()
8181
path += "\\" + subkeys[-1]
8282
try:
8383
aKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
8484
return _winreg.QueryValueEx(aKey, "JavaHome")[0]
8585
except WindowsError:
86-
print "No value for:", path
86+
print("No value for:", path)
8787
return None
8888
else:
8989
path, err = subprocess.Popen("which javah", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
9090
if err or not path:
9191
return None
9292
if sys.platform == 'darwin':
93-
path = subprocess.check_output("/usr/libexec/java_home").split('\n')[0]
93+
path = subprocess.check_output("/usr/libexec/java_home").decode("utf-8").split('\n')[0]
9494
return path if os.path.exists(path) else None
9595
else:
9696
matches = []
@@ -161,7 +161,7 @@ def get_vs_versions():
161161
if int(version) >= 12:
162162
versions.append(version)
163163
if not versions:
164-
print "No Visual Studio version found"
164+
print("No Visual Studio version found")
165165
return sorted(versions)
166166

167167

@@ -175,6 +175,7 @@ def main():
175175
parser.add_argument("-a", "--android", action="store_true")
176176
parser.add_argument("--arm", action="store_true")
177177
parser.add_argument("-c", "--clean", action="store_true")
178+
parser.add_argument("-v", "--verbose", action="store_true")
178179
if sys.platform == 'win32' and vs_versions:
179180
parser.add_argument("--vs", choices=vs_versions, default=vs_versions[0])
180181
args = parser.parse_args()
@@ -185,27 +186,31 @@ def main():
185186
else:
186187
if not yocto:
187188
target_bits = ['64']
188-
if (sys.platform != 'darwin') or args.android: #on MAC OSX we produce FAT library including both 32 and 64 bits
189+
if (sys.platform != 'darwin') or args.android: # on MAC OSX we produce FAT library including both 32 and 64 bits
189190
target_bits.append('32')
190191
else:
191192
target_bits = [yocto['bits']]
192193

193-
print "target_bits", target_bits
194+
print("target_bits", target_bits)
194195

195196
jdk_path = GetJDKPath()
196-
print "Found JDK:", jdk_path
197+
print("Found JDK:", jdk_path)
197198

198199
work_dir = os.getcwd()
199-
print work_dir
200-
for bits in target_bits: #create separate build dirs
200+
print(work_dir)
201+
if args.clean:
202+
bin_dir = os.path.join(work_dir, 'bin')
203+
if os.path.exists(bin_dir):
204+
shutil.rmtree(bin_dir)
205+
for bits in target_bits: # create separate build dirs
201206
work_folder = os.path.join(work_dir, "build_" + ("android" if args.android else "yocto" if yocto else sys.platform.replace('32', "")), bits)
202207
already_there = os.path.exists(work_folder)
203208
if already_there and args.clean:
204209
shutil.rmtree(work_folder)
205210
already_there = False
206211
if not already_there:
207212
os.makedirs(work_folder)
208-
print work_folder
213+
print("work_folder: ", work_folder)
209214
os.chdir(work_folder)
210215

211216
if args.android:
@@ -221,11 +226,12 @@ def main():
221226
("-DANDROID_NDK=%s" % (os.environ['ANDROID_NDK'])),
222227
("-DCMAKE_BUILD_TYPE=%s" % ("Debug" if args.debug else "Release")),
223228
('-DANDROID_ABI="%s"' % abi),
224-
(('-DJDK="%s"' % jdk_path) if jdk_path else "")
229+
(('-DJDK="%s"' % jdk_path) if jdk_path else ""),
230+
('-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' if args.verbose else '')
225231
])))
226232
run_shell('cmake --build .')
227233
else:
228-
print "Set ANDROID_NDK environment to build Android!"
234+
print("Set ANDROID_NDK environment to build Android!")
229235
continue
230236
if sys.platform == 'win32':
231237
if vs_versions:
@@ -238,22 +244,24 @@ def main():
238244
("-DFORCE_32=ON" if bits == '32' else ""),
239245
("-DCMAKE_BUILD_TYPE=Debug" if args.debug else ""),
240246
("-DYOCTO=1" if yocto else ""),
241-
(('-DJDK="%s"' % jdk_path) if jdk_path else "")
247+
(('-DJDK="%s"' % jdk_path) if jdk_path else ""),
248+
('-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' if args.verbose else '')
242249
])))
243250
if sys.platform == 'win32':
244251
install = args.install and bits == target_bits[-1]
245-
target_project = 'PACKAGE' if install else 'ALL_BUILD' #making install only on last config, to pack them all
252+
target_project = 'PACKAGE' if install else 'ALL_BUILD' # making install only on last config, to pack them all
246253
run_shell('cmake --build . --config %s --target %s' % ('Debug' if args.debug else 'Release', target_project))
247254
if install:
248255
run_shell(r'echo f | xcopy "IntelSEAPI*.exe" "%s\IntelSEAPI.exe" /F' % get_share_folder())
249256
else:
250257
import glob
251-
run_shell('make -j4')
258+
run_shell('cmake --build . --config %s' % ('Debug' if args.debug else 'Release'))
252259
if not args.install or ('linux' in sys.platform and bits == '64'):
253-
continue #don't pack on first round, instead on the second pass collect all
254-
run_shell('cpack "%s"' % work_dir)
260+
continue # don't pack on first round, instead on the second pass collect all
261+
run_shell('cmake --build . --config %s --target package' % ('Debug' if args.debug else 'Release'))
262+
255263
installer = glob.glob(os.path.join(work_folder, "IntelSEAPI*.sh"))[0]
256-
print installer
264+
print(installer)
257265
if sys.platform == 'darwin':
258266
replace_in_file(installer, [
259267
('toplevel="`pwd`"', 'toplevel="/Applications"'),

0 commit comments

Comments
 (0)