Improved analysis of functions to instrument + MPI support + timemory support (#2)
* various tweaks
* build updates + cleanup + overlap guard + min addr range
* Library source reorg + miscellaneous tweaks
* Removed unnecessary fwd decls
* Print address range in --print-X pair mode
- hosttrace modifications
- disable instrumenting functions with overlapping sections or multiple entry points by default (control via --allow-overlapping option)
- disable instrumenting functions whose address range < 512 bytes unless a loop is present by default (control via --min-address-range option)
- disable instrumenting functions w/ loops whose address range < 64 bytes (control via --min-loop-address-range)
- Support for wrapping MPI function calls even in binary rewrite mode
- e.g. use gotcha to wrap MPI functions with hosttrace_push_trace and hosttrace_pop_trace
- New timemory only mode --> HOSTTRACE_USE_TIMEMORY=ON
- New timemory + perfetto mode --> HOSTTRACE_USE_PERFETTO=ON + HOSTTRACE_USE_TIMEMORY=ON
- Full support for all timemory components
- parallel-overhead example for measuring the overhead in a MT-parallelized application with very small instrumentation functions
- improvements to output directories for hosttrace exe
- improvements to output directories for hosttrace library
- new hosttrace options
- --print-instrumented <type> prints out the instrumented entities and exits
- --print-available <type> prints out the available instrumentation entities and exits
- --print-overlapping <type> prints out the overlapping entities and exits
- NOTE: <type> above refers to the information printed out, e.g. module name vs. function name vs. module and function name, etc.
[ROCm/rocprofiler-systems commit: 1f15b3070f]
このコミットが含まれているのは:
@@ -4,3 +4,4 @@ project(hosttrace-dyninst-examples
|
||||
LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(transpose)
|
||||
add_subdirectory(parallel-overhead)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
add_executable(parallel-overhead parallel-overhead.cpp)
|
||||
target_link_libraries(parallel-overhead Threads::Threads)
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
std::atomic<long> total{ 0 };
|
||||
long
|
||||
fib(long n) __attribute__((noinline));
|
||||
void
|
||||
run(size_t nitr, long) __attribute__((noinline));
|
||||
|
||||
long
|
||||
fib(long n)
|
||||
{
|
||||
return (n < 2) ? n : fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
void
|
||||
run(size_t nitr, long n)
|
||||
{
|
||||
long local = 0;
|
||||
for(size_t i = 0; i < nitr; ++i)
|
||||
local += fib(n);
|
||||
total += local;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
size_t nthread = 16;
|
||||
size_t nitr = 50000;
|
||||
long nfib = 10;
|
||||
if(argc > 1)
|
||||
nfib = atol(argv[1]);
|
||||
if(argc > 2)
|
||||
nthread = atol(argv[2]);
|
||||
if(argc > 3)
|
||||
nitr = atol(argv[3]);
|
||||
|
||||
std::vector<std::thread> threads{};
|
||||
for(size_t i = 0; i < nthread; ++i)
|
||||
threads.emplace_back(&run, nitr, nfib);
|
||||
|
||||
for(auto& itr : threads)
|
||||
itr.join();
|
||||
|
||||
printf("fibonacci(%li) x %lu = %li\n", nfib, nthread, total.load());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -45,21 +45,33 @@ if(TARGET MPI::MPI_C)
|
||||
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} -lmpi")
|
||||
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_LIBDIR}/${_LDIR} ${_LINK_LIBS}")
|
||||
endif()
|
||||
set(_LIBDIR "${_LIBDIR_SAVE}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
if(MPI_C_LINK_FLAGS)
|
||||
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} ${MPI_C_LINK_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# remove generator expressions
|
||||
|
||||
@@ -155,11 +155,15 @@ run(int argc, char** argv)
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int rank = 0;
|
||||
#if defined(USE_MPI)
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
#endif
|
||||
run(argc, argv);
|
||||
if(rank == 0)
|
||||
run(argc, argv);
|
||||
#if defined(USE_MPI)
|
||||
MPI_Barrier(MPI_COMM_WORLD);
|
||||
MPI_Finalize();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする