build normalizing - generating under build directory

Change-Id: Id9203aec7800024bd749059a415fb29b8051005a


[ROCm/roctracer commit: ed1f1b66ac]
This commit is contained in:
Evgeny
2020-09-07 13:50:10 -05:00
orang tua 1b73058fb7
melakukan a547e615e3
10 mengubah file dengan 69 tambahan dan 61 penghapusan
+9 -2
Melihat File
@@ -100,12 +100,14 @@ set ( PUBLIC_HEADERS
roctracer_kfd.h
roctracer_roctx.h
roctracer_cb_table.h
ext/prof_protocol.h
ext/hsa_rt_utils.hpp
)
set ( GEN_HEADERS
hip_ostream_ops.h
hsa_prof_str.h
kfd_ostream_ops.h
kfd_prof_str.h
ext/prof_protocol.h
ext/hsa_rt_utils.hpp
)
if ( ${LIBRARY_TYPE} STREQUAL SHARED )
@@ -137,6 +139,11 @@ foreach ( header ${PUBLIC_HEADERS} )
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/${header} DESTINATION ${DEST_NAME}/include/${header_subdir} )
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/${header} DESTINATION include/${DEST_NAME}/${header_subdir} )
endforeach ()
foreach ( header ${GEN_HEADERS} )
get_filename_component ( header_subdir ${header} DIRECTORY )
install ( FILES ${PROJECT_BINARY_DIR}/inc/${header} DESTINATION ${DEST_NAME}/include/${header_subdir} )
install ( FILES ${PROJECT_BINARY_DIR}/inc/${header} DESTINATION include/${DEST_NAME}/${header_subdir} )
endforeach ()
#install ( FILES ${PROJECT_BINARY_DIR}/inc-link DESTINATION include RENAME ${DEST_NAME} )
install ( FILES ${PROJECT_BINARY_DIR}/so-link DESTINATION lib RENAME ${ROCTRACER_LIBRARY}.so )
install ( FILES ${PROJECT_BINARY_DIR}/so-major-link DESTINATION lib RENAME ${ROCTRACER_LIBRARY}.so.${LIB_VERSION_MAJOR} )
+1 -1
Melihat File
@@ -1,4 +1,4 @@
#!/bin/bash -x
#!/bin/bash -e
SRC_DIR=`dirname $0`
COMPONENT="roctracer"
ROCM_PATH="${ROCM_PATH:=/opt/rocm}"
+3 -3
Melihat File
@@ -490,15 +490,15 @@ class API_DescrParser:
# main
# Usage
if len(sys.argv) != 3:
print ("Usage:", sys.argv[0], " <rocTracer root> <HSA runtime include path>", file=sys.stderr)
print ("Usage:", sys.argv[0], " <OUT prefix> <HSA runtime include path>", file=sys.stderr)
sys.exit(1)
else:
ROOT = sys.argv[1] + '/'
PREFIX = sys.argv[1] + '/'
HSA_DIR = sys.argv[2] + '/'
descr = API_DescrParser(OUT, HSA_DIR, API_TABLES_H, API_HEADERS_H, LICENSE)
out_file = ROOT + OUT
out_file = PREFIX + OUT
print ('Generating "' + out_file + '"')
f = open(out_file, 'w')
f.write(descr.content[:-1])
+30 -30
Melihat File
@@ -2,10 +2,10 @@
from __future__ import print_function
import os, sys, re
OUT_H = 'inc/kfd_prof_str.h'
OUT_CPP = 'src/kfd/kfd_wrapper.cpp'
API_HEADERS_H = (
('HSAKMTAPI', 'hsakmt.h'),
OUT_H = 'inc/kfd_prof_str.h'
OUT_CPP = 'src/kfd_wrapper.cpp'
API_HEADERS_H = (
('HSAKMTAPI', 'hsakmt.h'),
)
LICENSE = \
@@ -38,7 +38,7 @@ def fatal(module, msg):
sys.exit(1)
# Get next text block
def NextBlock(pos, record):
def NextBlock(pos, record):
if len(record) == 0: return pos
space_pattern = re.compile(r'(\s+)')
@@ -82,8 +82,8 @@ class API_TableParser:
self.inp = open(header, 'r')
self.beg_pattern = re.compile(name)
self.end_pattern = re.compile('.*\)\s*;\s*$');
self.beg_pattern = re.compile(name)
self.end_pattern = re.compile('.*\)\s*;\s*$');
self.array = []
self.parse()
@@ -92,10 +92,10 @@ class API_TableParser:
return re.sub(r'^\s+', r' ', line)
def fix_comment_line(self, line):
return re.sub(r'\/\/.*', r'', line)
return re.sub(r'\/\/.*', r'', line)
def remove_ret_line(self, line):
return re.sub(r'\n', r'', line)
return re.sub(r'\n', r'', line)
# check for start record
def is_start(self, record):
@@ -107,7 +107,7 @@ class API_TableParser:
# check for declaration entry record
def is_entry(self, record):
return re.match(r'^\s*HSAKMTAPI\s*(.*)\s*\((.*)\)', record)
return re.match(r'^\s*HSAKMTAPI\s*(.*)\s*\((.*)\)', record)
# parse method
def parse(self):
@@ -121,7 +121,7 @@ class API_TableParser:
line = self.norm_line(line)
line = self.fix_comment_line(line)
if cumulate == 1: record += " " + line;
if cumulate == 1: record += " " + line;
else: record = line;
if self.is_start(line): rettype = prev_line.strip(); cumulate = 1; prev_line = line; continue;
if self.is_end(line): record = self.remove_ret_line(record); cumulate = 0; active = 1;
@@ -132,7 +132,7 @@ class API_TableParser:
mycall_full = rettype + " " + m.group(1) + ' (' + m.group(2) + ')'
mycall = m.group(1)
self.full_fct[mycall] = mycall_full
self.array.append(mycall)
self.array.append(mycall)
rettype = "";
prev_line = line
@@ -173,7 +173,7 @@ class API_DeclParser:
struct = {'ret': '', 'args': '', 'astr': {}, 'alst': [], 'tlst': []}
record = re.sub(r'^\s+', r'', record)
record = re.sub(r'\s*(\*+)\s*', r'\1 ', record)
rind = NextBlock(0, record)
rind = NextBlock(0, record)
struct['ret'] = record[0:rind]
pos = record.find('(')
end = NextBlock(pos, record);
@@ -184,7 +184,7 @@ class API_DeclParser:
struct['args'] = re.sub(r',', r', ', args)
if args == "void":
return struct
if len(args) == 0: return struct
pos = 0
@@ -217,7 +217,7 @@ class API_DeclParser:
# parse given api
def parse(self, call, full_fct):
if call in full_fct:
if call in full_fct:
self.data[call] = self.get_args(full_fct[call])
else:
self.data[call] = self.get_args(call)
@@ -238,7 +238,7 @@ class API_DescrParser:
self.api_calls = {}
self.api_rettypes = set()
self.api_id = {}
api_data = {}
full_fct = {}
api_list = []
@@ -271,7 +271,7 @@ class API_DescrParser:
self.ns_calls = ns_calls
self.content_h += "// automatically generated\n\n" + license + '\n'
self.content_h += "/////////////////////////////////////////////////////////////////////////////\n"
for call in self.ns_calls:
self.content_h += '// ' + call + ' was not parsed\n'
@@ -298,7 +298,7 @@ class API_DescrParser:
self.content_h += 'namespace kfd_support {\n'
self.add_section('API get_name function', ' ', self.gen_get_name)
self.add_section('API get_code function', ' ', self.gen_get_code)
self.add_section('API get_code function', ' ', self.gen_get_code)
self.add_section('API intercepting code', '', self.gen_intercept_decl)
self.add_section('API intercepting code', '', self.gen_intercept)
@@ -369,7 +369,7 @@ class API_DescrParser:
self.content_h += ' KFD_API_ID_NUMBER = ' + str(n) + ',\n'
self.content_h += ' KFD_API_ID_ANY = ' + str(n + 1) + ',\n'
self.content_h += '};\n'
# generate API args structure
def gen_arg_struct(self, n, name, call, struct):
if n == -1:
@@ -396,7 +396,7 @@ class API_DescrParser:
else:
self.content_h += ' } args;\n'
self.content_h += '} kfd_api_data_t;\n'
# generate API callbacks
def gen_callbacks(self, n, name, call, struct):
if n == -1:
@@ -406,7 +406,7 @@ class API_DescrParser:
if call != '-':
call_id = self.api_id[call];
ret_type = struct['ret']
self.content_h += ret_type + ' ' + call + '_callback(' + struct['args'] + ') {\n' # 'static ' +
self.content_h += ret_type + ' ' + call + '_callback(' + struct['args'] + ') {\n' # 'static ' +
self.content_h += ' if (' + name + '_table == NULL) intercept_KFDApiTable();\n'
self.content_h += ' kfd_api_data_t api_data{};\n'
for var in struct['alst']:
@@ -448,7 +448,7 @@ class API_DescrParser:
if call != '-':
self.content_h += ' typedef decltype(' + name + '_table_t::' + call + '_fn) ' + call + '_t;\n'
self.content_h += ' ' + name + '_table->' + call + '_fn = (' + call + '_t)' + 'dlsym(RTLD_NEXT,\"' + call + '\");\n'
self.content_h += ' ' + name + '_table->' + call + '_fn = (' + call + '_t)' + 'dlsym(RTLD_NEXT,\"' + call + '\");\n'
# generate API name function
def gen_get_name(self, n, name, call, struct):
@@ -493,7 +493,7 @@ class API_DescrParser:
arg_var = arg_list[ind]
arg_val = 'api_data.args.' + call + '.' + arg_var
if re.search(r'MemFlags',arg_var):
continue
continue
self.content_h += ' typedef decltype(' + arg_val.replace("[]","") + ') arg_val_type_t' + str(ind) + ';\n'
self.content_h += ' roctracer::kfd_support::output_streamer<arg_val_type_t' + str(ind) + '>::put(out, ' + arg_val.replace("[]","") + ')'
if ind < len(arg_list)-1: self.content_h += ' << ", ";\n'
@@ -510,11 +510,11 @@ class API_DescrParser:
self.content_h += ' abort();\n'
self.content_h += ' }\n'
self.content_h += ' return out;\n'
self.content_h += '}\n'
self.content_h += '}\n'
self.content_h += '#endif\n'
self.content_cpp += 'inline std::ostream& operator<< (std::ostream& out, const HsaMemFlags& v) { out << "HsaMemFlags"; return out; }\n'
self.content_cpp += 'inline std::ostream& operator<< (std::ostream& out, const HsaMemFlags& v) { out << "HsaMemFlags"; return out; }\n'
# generate PUBLIC_API for all API fcts
# generate PUBLIC_API for all API fcts
def gen_public_api(self, n, name, call, struct):
if n == -1:
self.content_cpp += 'extern "C" {\n'
@@ -540,21 +540,21 @@ class API_DescrParser:
# main
# Usage
if len(sys.argv) != 3:
print ("Usage:", sys.argv[0], " <rocTracer root> <KFD include path>", file = sys.stderr)
print ("Usage:", sys.argv[0], " <OUT prefix> <KFD include path>", file = sys.stderr)
sys.exit(1)
else:
ROOT = sys.argv[1] + '/'
PREFIX = sys.argv[1] + '/'
KFD_DIR = sys.argv[2] + '/'
descr = API_DescrParser(OUT_H, KFD_DIR, API_HEADERS_H, LICENSE)
out_file = ROOT + OUT_H
out_file = PREFIX + OUT_H
print ('Generating "' + out_file + '"')
f = open(out_file, 'w')
f.write(descr.content_h[:-1])
f.close()
out_file = ROOT + OUT_CPP
out_file = PREFIX + OUT_CPP
print ('Generating "' + out_file + '"')
f = open(out_file, 'w')
f.write(descr.content_cpp[:-1])
+21 -20
Melihat File
@@ -1,7 +1,19 @@
#
# Generating tracing primitives
set ( GEN_INC_DIR ${PROJECT_BINARY_DIR}/inc )
set ( GEN_SRC_DIR ${PROJECT_BINARY_DIR}/src )
execute_process ( COMMAND sh -xc "mkdir -p ${GEN_INC_DIR}" )
execute_process ( COMMAND sh -xc "mkdir -p ${GEN_SRC_DIR}" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/hsaap.py ${PROJECT_BINARY_DIR} ${HSA_RUNTIME_INC_PATH}" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/kfdap.py ${PROJECT_BINARY_DIR} ${HSA_KMT_INC_PATH}" )
execute_process ( COMMAND sh -xc "${CMAKE_C_COMPILER} -E ${HSA_KMT_INC_PATH}/hsakmttypes.h > ${GEN_INC_DIR}/hsakmttypes_pp.h" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/gen_ostream_ops.py -in ${GEN_INC_DIR}/hsakmttypes_pp.h -out ${GEN_INC_DIR}/kfd_ostream_ops.h" )
execute_process ( COMMAND sh -xc "${CMAKE_C_COMPILER} -E ${HIP_PATH}/include/hip/hip_runtime_api.h ${HIP_DEFINES} -I${HIP_PATH}/include -I${ROCM_ROOT_DIR}/hsa/include > ${GEN_INC_DIR}/hip_runtime_api_pp.h" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/gen_ostream_ops.py -in ${GEN_INC_DIR}/hip_runtime_api_pp.h -out ${GEN_INC_DIR}/hip_ostream_ops.h" )
execute_process ( COMMAND sh -xc "${CMAKE_C_COMPILER} -E ${HSA_RUNTIME_INC_PATH}/hsa.h > ${GEN_INC_DIR}/hsa_pp.h" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/gen_ostream_ops.py -in ${GEN_INC_DIR}/hsa_pp.h -out ${GEN_INC_DIR}/hsa_ostream_ops.h" )
# Build dynamic Library object
#
set ( TARGET_LIB "${TARGET_NAME}" )
set ( TARGET_LIB ${TARGET_NAME} )
set ( LIB_SRC
${LIB_DIR}/core/roctracer.cpp
${LIB_DIR}/proxy/proxy_queue.cpp
@@ -10,33 +22,22 @@ set ( LIB_SRC
${LIB_DIR}/util/hsa_rsrc_factory.cpp
)
add_library ( ${TARGET_LIB} ${LIBRARY_TYPE} ${LIB_SRC} )
target_include_directories ( ${TARGET_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${HIP_INC_DIR} ${HCC_INC_DIR} ${HSA_KMT_INC_PATH} )
target_include_directories ( ${TARGET_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${HIP_INC_DIR} ${HCC_INC_DIR} ${HSA_KMT_INC_PATH} ${GEN_INC_DIR} )
target_link_libraries( ${TARGET_LIB} PRIVATE ${HSA_RUNTIME_LIB} c stdc++ )
# Generating HSA tracing primitives
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/hsaap.py ${ROOT_DIR} ${HSA_RUNTIME_INC_PATH}" )
# Generating KFD/Thunk tracing primitives
# Build KFD/Thunk tracing library
set ( KFD_LIB "kfdwrapper64" )
set ( KFD_LIB_SRC
${LIB_DIR}/kfd/kfd_wrapper.cpp
)
execute_process ( COMMAND sh -xc "${CMAKE_CXX_COMPILER} -E ${HSA_KMT_INC_PATH}/hsakmttypes.h > ${PROJECT_BINARY_DIR}/hsakmttypes_pp.h" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/gen_ostream_ops.py -in ${PROJECT_BINARY_DIR}/hsakmttypes_pp.h -out ${ROOT_DIR}/inc/kfd_ostream_ops.h" )
execute_process ( COMMAND sh -xc "${CMAKE_C_COMPILER} ${HIP_DEFINES} -I${HIP_PATH}/include -I${ROCM_ROOT_DIR}/hsa/include -E ${HIP_PATH}/include/hip/hip_runtime_api.h > ${PROJECT_BINARY_DIR}/hip_runtime_api_pp.h" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/gen_ostream_ops.py -in ${PROJECT_BINARY_DIR}/hip_runtime_api_pp.h -out ${ROOT_DIR}/inc/hip_ostream_ops.h" )
execute_process ( COMMAND sh -xc "${CMAKE_C_COMPILER} -E ${HSA_RUNTIME_INC_PATH}/hsa.h > ${PROJECT_BINARY_DIR}/hsa_pp.h" )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/gen_ostream_ops.py -in ${PROJECT_BINARY_DIR}/hsa_pp.h -out ${ROOT_DIR}/inc/hsa_ostream_ops.h" )
set ( KFD_LIB_SRC ${GEN_SRC_DIR}/kfd_wrapper.cpp)
add_library ( ${KFD_LIB} SHARED ${KFD_LIB_SRC} )
target_include_directories ( ${KFD_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${HSA_KMT_INC_PATH} )
target_include_directories ( ${KFD_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${HSA_KMT_INC_PATH} ${GEN_INC_DIR} )
target_link_libraries( ${KFD_LIB} PRIVATE c stdc++ )
execute_process ( COMMAND sh -xc "${ROOT_DIR}/script/kfdap.py ${ROOT_DIR} ${HSA_KMT_INC_PATH}" )
# Build ROCTX tracing library
set ( ROCTX_LIB "roctx64" )
set ( ROCTX_LIB_SRC
${LIB_DIR}/roctx/roctx.cpp
${LIB_DIR}/roctx/roctx_intercept.cpp
)
add_library ( ${ROCTX_LIB} SHARED ${ROCTX_LIB_SRC} )
target_include_directories ( ${ROCTX_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} )
target_include_directories ( ${ROCTX_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${GEN_INC_DIR} )
target_link_libraries( ${ROCTX_LIB} PRIVATE c stdc++ )
-1
Melihat File
@@ -1 +0,0 @@
kfd_wrapper.cpp
+2 -1
Melihat File
@@ -50,6 +50,7 @@ set ( HSA_REV "a657002" )
set ( RUN_SCRIPT "${TEST_DIR}/run.sh" )
## build HIP tests
set ( INC_PATH "${INC_PATH} ${PROJECT_BINARY_DIR}/inc" )
set ( TEST_ENV HIP_VDI=${HIP_VDI} ROCM_PATH=${ROCM_ROOT_DIR} HSA_PATH=${ROCM_ROOT_DIR}/hsa INC_PATH=${INC_PATH} LIB_PATH=${LIB_PATH} HIPCC_VERBOSE=3 )
add_custom_target( mytest
COMMAND ${TEST_ENV} make -C "${TEST_DIR}/MatrixTranspose"
@@ -75,7 +76,7 @@ if ( DEFINED ROCTRACER_TARGET )
set ( TEST_LIB "tracer_tool" )
set ( TEST_LIB_SRC ${TEST_DIR}/tool/tracer_tool.cpp ${UTIL_SRC} )
add_library ( ${TEST_LIB} SHARED ${TEST_LIB_SRC} )
target_include_directories ( ${TEST_LIB} PRIVATE ${HSA_TEST_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${HIP_INC_DIR} ${HCC_INC_DIR} ${HSA_KMT_INC_PATH} )
target_include_directories ( ${TEST_LIB} PRIVATE ${HSA_TEST_DIR} ${ROOT_DIR} ${ROOT_DIR}/inc ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_HSA_INC_PATH} ${HIP_INC_DIR} ${HCC_INC_DIR} ${HSA_KMT_INC_PATH} ${PROJECT_BINARY_DIR}/inc )
target_link_libraries ( ${TEST_LIB} ${ROCTRACER_TARGET} ${HSA_RUNTIME_LIB} c stdc++ dl pthread rt )
endif ()
@@ -23,7 +23,7 @@ EXECUTABLE=./MatrixTranspose
all: clean $(EXECUTABLE)
CXXFLAGS =-g -I$(INC_PATH) -DLOCAL_BUILD=1 --rocm-path=$(ROCM_PATH)
CXXFLAGS =-g $(INC_PATH:%=-I%) -DLOCAL_BUILD=1 --rocm-path=$(ROCM_PATH)
CXX=$(HIPCC)
$(EXECUTABLE): $(OBJECTS)
@@ -17,7 +17,7 @@ TARGET=hcc
EXECUTABLE=./MatrixTranspose
OBJECTS = MatrixTranspose.o
FLAGS =-g -I$(INC_PATH) -I$(ROCM_PATH)/hsa/include/hsa -I$(ROCM_PATH)/hsa/include -I$(ROCM_PATH)/hip/include -I$(ROCM_PATH)/include -DLOCAL_BUILD=1 -DHIP_VDI=${HIP_VDI} -DITERATIONS=$(ITERATIONS) -DAMD_INTERNAL_BUILD=1
FLAGS =-g $(INC_PATH:%=-I%) -I$(ROCM_PATH)/hsa/include/hsa -I$(ROCM_PATH)/hsa/include -I$(ROCM_PATH)/hip/include -I$(ROCM_PATH)/include -DLOCAL_BUILD=1 -DHIP_VDI=${HIP_VDI} -DITERATIONS=$(ITERATIONS) -DAMD_INTERNAL_BUILD=1
ifeq ($(C_TEST), 1)
COMP=${CC}
+1 -1
Melihat File
@@ -1,4 +1,4 @@
#!/bin/sh -x
#!/bin/sh
################################################################################
# Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.