diff --git a/projects/rocprofiler/CHANGELOG.md b/projects/rocprofiler/CHANGELOG.md index d347c3fe1f..ad7407ab4f 100644 --- a/projects/rocprofiler/CHANGELOG.md +++ b/projects/rocprofiler/CHANGELOG.md @@ -201,7 +201,7 @@ int main() { This can be built in the following manner: ```sh -$ gcc main.c -I/opt/rocm-5.6.0/include -L/opt/rocm-5.6.0/lib -lrocprofiler64-v2 +$ gcc main.c -I/opt/rocm-5.6.0/include -L/opt/rocm-5.6.0/lib -lrocprofiler64v2 ``` The resulting `a.out` will depend on diff --git a/projects/rocprofiler/CMakeLists.txt b/projects/rocprofiler/CMakeLists.txt index 8f94b58858..fbeab25369 100644 --- a/projects/rocprofiler/CMakeLists.txt +++ b/projects/rocprofiler/CMakeLists.txt @@ -411,7 +411,7 @@ if(${LIBRARY_TYPE} STREQUAL SHARED) # RPM package specific variable for ASAN set ( CPACK_RPM_ASAN_PACKAGE_NAME "${ROCPROFILER_NAME}-asan" ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES "hsa-rocr-asan, rocm-core-asan" ) - + # Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake if(NOT ROCM_DEP_ROCMCORE) string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_RUNTIME_PACKAGE_REQUIRES @@ -533,7 +533,7 @@ if(DOXYGEN_FOUND) install( DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html/" - DESTINATION ${CMAKE_INSTALL_DATADIR}/html/${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_DOCDIR}/html OPTIONAL COMPONENT docs) endif() diff --git a/projects/rocprofiler/samples/CMakeLists.txt b/projects/rocprofiler/samples/CMakeLists.txt index 38af39706b..8d2f918207 100644 --- a/projects/rocprofiler/samples/CMakeLists.txt +++ b/projects/rocprofiler/samples/CMakeLists.txt @@ -66,6 +66,15 @@ target_link_options(profiler_kernel_replay PRIVATE "-Wl,--build-id=md5") add_dependencies(samples profiler_kernel_replay) install(TARGETS profiler_kernel_replay RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) +## Build Kernel No Replay Sample +set_source_files_properties(profiler/kernel_profiling_no_replay_sample.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) +hip_add_executable(profiler_kernel_no_replay profiler/kernel_profiling_no_replay_sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) +target_include_directories(profiler_kernel_no_replay PRIVATE ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/common) +target_link_libraries(profiler_kernel_no_replay PRIVATE rocprofiler-v2 amd_comgr) +target_link_options(profiler_kernel_no_replay PRIVATE "-Wl,--build-id=md5") +add_dependencies(samples profiler_kernel_no_replay) +install(TARGETS profiler_kernel_no_replay RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) + ## Build User Replay Sample set_source_files_properties(profiler/user_replay_sample.cpp PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) hip_add_executable(profiler_user_replay profiler/user_replay_sample.cpp ${ROCPROFILER_UTIL_SRC_FILES}) @@ -163,7 +172,9 @@ check_c_source_compiles(" ${PROJECT_SOURCE_DIR}) target_link_options(pc_sampling_code_printing PRIVATE "-Wl,--build-id=md5") add_dependencies(samples pc_sampling_code_printing) - install(TARGETS pc_sampling_code_printing RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) + install(TARGETS pc_sampling_code_printing RUNTIME DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples COMPONENT samples) + + install(DIRECTORY "${PROJECT_SOURCE_DIR}/samples/" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/samples-src OPTIONAL COMPONENT samples) # ############################################################################################################################################ # Scripts to run samples diff --git a/projects/rocprofiler/samples/Makefile b/projects/rocprofiler/samples/Makefile index b36bb1b499..1a25a6ac33 100644 --- a/projects/rocprofiler/samples/Makefile +++ b/projects/rocprofiler/samples/Makefile @@ -1,18 +1,18 @@ ROCM_PATH ?=/opt/rocm ROCPROFILER_LIBS_PATH ?=$(ROCM_PATH)/lib ROCM_INCLUDES=-I$(ROCM_PATH)/include -ROCPROFILER_INCLUDES=-I$(ROCM_PATH)/include/rocprofiler/ +ROCPROFILER_INCLUDES=-I$(ROCPROFILER_LIBS_PATH)/../include/rocprofiler/ -LIBS=-L$(ROCPROFILER_LIBS_PATH) -lrocprofiler64 -lamd_comgr +LIBS=-L$(ROCPROFILER_LIBS_PATH) -lamd_comgr -lrocprofiler64v2 ifndef ROCPROFILER_LIBS_PATH $(warning You may need to set ROCPROFILER_LIBS_PATH to the path of the rocprofiler source) endif .PHONY: all -all: kernel_profiling_no_replay_sample device_profiling_sample kernel_replay_sample application_replay_sample user_replay_sample tracer_sample pc_sampler +all: profiler_kernel_no_replay profiler_device_profiling profiler_kernel_replay profiler_application_replay profiler_user_replay tracer_hip_hsa tracer_hip_hsa_async pcie_counters_sampler xgmi_counters_sampler pc_sampler -CXX=hipcc -std=c++17 -Wall +CXX=$(ROCM_PATH)/bin/hipcc -std=c++17 -Wall DEBUG=1 ifeq ($(DEBUG), 1) @@ -21,30 +21,39 @@ else CFLAGS=-DNDEBUG endif -kernel_profiling_no_replay_sample: profiler/kernel_profiling_no_replay_sample.cpp common/helper.cpp - $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(HIP_INCLUDES) $(CFLAGS) +profiler_kernel_no_replay: profiler/kernel_profiling_no_replay_sample.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) -device_profiling_sample: profiler/device_profiling_sample.cpp common/helper.cpp - $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(HIP_INCLUDES) $(CFLAGS) +profiler_device_profiling: profiler/device_profiling_sample.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) -kernel_replay_sample: profiler/kernel_replay_sample.cpp common/helper.cpp - $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(HIP_INCLUDES) $(CFLAGS) +profiler_kernel_replay: profiler/kernel_replay_sample.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) -application_replay_sample: profiler/application_replay_sample.cpp common/helper.cpp - $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(HIP_INCLUDES) $(CFLAGS) +profiler_application_replay: profiler/application_replay_sample.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) -user_replay_sample: profiler/user_replay_sample.cpp common/helper.cpp - $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(HIP_INCLUDES) $(CFLAGS) +profiler_user_replay: profiler/user_replay_sample.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) -tracer_sample: tracer/sample.cpp common/helper.cpp - $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(HIP_INCLUDES) $(CFLAGS) +tracer_hip_hsa: tracer/sample.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) -pc_sampler : +tracer_hip_hsa_async: tracer/sample_async.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) + +pcie_counters_sampler: counters_sampler/pcie_counters_example.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) + +xgmi_counters_sampler: counters_sampler/xgmi_counters_sampler_example.cpp common/helper.cpp + $(CXX) $^ $(LDFLAGS) -o $@ $(LIBS) $(ROCPROFILER_INCLUDES) $(ROCM_INCLUDES) $(CFLAGS) + +pc_sampler : cd pcsampler/code_printing_sample && $(MAKE) - + .PHONY: clean clean: - $(RM) -rf kernel_profiling_no_replay_sample device_profiling_sample kernel_replay_sample application_replay_sample user_replay_sample tracer_sample && cd pcsampler/code_printing_sample && $(MAKE) clean + $(RM) -rf xgmi_counters_sampler pcie_counters_sampler tracer_hip_hsa_async tracer_hip_hsa profiler_user_replay profiler_application_replay profiler_kernel_replay profiler_device_profiling profiler_kernel_no_replay && cd pcsampler/code_printing_sample && $(MAKE) clean diff --git a/projects/rocprofiler/samples/common/common.h b/projects/rocprofiler/samples/common/common.h index 16110894cd..e3ba9b05f8 100644 --- a/projects/rocprofiler/samples/common/common.h +++ b/projects/rocprofiler/samples/common/common.h @@ -200,8 +200,10 @@ void FlushTracerRecord(rocprofiler_record_tracer_t tracer_record, << tracer_record.timestamps.end.value; } output_file << "), Correlation ID(" << tracer_record.correlation_id.value << ")"; - if (roctx_id >= 0) output_file << ", ROCTX ID(" << roctx_id << ")"; - if (roctx_message.size() > 1) output_file << ", ROCTX Message(" << roctx_message << ")"; + if (tracer_record.domain == ACTIVITY_DOMAIN_ROCTX && roctx_id >= 0) + output_file << ", ROCTX ID(" << roctx_id << ")"; + if (tracer_record.domain == ACTIVITY_DOMAIN_ROCTX && roctx_message.size() > 1) + output_file << ", ROCTX Message(" << roctx_message << ")"; if (function_name.size() > 1) output_file << ", Function(" << function_name << ")"; if (kernel_name.size() > 1) output_file << ", Kernel Name(" << kernel_name.c_str() << ")"; output_file << std::endl; diff --git a/projects/rocprofiler/samples/pcsampler/code_printing_sample/Makefile b/projects/rocprofiler/samples/pcsampler/code_printing_sample/Makefile index 1efd3dec31..bdc38ae3a9 100644 --- a/projects/rocprofiler/samples/pcsampler/code_printing_sample/Makefile +++ b/projects/rocprofiler/samples/pcsampler/code_printing_sample/Makefile @@ -4,12 +4,14 @@ ROCM_PATH ?= /opt/rocm HIP_PATH ?= $(ROCM_PATH)/hip HIPCC := $(HIP_PATH)/bin/hipcc +ROCM_PATH ?=/opt/rocm +ROCPROFILER_LIBS_PATH ?=$(ROCM_PATH)/lib +ROCPROFILER_INCLUDES=$(ROCPROFILER_LIBS_PATH)/../include/rocprofiler/ + ifndef ROCPROFILER_PATH $(warning You may need to set ROCPROFILER_PATH to the path of the rocprofiler source) endif -ROCPROFILER_PATH ?= $(ROCM_PATH)/include/rocprofiler - CXXFLAGS += -std=c++17 -Wall ifdef DEBUG @@ -35,9 +37,9 @@ deps := $(srcs:%.cpp=%.d) CPPFLAGS += -DHAVE_MEMFD_CREATE $(prog): CC = $(HIPCC) -$(prog): CPPFLAGS += -I$(ROCM_PATH)/include -I$(ROCPROFILER_PATH) -$(prog): LDFLAGS := -L$(ROCM_PATH)/lib -L$(ROCPROFILER_PATH)/build -$(prog): LDLIBS += -ldl -lpthread -lhsa-runtime64 -lrocprofiler64 -lrocm-dbgapi -ldw -lelf +$(prog): CPPFLAGS += -I$(ROCPROFILER_INCLUDES) -I$(ROCM_PATH)/include +$(prog): LDFLAGS := -L$(ROCPROFILER_LIBS_PATH) -L$(ROCM_PATH)/lib +$(prog): LDLIBS += -ldl -lpthread -lhsa-runtime64 -lrocprofiler64v2 -lrocm-dbgapi -ldw -lelf $(objs): CXX = $(HIPCC) # Targets diff --git a/projects/rocprofiler/samples/run_samples.sh b/projects/rocprofiler/samples/run_samples.sh index 9aa4565263..6ff26d793a 100755 --- a/projects/rocprofiler/samples/run_samples.sh +++ b/projects/rocprofiler/samples/run_samples.sh @@ -1,28 +1,26 @@ #!/bin/bash -CURRENT_DIR="$( dirname -- "$0"; )"; +CURRENT_DIR=$(dirname -- $(realpath ${BASH_SOURCE[0]})); +ROCM_PATH="${ROCM_PATH:=/opt/rocm}" + echo -e "Running Samples" -export ROCPROFILER_METRICS_PATH=${CURRENT_DIR}/../counters/derived_counters.xml +export ROCPROFILER_METRICS_PATH=${ROCM_PATH}/libexec/rocprofiler/counters/derived_counters.xml echo -e "\tProfiler Samples:" -# echo -e "\t\tApplication Replay Sample:" -# eval ${CURRENT_DIR}/profiler_application_replay - echo -e "\t\tKernel Replay Sample:" eval ${CURRENT_DIR}/profiler_kernel_replay -# echo -e "\t\tUser Replay Sample:" -# eval ${CURRENT_DIR}/profiler_user_replay echo -e "\t\tDevice Profiling Sample:" eval ${CURRENT_DIR}/profiler_device_profiling +echo -e "\tTracer Samples:" -# echo -e "\tTracer Samples:" +echo -e "\t\tHIP/HSA Trace Synchronous Sample:" +eval ${CURRENT_DIR}/tracer_hip_hsa - -# echo -e "\t\tHIP/HSA Trace Sample:" -# eval ${CURRENT_DIR}/tracer_hip_hsa +echo -e "\t\tHIP/HSA Trace ASynchronous Sample:" +eval ${CURRENT_DIR}/tracer_hip_hsa_async \ No newline at end of file