diff --git a/projects/rocprofiler/bin/rocprofv2 b/projects/rocprofiler/bin/rocprofv2 index 41772bbef1..4fc0123c2f 100755 --- a/projects/rocprofiler/bin/rocprofv2 +++ b/projects/rocprofiler/bin/rocprofv2 @@ -155,7 +155,7 @@ while [ 1 ]; do export ROCPROFILER_ROCTX_TRACE=1 shift elif [ "$1" = "--roc-sys" ]; then - export ROCPROFILER_ENABLE_AMDSYS=$2 + export ROCPROFILER_ENABLE_ROCSYS=$2 shift shift elif [ "$1" = "--plugin" ]; then diff --git a/projects/rocprofiler/src/tools/rocsys/CMakeLists.txt b/projects/rocprofiler/src/tools/rocsys/CMakeLists.txt index df8e73fbc4..3b80921178 100644 --- a/projects/rocprofiler/src/tools/rocsys/CMakeLists.txt +++ b/projects/rocprofiler/src/tools/rocsys/CMakeLists.txt @@ -1,15 +1,18 @@ # ############################################################################################################################################ -# ROCProfiler AMDSYS Frontend +# ROCProfiler ROCSYS Frontend # ############################################################################################################################################ set(CMAKE_BINARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) # Getting Source files for RDC, Utils, Counters -file(GLOB ROCPROFILER_AMDSYS_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file(GLOB ROCPROFILER_ROCSYS_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) # Compiling/Installing ROCProfiler API -add_executable(rocprofiler_rocsys_fe ${ROCPROFILER_AMDSYS_SRC_FILES}) +add_executable(rocprofiler_rocsys_fe ${ROCPROFILER_ROCSYS_SRC_FILES}) -set_target_properties(rocprofiler_rocsys_fe PROPERTIES OUTPUT_NAME "rocsys") +set_target_properties( + rocprofiler_rocsys_fe + PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_OUTPUT_DIRECTORY} OUTPUT_NAME + "rocsys") target_include_directories( rocprofiler_rocsys_fe PRIVATE ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/projects/rocprofiler/src/tools/rocsys/rocsys.cpp b/projects/rocprofiler/src/tools/rocsys/rocsys.cpp index 2e1895069f..045a236dbf 100644 --- a/projects/rocprofiler/src/tools/rocsys/rocsys.cpp +++ b/projects/rocprofiler/src/tools/rocsys/rocsys.cpp @@ -36,8 +36,8 @@ #include /* -mpiexec -n 16 amdsys --session-new test launch python app.py -amdsys +mpiexec -n 16 rocsys --session-new test launch python app.py +rocsys */ namespace { @@ -84,13 +84,16 @@ int main(int argc, char* argv[]) { if (argc < 4) { perror( + "rocsys: launch must be preceeded by --session \n" + "e.g. rocsys --session launch rocprofv2\n\t " + " \n" + "where all mpiexec options must come before rocsys\n" "rocsys: start must be preceeded by --session \n\t" "rocsys --session start \n" "rocsys: stop must be preceeded by --session \n \t" "rocsys --session stop \n" - "rocsys: launch must be preceeded by --session-new \n \t" - "e.g. mpiexec -np 16 rocsys --session-new launch py app.py\n" - "where all mpiexec options must come before rocsys"); + "rocsys: exit must be preceeded by --session \n \t" + "rocsys --session exit \n"); exit(1); } @@ -117,7 +120,7 @@ int main(int argc, char* argv[]) { break; } - const char* shared_memory_key = "AMD_SYS_KEY"; + const char* shared_memory_key = "ROC_SYS_KEY"; const int SIZE = sizeof(int); @@ -152,14 +155,16 @@ int main(int argc, char* argv[]) { break; } else { report( + "rocsys: launch must be preceeded by --session \n" + "e.g. rocsys --session launch rocprofv2\n\t " + " \n" + "where all mpiexec options must come before rocsys\n" "rocsys: start must be preceeded by --session \n\t" "rocsys --session start \n" "rocsys: stop must be preceeded by --session \n \t" "rocsys --session stop \n" - "rocsys: launch must be preceeded by --session \n \t" - "e.g. rocsys --session launch rocprofv2 " - " \n" - "where all mpiexec options must come before rocsys\n", + "rocsys: exit must be preceeded by --session \n \t" + "rocsys --session exit \n", 1); } } diff --git a/projects/rocprofiler/src/tools/tool.cpp b/projects/rocprofiler/src/tools/tool.cpp index 3c7f535b66..49e5fee6f9 100644 --- a/projects/rocprofiler/src/tools/tool.cpp +++ b/projects/rocprofiler/src/tools/tool.cpp @@ -76,14 +76,14 @@ namespace { struct shmd_t { int command; }; -static const char* amd_sys_session_id; +static const char* roc_sys_session_id; static int shm_fd_sn = -1; struct shmd_t* shmd; uint64_t flush_interval, trace_time_length, trace_delay, trace_interval; std::thread wait_for_start_shm, flush_thread, trace_period_thread; -std::atomic amd_sys_handler{false}; +std::atomic roc_sys_handler{false}; std::atomic session_created{false}; std::atomic trace_period_thread_control{false}; std::atomic flush_thread_control{false}; @@ -401,10 +401,10 @@ void finish() { for ([[maybe_unused]] rocprofiler_buffer_id_t buffer_id : buffer_ids) { CHECK_ROCPROFILER(rocprofiler_flush_data(session_id, buffer_id)); } - if (amd_sys_handler.load(std::memory_order_acquire)) { - amd_sys_handler.exchange(false, std::memory_order_release); + if (roc_sys_handler.load(std::memory_order_acquire)) { + roc_sys_handler.exchange(false, std::memory_order_release); wait_for_start_shm.join(); - shm_unlink(std::to_string(*amd_sys_session_id).c_str()); + shm_unlink(std::to_string(*roc_sys_session_id).c_str()); } if (session_created.load(std::memory_order_acquire)) { session_created.exchange(false, std::memory_order_release); @@ -527,9 +527,9 @@ void sync_api_trace_callback(rocprofiler_record_tracer_t tracer_record, } } -void wait_for_amdsys() { - while (amd_sys_handler.load(std::memory_order_acquire)) { - shm_fd_sn = shm_open(amd_sys_session_id, O_RDONLY, 0666); +void wait_for_rocsys() { + while (roc_sys_handler.load(std::memory_order_acquire)) { + shm_fd_sn = shm_open(roc_sys_session_id, O_RDONLY, 0666); if (shm_fd_sn < 0) { continue; } @@ -539,15 +539,15 @@ void wait_for_amdsys() { switch (shmd->command) { // Start case 4: { - printf("AMDSYS:: Starting Tools Session...\n"); + printf("ROCSYS:: Starting Tools Session...\n"); CHECK_ROCPROFILER(rocprofiler_start_session(session_id)); session_created.exchange(true, std::memory_order_release); break; } // Stop case 5: { + printf("ROCSYS:: Stopping Tools Session...\n"); if (session_created.load(std::memory_order_acquire)) { - printf("AMDSYS:: Stopping Tools Session...\n"); session_created.exchange(false, std::memory_order_release); CHECK_ROCPROFILER(rocprofiler_terminate_session(session_id)); for ([[maybe_unused]] rocprofiler_buffer_id_t buffer_id : buffer_ids) { @@ -559,9 +559,8 @@ void wait_for_amdsys() { } // Exit case 6: { - printf("AMDSYS:: Exiting the Application..\n"); + printf("ROCSYS:: Exiting Tools Session...Application might still be finishng up..\n"); if (session_created.load(std::memory_order_acquire)) { - printf("AMDSYS:: Stopping Tools Session...\n"); session_created.exchange(false, std::memory_order_release); CHECK_ROCPROFILER(rocprofiler_terminate_session(session_id)); for ([[maybe_unused]] rocprofiler_buffer_id_t buffer_id : buffer_ids) { @@ -569,12 +568,12 @@ void wait_for_amdsys() { } rocprofiler::TraceBufferBase::FlushAll(); } - amd_sys_handler.exchange(false, std::memory_order_release); + roc_sys_handler.exchange(false, std::memory_order_release); flag = true; } } } - shm_unlink(amd_sys_session_id); + shm_unlink(roc_sys_session_id); if (flag) break; } } @@ -662,11 +661,11 @@ ROCPROFILER_EXPORT bool OnLoad(void* table, uint64_t runtime_version, uint64_t f std::atexit(finish); - amd_sys_session_id = getenv("ROCPROFILER_ENABLE_AMDSYS"); - if (amd_sys_session_id != nullptr) { - printf("AMDSYS Session Started!\n"); - wait_for_start_shm = std::thread{wait_for_amdsys}; - amd_sys_handler.exchange(true, std::memory_order_release); + roc_sys_session_id = getenv("ROCPROFILER_ENABLE_ROCSYS"); + if (roc_sys_session_id != nullptr) { + printf("ROCSYS Session Created!\n"); + wait_for_start_shm = std::thread{wait_for_rocsys}; + roc_sys_handler.exchange(true, std::memory_order_release); } CHECK_ROCPROFILER(rocprofiler_initialize()); @@ -876,7 +875,7 @@ ROCPROFILER_EXPORT bool OnLoad(void* table, uint64_t runtime_version, uint64_t f if (trace_time_length > 0) { trace_period_thread_control.exchange(true, std::memory_order_release); trace_period_thread = std::thread{trace_period_func}; - } else if (amd_sys_session_id == nullptr) { + } else if (roc_sys_session_id == nullptr) { CHECK_ROCPROFILER(rocprofiler_start_session(session_id)); session_created.exchange(true, std::memory_order_release); }