Fixing rocprofilerv2 naming and CMake issues

Change-Id: Ib6d336349a056731e5c0f35151296d6fea671360


[ROCm/rocprofiler commit: dc69331379]
This commit is contained in:
Ammar ELWazir
2023-02-17 11:12:27 -06:00
parent 38080f727a
commit ff80dd4dfa
62 changed files with 228 additions and 234237 deletions
+7 -7
View File
@@ -1,5 +1,5 @@
# ############################################################################################################################################
# ROCMTOOL General Requirements
# ROCProfiler General Requirements
# ############################################################################################################################################
find_package(Python3 COMPONENTS Interpreter REQUIRED)
@@ -71,7 +71,7 @@ execute_process(
# COMMENT "Generating derived_counter.cpp...")
# ############################################################################################################################################
# ROCMTOOL Tracer HIP/HSA Parsing
# ROCProfiler Tracer HIP/HSA Parsing
# ############################################################################################################################################
get_property(HIP_INCLUDE_DIRECTORIES TARGET hip::amdhip64 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
find_file(HIP_RUNTIME_API_H hip_runtime_api.h
@@ -127,7 +127,7 @@ set(GENERATED_SOURCES
hsa_prof_str.inline.h)
# ############################################################################################################################################
# ROCMTOOL API
# ROCProfiler API
# ############################################################################################################################################
# PC sampling uses libpciaccess as a fallback if the debugfs ioctl is
# unavailable
@@ -150,8 +150,8 @@ file(GLOB ROCPROFILER_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB ROCPROFILER_PROFILER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/profiler/profiler.cpp)
file(GLOB ROCPROFILER_TRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/*.cpp)
file(GLOB ROCPROFILER_ROCTRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/src/*.cpp)
file(GLOB ROCMTOOLS_ATT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/att/att.cpp)
file(GLOB ROCMTOOL_CLASS_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocmtool.cpp)
file(GLOB ROCPROFILER_ATT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/att/att.cpp)
file(GLOB ROCPROFILER_CLASS_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocmtool.cpp)
file(GLOB ROCPROFILER_SPM_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/spm/spm.cpp)
@@ -188,9 +188,9 @@ file(GLOB CORE_PC_SAMPLING_FILES ${CORE_PC_SAMPLING_DIR}/core/*.cpp ${CORE_PC_SA
# Compiling/Installing ROCProfiler API
add_library(${ROCPROFILER_TARGET} SHARED
${ROCPROFILER_SRC_FILES}
${ROCMTOOL_CLASS_SRC_FILES}
${ROCPROFILER_CLASS_SRC_FILES}
${ROCPROFILER_PROFILER_SRC_FILES}
${ROCMTOOLS_ATT_SRC_FILES}
${ROCPROFILER_ATT_SRC_FILES}
${CORE_HARDWARE_SRC_FILES}
${CORE_HSA_SRC_FILES}
${ROCPROFILER_SPM_SRC_FILES}
@@ -69,7 +69,7 @@ Filter::Filter(rocprofiler_filter_id_t id, rocprofiler_filter_kind_t filter_kind
}
default: {
warning(
"Error: ROCMtools filter specified is not supported for "
"Error: ROCProfiler filter specified is not supported for "
"profiler mode!\n");
}
}
@@ -92,7 +92,7 @@ std::vector<std::string> Filter::GetCounterData() {
return profiler_counter_names_;
}
fatal(
"Error: ROCMtools filter specified is not supported for "
"Error: ROCProfiler filter specified is not supported for "
"Counter Collection Filter!\n");
}
@@ -101,7 +101,7 @@ std::vector<rocprofiler_tracer_activity_domain_t> Filter::GetTraceData() {
return tracer_apis_;
}
fatal(
"Error: ROCMtools filter specified is not supported for "
"Error: ROCProfiler filter specified is not supported for "
"profiler mode!\n");
}
@@ -110,7 +110,7 @@ std::vector<rocprofiler_att_parameter_t> Filter::GetAttParametersData() {
return att_parameters_;
}
fatal(
"Error: ROCMtools filter specified is not supported for "
"Error: ROCProfiler filter specified is not supported for "
"ATT tracing mode!\n");
}
@@ -119,7 +119,7 @@ rocprofiler_spm_parameter_t* Filter::GetSpmParameterData() {
return spm_parameter_;
}
fatal(
"Error: ROCMtools filter specified is not supported for "
"Error: ROCProfiler filter specified is not supported for "
"SPM collection mode!\n");
}
void Filter::SetProperty(rocprofiler_filter_property_t property) {
@@ -181,7 +181,7 @@ void Filter::SetProperty(rocprofiler_filter_property_t property) {
break;
// TODO(aelwazir): Check for empty property
// warning(
// "Error: ROCMtools filter specified is not supported for "
// "Error: ROCProfiler filter specified is not supported for "
// "profiler mode!\n");
}
}
@@ -211,7 +211,7 @@ std::variant<std::vector<std::string>, uint32_t*> Filter::GetProperty(
}
default:
fatal(
"Error: ROCMtools filter specified is not supported for the given "
"Error: ROCProfiler filter specified is not supported for the given "
"kind!");
break;
}
@@ -241,7 +241,7 @@ size_t Filter::GetPropertiesCount(rocprofiler_filter_property_kind_t kind) {
}
}
fatal(
"Error: ROCMtools filter specified is not supported for the given "
"Error: ROCProfiler filter specified is not supported for the given "
"kind!");
}
@@ -34,7 +34,7 @@ namespace fs = std::experimental::filesystem;
// Usage message
void printUsage() {
std::cout << "ROCMTools Run Binary Usage:" << std::endl;
std::cout << "ROCProfiler Run Binary Usage:" << std::endl;
std::cout << "\nTo run ./run.sh PARAMs, PARAMs can be the following:" << std::endl;
std::cout << "-h | --help For showing this message" << std::endl;
std::cout << "-t | --test For Running the tests" << std::endl;
@@ -122,7 +122,7 @@ int main(int argc, char** argv) {
}
current_path[sizeof(current_path) - 1] = '\0';
// Getting the rocprofv2 binary path to locate rocmtools library path
// Getting the rocprofv2 binary path to locate rocprofiler library path
fs::path bin_path;
if (Dl_info dl_info; dladdr((void*)runApp, &dl_info) != 0) {
bin_path = fs::path(dl_info.dli_fname);
@@ -140,7 +140,7 @@ int main(int argc, char** argv) {
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-h") == 0) {
printUsage();
return 1;
// Normal ROCMTools Tests
// Normal ROCProfiler Tests
} else if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--test") == 0) {
fs::path test_path = bin_path;
test_path = test_path.replace_filename("run_tests.sh");
@@ -225,7 +225,7 @@ int main(int argc, char** argv) {
}
app_args[j] = NULL;
// Providing LD_PRELOAD of ROCMTools Library to runApp function
// Providing LD_PRELOAD of ROCProfiler Library to runApp function
std::string pathenv_str = "LD_PRELOAD=librocprofiler_tool.so";
std::string current_ld_preload;
if (getenv("LD_PRELOAD")) current_ld_preload = getenv("LD_PRELOAD");
+31 -39
View File
@@ -59,10 +59,10 @@
namespace fs = std::experimental::filesystem;
// Macro to check ROCMTools calls status
#define CHECK_ROCMTOOLS(call) \
// Macro to check ROCProfiler calls status
#define CHECK_ROCPROFILER(call) \
do { \
if ((call) != ROCPROFILER_STATUS_SUCCESS) rocmtools::fatal("Error: ROCMTools API Call Error!"); \
if ((call) != ROCPROFILER_STATUS_SUCCESS) rocmtools::fatal("Error: ROCProfiler API Call Error!"); \
} while (false)
namespace {
@@ -193,14 +193,6 @@ att_parsed_input_t GetATTParams() {
ATT_PARAM_NAMES["PERFCOUNTERS_COL_PERIOD"] = ROCPROFILER_ATT_MAXVALUE;
ATT_PARAM_NAMES["KERNEL"] = ROCPROFILER_ATT_MAXVALUE;
ATT_PARAM_NAMES["REDUCED_MEMORY"] = ROCPROFILER_ATT_MAXVALUE;
/*
ATT_PARAM_NAMES["ATT_MASK"] = ROCMTOOLS_ATT_MASK;
ATT_PARAM_NAMES["TOKEN_MASK"] = ROCMTOOLS_ATT_TOKEN_MASK;
ATT_PARAM_NAMES["TOKEN_MASK2"] = ROCMTOOLS_ATT_TOKEN_MASK2;
ATT_PARAM_NAMES["SE_MASK"] = ROCMTOOLS_ATT_SE_MASK;
ATT_PARAM_NAMES["PERF_MASK"] = ROCMTOOLS_ATT_PERF_MASK;
ATT_PARAM_NAMES["PERF_CTRL"] = ROCMTOOLS_ATT_PERF_CTRL;
*/
// Default values used for token generation.
std::unordered_map<std::string, uint32_t> default_params = {
@@ -308,14 +300,14 @@ void finish() {
}
if (session_created.load(std::memory_order_relaxed)) {
session_created.exchange(false, std::memory_order_release);
CHECK_ROCMTOOLS(rocprofiler_terminate_session(session_id));
CHECK_ROCPROFILER(rocprofiler_terminate_session(session_id));
for ([[maybe_unused]] rocprofiler_buffer_id_t buffer_id : buffer_ids) {
CHECK_ROCMTOOLS(rocprofiler_flush_data(session_id, buffer_id));
CHECK_ROCPROFILER(rocprofiler_flush_data(session_id, buffer_id));
}
}
// CHECK_ROCMTOOLS(rocprofiler_destroy_session(session_id));
// CHECK_ROCMTOOLS(rocprofiler_finalize());
// CHECK_ROCPROFILER(rocprofiler_destroy_session(session_id));
// CHECK_ROCPROFILER(rocprofiler_finalize());
}
// load plugins
@@ -327,7 +319,7 @@ void plugins_load() {
if (fs::path(dl_info.dli_fname).string().find("build") != std::string::npos) {
plugin_name = "libfile_plugin.so";
} else {
plugin_name = "rocmtools/libfile_plugin.so";
plugin_name = "rocprofiler/libfile_plugin.so";
}
}
if (!plugin.emplace(fs::path(dl_info.dli_fname).replace_filename(plugin_name)).is_valid()) {
@@ -353,7 +345,7 @@ void wait_for_amdsys() {
// Start
case 4: {
printf("AMDSYS:: Starting Tools Session...\n");
CHECK_ROCMTOOLS(rocprofiler_start_session(session_id));
CHECK_ROCPROFILER(rocprofiler_start_session(session_id));
session_created.exchange(true, std::memory_order_release);
break;
}
@@ -362,9 +354,9 @@ void wait_for_amdsys() {
if (session_created.load(std::memory_order_relaxed)) {
printf("AMDSYS:: Stopping Tools Session...\n");
session_created.exchange(false, std::memory_order_release);
CHECK_ROCMTOOLS(rocprofiler_terminate_session(session_id));
CHECK_ROCPROFILER(rocprofiler_terminate_session(session_id));
for ([[maybe_unused]] rocprofiler_buffer_id_t buffer_id : buffer_ids) {
CHECK_ROCMTOOLS(rocprofiler_flush_data(session_id, buffer_id));
CHECK_ROCPROFILER(rocprofiler_flush_data(session_id, buffer_id));
}
}
break;
@@ -375,9 +367,9 @@ void wait_for_amdsys() {
if (session_created.load(std::memory_order_relaxed)) {
printf("AMDSYS:: Stopping Tools Session...\n");
session_created.exchange(false, std::memory_order_release);
CHECK_ROCMTOOLS(rocprofiler_terminate_session(session_id));
CHECK_ROCPROFILER(rocprofiler_terminate_session(session_id));
for ([[maybe_unused]] rocprofiler_buffer_id_t buffer_id : buffer_ids) {
CHECK_ROCMTOOLS(rocprofiler_flush_data(session_id, buffer_id));
CHECK_ROCPROFILER(rocprofiler_flush_data(session_id, buffer_id));
}
}
amd_sys_handler.exchange(false, std::memory_order_release);
@@ -421,7 +413,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
uint64_t failed_tool_count, const char* const* failed_tool_names) {
if (rocprofiler_version_major() != ROCPROFILER_VERSION_MAJOR ||
rocprofiler_version_minor() < ROCPROFILER_VERSION_MINOR) {
warning("the ROCMTools API version is not compatible with this tool");
warning("the ROCProfiler API version is not compatible with this tool");
return true;
}
@@ -434,7 +426,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
amd_sys_handler.exchange(true, std::memory_order_release);
}
CHECK_ROCMTOOLS(rocprofiler_initialize());
CHECK_ROCPROFILER(rocprofiler_initialize());
// Printing out info
char* info_symb = getenv("ROCPROFILER_COUNTER_LIST");
@@ -443,7 +435,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
printf("Basic HW counters:\n");
else
printf("Derived metrics:\n");
CHECK_ROCMTOOLS(rocprofiler_iterate_counters(info_callback));
CHECK_ROCPROFILER(rocprofiler_iterate_counters(info_callback));
exit(1);
}
@@ -485,7 +477,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
parameters.emplace_back(param);
}
CHECK_ROCMTOOLS(rocprofiler_create_session(ROCPROFILER_KERNEL_REPLAY_MODE, &session_id));
CHECK_ROCPROFILER(rocprofiler_create_session(ROCPROFILER_KERNEL_REPLAY_MODE, &session_id));
bool want_pc_sampling = getenv("ROCPROFILER_PC_SAMPLING");
@@ -502,7 +494,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
if (parameters.size() > 0) filters_requested.emplace_back(ROCPROFILER_ATT_TRACE_COLLECTION);
rocprofiler_buffer_id_t buffer_id;
CHECK_ROCMTOOLS(rocprofiler_create_buffer(
CHECK_ROCPROFILER(rocprofiler_create_buffer(
session_id,
[](const rocprofiler_record_header_t* record, const rocprofiler_record_header_t* end_record,
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id) {
@@ -512,7 +504,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
buffer_ids.emplace_back(buffer_id);
rocprofiler_buffer_id_t buffer_id_1;
CHECK_ROCMTOOLS(rocprofiler_create_buffer(
CHECK_ROCPROFILER(rocprofiler_create_buffer(
session_id,
[](const rocprofiler_record_header_t* record, const rocprofiler_record_header_t* end_record,
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id_1) {
@@ -527,19 +519,19 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
printf("Enabling Counter Collection\n");
rocprofiler_filter_id_t filter_id;
[[maybe_unused]] rocprofiler_filter_property_t property = {};
CHECK_ROCMTOOLS(rocprofiler_create_filter(
CHECK_ROCPROFILER(rocprofiler_create_filter(
session_id, filter_kind, rocprofiler_filter_data_t{.counters_names = &counters_[0]},
counters_.size(), &filter_id, property));
CHECK_ROCMTOOLS(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id_1));
CHECK_ROCPROFILER(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id_1));
filter_ids.emplace_back(filter_id);
break;
}
case ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION: {
rocprofiler_filter_id_t filter_id;
[[maybe_unused]] rocprofiler_filter_property_t property = {};
CHECK_ROCMTOOLS(rocprofiler_create_filter(session_id, filter_kind, rocprofiler_filter_data_t{},
CHECK_ROCPROFILER(rocprofiler_create_filter(session_id, filter_kind, rocprofiler_filter_data_t{},
0, &filter_id, property));
CHECK_ROCMTOOLS(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id_1));
CHECK_ROCPROFILER(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id_1));
filter_ids.emplace_back(filter_id);
break;
}
@@ -547,11 +539,11 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
printf("Enabling API Tracing\n");
rocprofiler_filter_id_t filter_id;
[[maybe_unused]] rocprofiler_filter_property_t property = {};
CHECK_ROCMTOOLS(rocprofiler_create_filter(session_id, filter_kind,
CHECK_ROCPROFILER(rocprofiler_create_filter(session_id, filter_kind,
rocprofiler_filter_data_t{&apis_requested[0]},
apis_requested.size(), &filter_id, property));
CHECK_ROCMTOOLS(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id));
CHECK_ROCMTOOLS(
CHECK_ROCPROFILER(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id));
CHECK_ROCPROFILER(
rocprofiler_set_api_trace_sync_callback(session_id, filter_id, plugin_write_record));
filter_ids.emplace_back(filter_id);
break;
@@ -568,11 +560,11 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
property.data_count = kernel_names_c.size();
property.name_regex = kernel_names_c.data();
CHECK_ROCMTOOLS(
CHECK_ROCPROFILER(
rocprofiler_create_filter(session_id, ROCPROFILER_ATT_TRACE_COLLECTION,
rocprofiler_filter_data_t{.att_parameters = &parameters[0]},
parameters.size(), &filter_id, property));
CHECK_ROCMTOOLS(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id_1));
CHECK_ROCPROFILER(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id_1));
filter_ids.emplace_back(filter_id);
break;
}
@@ -580,10 +572,10 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
puts("Enabling PC sampling");
rocprofiler_filter_id_t filter_id;
[[maybe_unused]] rocprofiler_filter_property_t property = {};
CHECK_ROCMTOOLS(rocprofiler_create_filter(session_id, filter_kind,
CHECK_ROCPROFILER(rocprofiler_create_filter(session_id, filter_kind,
rocprofiler_filter_data_t{},
0, &filter_id, property));
CHECK_ROCMTOOLS(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id));
CHECK_ROCPROFILER(rocprofiler_set_filter_buffer(session_id, filter_id, buffer_id));
filter_ids.emplace_back(filter_id);
break;
}
@@ -593,7 +585,7 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
}
if (getenv("ROCPROFILER_ENABLE_AMDSYS") == nullptr) {
CHECK_ROCMTOOLS(rocprofiler_start_session(session_id));
CHECK_ROCPROFILER(rocprofiler_start_session(session_id));
session_created.exchange(true, std::memory_order_release);
}
return true;
@@ -415,12 +415,12 @@ uint32_t HsaRsrcFactory::GetCountOfCpuAgents() { return uint32_t(cpu_list_.size(
bool HsaRsrcFactory::GetGpuAgentInfo(uint32_t idx, const AgentInfo** agent_info) {
// Determine if request is valid
uint32_t size = uint32_t(gpu_list_.size());
if (idx-cpu_list_.size() >= size) {
if (idx >= size) {
return false;
}
// Copy AgentInfo from specified index
*agent_info = gpu_list_[idx-cpu_list_.size()];
*agent_info = gpu_list_[idx];
return true;
}