Integrated perfetto + roctracer (#5)
- hosttrace library automatically collects and merges timestamps for HIP API calls and kernels with the host-side instrumentation
- mostly eliminates the need for using external rocprof
- added thread_instruction_count in perfetto output
- increased hosttrace min_loop_address_range to 512
- disabled instrumenting functions with dynamic callsites by default
- miscellaneous cmake updates
* roctracer support
- fully integrated perfetto + roctracer outputs
- thread_instruction_count in perfetto
- increased min_loop_address_range to 512
- disabled instrumenting functions with dynamic callsites by default
- updated timemory submodule
* hosttrace_launch_compiler
- support for using an alternative compiler as needed via launch compiler
- elfio added as submodule (not currently used)
- miscellaneous cmake updates
* README update + host/device categories + misc
- timemory fix for TIMEMORY_ROCTRACER_ENABLED
- transpose fix
* papi_tuple_t -> papi_tot_ins
- minor fix to Findroctracer.cmake
[ROCm/rocprofiler-systems commit: a061b7947f]
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
7435122726
commit
244b308cb5
@@ -1,5 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
|
||||
project(hosttrace-parallel-overhead
|
||||
LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
find_package(Threads REQUIRED)
|
||||
add_executable(parallel-overhead parallel-overhead.cpp)
|
||||
target_link_libraries(parallel-overhead Threads::Threads)
|
||||
|
||||
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set_target_properties(transpose PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
@@ -1,106 +1,43 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
|
||||
# uses make to avoid CMAKE_CXX_COMPILER issues
|
||||
project(transpose
|
||||
project(hosttrace-transpose
|
||||
LANGUAGES CXX)
|
||||
|
||||
find_program(MAKE_EXECUTABLE NAMES make gmake)
|
||||
find_program(HIPCC_EXECUTABLE NAMES hipcc)
|
||||
|
||||
if(NOT MAKE_EXECUTABLE)
|
||||
message(AUTHOR_WARNING "make/gmake could not be found. Cannot build transpose target")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT HIPCC_EXECUTABLE)
|
||||
message(AUTHOR_WARNING "hipcc could not be found. Cannot build transpose target")
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
||||
set(transpose_CXX_FLAGS "-W -Wall ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}")
|
||||
set(transpose_LINK_FLAGS "")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG AND TARGET hosttrace::hosttrace-compile-options)
|
||||
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${hosttrace_CXX_FLAGS}")
|
||||
get_target_property(COMPILE_OPTS hosttrace::hosttrace-compile-options INTERFACE_COMPILE_OPTIONS)
|
||||
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${COMPILE_OPTS}")
|
||||
endif()
|
||||
|
||||
option(TRANSPOSE_USE_MPI "Enable MPI support in transpose exe" ${TIMEMORY_USE_MPI})
|
||||
|
||||
if(TRANSPOSE_USE_MPI)
|
||||
find_package(MPI REQUIRED)
|
||||
endif()
|
||||
|
||||
if(TARGET MPI::MPI_C)
|
||||
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} -DUSE_MPI")
|
||||
get_target_property(COMPILE_OPTS MPI::MPI_C INTERFACE_COMPILE_OPTIONS)
|
||||
foreach(_COPT ${COMPILE_OPTS})
|
||||
if(NOT "${_COPT}" MATCHES "COMPILE_LANG")
|
||||
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${_COPT}")
|
||||
endif()
|
||||
endforeach()
|
||||
get_target_property(INCLUDE_DIRS MPI::MPI_C INTERFACE_INCLUDE_DIRECTORIES)
|
||||
foreach(_IDIR ${INCLUDE_DIRS})
|
||||
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} -I${_IDIR}")
|
||||
endforeach()
|
||||
if(MPI_C_LINK_FLAGS)
|
||||
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} ${MPI_C_LINK_FLAGS}")
|
||||
endif()
|
||||
set(_LINK_LIBS "")
|
||||
foreach(_LIB ${MPI_C_LIB_NAMES})
|
||||
string(APPEND _LINK_LIBS "-l${_LIB} ")
|
||||
endforeach()
|
||||
foreach(_IDIR ${INCLUDE_DIRS} ${MPI_mpich_LIBRARY} ${MPI_mpi_LIBRARY} ${MPI_LIBRARY_DIRS})
|
||||
get_filename_component(_LIBDIR "${_IDIR}" DIRECTORY)
|
||||
if(EXISTS "${_IDIR}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_IDIR} ${_LINK_LIBS}")
|
||||
endif()
|
||||
if(EXISTS "${_LIBDIR}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_LIBDIR} ${_LINK_LIBS}")
|
||||
endif()
|
||||
foreach(_LDIR lib lib64)
|
||||
set(_LIBDIR_SAVE "${_LIBDIR}")
|
||||
if(NOT EXISTS "${_LIBDIR}/${_LDIR}")
|
||||
get_filename_component(_LIBDIR "${_LIBDIR}" DIRECTORY)
|
||||
endif()
|
||||
if(EXISTS "${_LIBDIR}/${_LDIR}")
|
||||
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_LIBDIR}/${_LDIR} ${_LINK_LIBS}")
|
||||
endif()
|
||||
set(_LIBDIR "${_LIBDIR_SAVE}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
add_executable(transpose transpose.cpp)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG AND TARGET hosttrace::hosttrace-compile-options)
|
||||
target_link_libraries(transpose PRIVATE hosttrace::hosttrace-compile-options)
|
||||
else()
|
||||
target_compile_options(transpose PRIVATE -W -Wall)
|
||||
endif()
|
||||
|
||||
# remove generator expressions
|
||||
string(REPLACE "$<" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
string(REPLACE ">:" ":" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
string(REPLACE ">" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
string(REPLACE "COMPILE_LANGUAGE:CXX:" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
# remove double spaces
|
||||
string(REPLACE " " " " transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
# convert to list
|
||||
string(REPLACE " " ";" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
# remove duplicate args
|
||||
list(REMOVE_DUPLICATES transpose_CXX_FLAGS)
|
||||
# make single string
|
||||
string(REPLACE ";" " " transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
|
||||
if(TRANSPOSE_USE_MPI)
|
||||
target_compile_definitions(transpose PRIVATE USE_MPI)
|
||||
target_link_libraries(transpose PRIVATE MPI::MPI_C)
|
||||
endif()
|
||||
|
||||
# configure files in build directory
|
||||
configure_file(${PROJECT_SOURCE_DIR}/transpose.cpp
|
||||
${CMAKE_BINARY_DIR}/transpose/transpose.cpp COPYONLY)
|
||||
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
set_target_properties(transpose PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/Makefile.in
|
||||
${CMAKE_BINARY_DIR}/transpose/Makefile @ONLY)
|
||||
|
||||
# touch the file when cmake re-runs to ensure rebuilt
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/transpose/transpose.cpp)
|
||||
|
||||
# target for adding a dependency to libpytimemory target
|
||||
add_custom_target(transpose ALL
|
||||
COMMAND ${MAKE_EXECUTABLE}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/transpose
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/transpose/transpose
|
||||
SOURCES ${CMAKE_BINARY_DIR}/transpose/transpose.cpp)
|
||||
if(NOT CMAKE_CXX_COMPILER_IS_HIPCC AND HIPCC_EXECUTABLE)
|
||||
# defined in MacroUtilities.cmake
|
||||
hosttrace_custom_compilation(
|
||||
COMPILER ${HIPCC_EXECUTABLE}
|
||||
TARGET transpose)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
CXXFLAGS += -std=c++17 -O3 -Wno-unused-result -g
|
||||
LINK_FLAGS :=
|
||||
|
||||
all: transpose
|
||||
|
||||
debug: CXXFLAGS += -ggdb -g
|
||||
debug: transpose
|
||||
|
||||
transpose: transpose.cpp
|
||||
hipcc ${CXXFLAGS} -o $@ $^ ${LINK_FLAGS}
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
run:
|
||||
./transpose
|
||||
|
||||
run.verbose:
|
||||
AMD_LOG_LEVEL=3, AMD_LOG_MASK=128 ./transpose
|
||||
|
||||
rd:
|
||||
rocgdb --args ./transpose
|
||||
|
||||
prof.trace:
|
||||
rocprof --hip-trace --stats ./transpose
|
||||
|
||||
prof:
|
||||
rocprof --obj-tracking on -i profile.txt ./transpose
|
||||
|
||||
prof.full:
|
||||
rocprof --obj-tracking on -i profile.txt -m custom_metric.xml ./transpose
|
||||
|
||||
callgrind:
|
||||
valgrind --tool=callgrind ./transpose
|
||||
|
||||
callgrind.ann:
|
||||
callgrind_annotate --inclusive=yes --tree=both callgrind.out.* > callgrind.out
|
||||
|
||||
clean:
|
||||
rm -f transpose *.o results.*
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
CXXFLAGS += -std=c++@CMAKE_CXX_STANDARD@ @transpose_CXX_FLAGS@
|
||||
LINKFLAGS := @transpose_LINK_FLAGS@
|
||||
|
||||
all: transpose
|
||||
|
||||
debug: CXXFLAGS += -ggdb -g
|
||||
debug: transpose
|
||||
|
||||
transpose: transpose.cpp
|
||||
hipcc ${CXXFLAGS} -o $@ $^ ${LINKFLAGS}
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
run:
|
||||
./transpose
|
||||
|
||||
run.verbose:
|
||||
AMD_LOG_LEVEL=3, AMD_LOG_MASK=128 ./transpose
|
||||
|
||||
rd:
|
||||
rocgdb --args ./transpose
|
||||
|
||||
prof.trace:
|
||||
rocprof --hip-trace --stats ./transpose
|
||||
|
||||
prof:
|
||||
rocprof --obj-tracking on -i profile.txt ./transpose
|
||||
|
||||
prof.full:
|
||||
rocprof --obj-tracking on -i profile.txt -m custom_metric.xml ./transpose
|
||||
|
||||
callgrind:
|
||||
valgrind --tool=callgrind ./transpose
|
||||
|
||||
callgrind.ann:
|
||||
callgrind_annotate --inclusive=yes --tree=both callgrind.out.* > callgrind.out
|
||||
|
||||
clean:
|
||||
rm -f transpose *.o results.*
|
||||
@@ -123,14 +123,15 @@ run(int argc, char** argv)
|
||||
for(size_t i = 0; i < times; i++)
|
||||
{
|
||||
hipLaunchKernelGGL(transpose_a, grid, block, 0, 0, in, out, M, N);
|
||||
check_hip_error();
|
||||
HIP_API_CALL(hipDeviceSynchronize());
|
||||
}
|
||||
check_hip_error();
|
||||
HIP_API_CALL(hipDeviceSynchronize());
|
||||
t2 = std::chrono::high_resolution_clock::now();
|
||||
double time =
|
||||
std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1).count();
|
||||
float GB = (float) size * times * 2 / (1 << 30);
|
||||
std::cout << "The average performance of transpose is " << GB / time << " GBytes/sec"
|
||||
std::cout << "Runtime of transpose is " << time << " sec\n"
|
||||
<< "The average performance of transpose is " << GB / time << " GBytes/sec"
|
||||
<< std::endl;
|
||||
|
||||
int* out_matrix = (int*) malloc(size);
|
||||
|
||||
Reference in New Issue
Block a user