Fixing usability for rocsys
Change-Id: Ic2f3c4bdc5e6eb89c03799410ee16d27de035c97
[ROCm/rocprofiler commit: 1d8401dec8]
Αυτή η υποβολή περιλαμβάνεται σε:
υποβλήθηκε από
Gopesh Bhardwaj
γονέας
cc8bf264c7
υποβολή
d287152244
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#include <experimental/filesystem>
|
||||
|
||||
/*
|
||||
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 <name>\n"
|
||||
"e.g. rocsys --session <SESSION_NAME> launch <MPI_COMMAND> <MPI_ARGUMENTS> rocprofv2\n\t "
|
||||
"<ROCPROFV2_OPTIONS> <APP_EXEC>\n"
|
||||
"where all mpiexec options must come before rocsys\n"
|
||||
"rocsys: start must be preceeded by --session <name>\n\t"
|
||||
"rocsys --session <name> start \n"
|
||||
"rocsys: stop must be preceeded by --session <name>\n \t"
|
||||
"rocsys --session <name> stop \n"
|
||||
"rocsys: launch must be preceeded by --session-new <name>\n \t"
|
||||
"e.g. mpiexec -np 16 rocsys --session-new <name> launch py app.py\n"
|
||||
"where all mpiexec options must come before rocsys");
|
||||
"rocsys: exit must be preceeded by --session <name>\n \t"
|
||||
"rocsys --session <name> 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 <name>\n"
|
||||
"e.g. rocsys --session <SESSION_NAME> launch <MPI_COMMAND> <MPI_ARGUMENTS> rocprofv2\n\t "
|
||||
"<ROCPROFV2_OPTIONS> <APP_EXEC>\n"
|
||||
"where all mpiexec options must come before rocsys\n"
|
||||
"rocsys: start must be preceeded by --session <name>\n\t"
|
||||
"rocsys --session <name> start \n"
|
||||
"rocsys: stop must be preceeded by --session <name>\n \t"
|
||||
"rocsys --session <name> stop \n"
|
||||
"rocsys: launch must be preceeded by --session <name>\n \t"
|
||||
"e.g. rocsys --session <SESSION_NAME> launch <MPI_COMMAND> <MPI_ARGUMENTS> rocprofv2 "
|
||||
"<ROCPROFV2_OPTIONS> <APP_EXEC>\n"
|
||||
"where all mpiexec options must come before rocsys\n",
|
||||
"rocsys: exit must be preceeded by --session <name>\n \t"
|
||||
"rocsys --session <name> exit \n",
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<bool> amd_sys_handler{false};
|
||||
std::atomic<bool> roc_sys_handler{false};
|
||||
std::atomic<bool> session_created{false};
|
||||
std::atomic<bool> trace_period_thread_control{false};
|
||||
std::atomic<bool> 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);
|
||||
}
|
||||
|
||||
Αναφορά σε νέο ζήτημα
Block a user