diff --git a/bin/rpl_run.sh b/bin/rpl_run.sh index 4f15b97c82..6fff8e77f0 100755 --- a/bin/rpl_run.sh +++ b/bin/rpl_run.sh @@ -75,6 +75,8 @@ export ROCP_METRICS=$PKG_DIR/lib/metrics.xml export AQLPROFILE_READ_API=0 # ROC Profiler package path export ROCP_PACKAGE_DIR=$PKG_DIR +# enabled SPM KFD mode +export ROCP_SPM_KFD_MODE=1 # error handling fatal() { @@ -184,7 +186,6 @@ usage() { echo " --flush-rate - to enable trace flush rate (time period)" echo " Supported time formats: " echo " --parallel-kernels - to enable cnocurrent kernels" - echo " --spm-mode - to enable collecting time-based sampling of HW counter data [off]" echo "" echo "Configuration file:" echo " You can set your parameters defaults preferences in the configuration file 'rpl_rc.xml'. The search path sequence: .:${HOME}:" @@ -445,10 +446,6 @@ while [ 1 ] ; do ARG_VAL=0 export ROCP_K_CONCURRENT=1 export AQLPROFILE_READ_API=1 - elif [ "$1" = "--spm-mode" ] ; then - if [ "$2" = "on" ] ; then - export ROCP_SPM_KFD_MODE=1 - fi elif [ "$1" = "--verbose" ] ; then ARG_VAL=0 export ROCP_VERBOSE_MODE=1 diff --git a/bin/txt2xml.sh b/bin/txt2xml.sh index 126337ed03..50c20926f8 100755 --- a/bin/txt2xml.sh +++ b/bin/txt2xml.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x ################################################################################ # Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved. @@ -64,7 +64,7 @@ parse() { gpu_index=$line fi else - found=$(echo $feature | sed -n "/^\(pmc\|sqtt\|hsa\)$/ p") + found=$(echo $feature | sed -n "/^\(pmc\|sqtt\|hip\|hsa\|kfd\)$/ p") if [ -n "$found" ] ; then output=$outdir/input${index}.xml header="# $timestamp '$output' generated with '$0 $*'" @@ -85,9 +85,21 @@ EOF EOF fi + if [ "$feature" == "hip" ] ; then + cat >> $output < +EOF + fi + if [ "$feature" == "hsa" ] ; then cat >> $output < +EOF + fi + + if [ "$feature" == "kfd" ] ; then + cat >> $output < EOF fi fi diff --git a/src/core/context.h b/src/core/context.h index c368d42c04..f3c2f2a805 100644 --- a/src/core/context.h +++ b/src/core/context.h @@ -323,7 +323,7 @@ class Context { for (auto& tuple : profile_vector) { if (pcsmp_mode_) const_cast(tuple.profile)->event_count = UINT32_MAX; const hsa_status_t status = - api_->hsa_ven_amd_aqlprofile_iterate_data(tuple.profile, callback, data); + api_->hsa_ven_amd_aqlprofile_iterate_data(tuple.profile, callback, data); if (status != HSA_STATUS_SUCCESS) AQL_EXC_RAISING(status, "context iterate data failed"); } } diff --git a/test/tool/tool.cpp b/test/tool/tool.cpp index 71d5603850..c945fa1ac9 100644 --- a/test/tool/tool.cpp +++ b/test/tool/tool.cpp @@ -443,7 +443,8 @@ hsa_status_t trace_data_cb(hsa_ven_amd_aqlprofile_info_type_t info_type, } // SPM counter trace start/stop methods -std::vector spm_ctx_vec; +typedef std::vector spm_ctx_vec_t; +spm_ctx_vec_t *spm_ctx_vec = NULL; void spm_ctrl_start(rocprofiler_feature_t* features, uint32_t features_found) { // Start SPM trace collection for all GPUs uint32_t gpu_count = HsaRsrcFactory::Instance().GetCountOfGpuAgents(); @@ -459,6 +460,14 @@ void spm_ctrl_start(rocprofiler_feature_t* features, uint32_t features_found) { rocprofiler_properties_t properties{}; properties.queue_depth = 256; + for (rocprofiler_feature_t* p = features; p < features + features_found; ++p) { + int val = p->kind; + if (val == ROCPROFILER_FEATURE_KIND_METRIC) { + val = ROCPROFILER_FEATURE_KIND_TRACE | ROCPROFILER_FEATURE_KIND_SPM_MOD; + p->kind = (rocprofiler_feature_kind_t)val; + } + } + // Creating SPM context rocprofiler_t* context = NULL; hsa_status_t status = rocprofiler_open(agent, features, features_found, &context, @@ -472,13 +481,16 @@ void spm_ctrl_start(rocprofiler_feature_t* features, uint32_t features_found) { status = rocprofiler_start(context, 0); check_status(status); // saving the context in the vectort - spm_ctx_vec.push_back(context); + if (spm_ctx_vec == NULL) spm_ctx_vec = new spm_ctx_vec_t; + spm_ctx_vec->push_back(context); } } void spm_ctrl_stop() { - for (rocprofiler_t* context : spm_ctx_vec) { + for (rocprofiler_t* context : *spm_ctx_vec) { hsa_status_t status = rocprofiler_stop(context, 0); check_status(status); + status = rocprofiler_iterate_trace_data(context, NULL, NULL); + check_status(status); rocprofiler_close(context); } } @@ -1565,12 +1577,6 @@ extern "C" PUBLIC_API void OnLoadToolProp(rocprofiler_settings_t* settings) // set a value to indicate tracing mode if (settings->k_concurrent != 0) settings->k_concurrent = (traces_found == 0) ? 1 : 2; - if (is_spm_trace) { - for (uint32_t index = 0; index < features_found; index++) { - features[index].kind = ROCPROFILER_FEATURE_KIND_TRACE; - } - } - // Context array aloocation context_array = new context_array_t;