Enabling -m and --basenames option
Change-Id: Ic19ac28ab6ec842daf2a93a311ed7690b61b1e2a
[ROCm/rocprofiler commit: a76341e30c]
This commit is contained in:
@@ -31,6 +31,8 @@ usage() {
|
||||
echo -e "${GREEN}-t | --test ${RESET} For Running the tests"
|
||||
echo -e "${GREEN}-mt | --mem-test ${RESET} For Running the Memory Leak tests. This run requires building using -acb | --asan-clean-build option"
|
||||
fi
|
||||
echo -e "${GREEN}-m ${RESET} For providing an absolute path of a custom metrics file"
|
||||
echo -e "${GREEN}--basenames ${RESET} For Truncating the kernel names"
|
||||
echo -e "${GREEN}--hip-api ${RESET} For Collecting HIP API Traces"
|
||||
echo -e "${GREEN}--hip-activity | --hip-trace ${RESET} For Collecting HIP API Activities Traces"
|
||||
echo -e "${GREEN}--hsa-api ${RESET} For Collecting HSA API Traces"
|
||||
@@ -163,6 +165,19 @@ while [ 1 ]; do
|
||||
export ROCPROFILER_ENABLE_ROCSYS=$2
|
||||
shift
|
||||
shift
|
||||
elif [ "$1" = "-m" ]; then
|
||||
if [ $2 ] && [ -n $2 ] && [ -r $2 ]; then
|
||||
export ROCPROFILER_METRICS_PATH=$2
|
||||
else
|
||||
echo -e "Error: \"$2\" path doesn't exist!"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
shift
|
||||
elif [ "$1" = "--basenames" ]; then
|
||||
export ROCPROFILER_TRUNCATE_KERNEL_PATH=1
|
||||
shift
|
||||
elif [ "$1" = "--plugin" ]; then
|
||||
if [ -n $2 ]; then
|
||||
PLUGIN=$2
|
||||
|
||||
@@ -199,6 +199,7 @@ class MetricsDict {
|
||||
|
||||
MetricsDict(const rocprofiler::HSAAgentInfo* agent_info) : xml_(NULL), agent_info_(agent_info) {
|
||||
std::string xml_name = []() {
|
||||
|
||||
if (const char* path = getenv("ROCPROFILER_METRICS_PATH"); path != nullptr) return path;
|
||||
return "";
|
||||
}();
|
||||
|
||||
@@ -154,43 +154,49 @@ input string. By using the iterators it finds the
|
||||
window in the string which contains only the kernel name.
|
||||
For example 'Foo<int, float>::foo(a[], int (int))' -> 'foo'*/
|
||||
std::string truncate_name(const std::string& name) {
|
||||
auto rit = name.rbegin();
|
||||
auto rend = name.rend();
|
||||
uint32_t counter = 0;
|
||||
char open_token = 0;
|
||||
char close_token = 0;
|
||||
while (rit != rend) {
|
||||
if (counter == 0) {
|
||||
switch (*rit) {
|
||||
case ')':
|
||||
counter = 1;
|
||||
open_token = ')';
|
||||
close_token = '(';
|
||||
break;
|
||||
case '>':
|
||||
counter = 1;
|
||||
open_token = '>';
|
||||
close_token = '<';
|
||||
break;
|
||||
case ']':
|
||||
counter = 1;
|
||||
open_token = ']';
|
||||
close_token = '[';
|
||||
break;
|
||||
case ' ':
|
||||
++rit;
|
||||
continue;
|
||||
|
||||
const char* path = getenv("ROCPROFILER_TRUNCATE_KERNEL_PATH");
|
||||
if(path != nullptr) {
|
||||
auto rit = name.rbegin();
|
||||
auto rend = name.rend();
|
||||
uint32_t counter = 0;
|
||||
char open_token = 0;
|
||||
char close_token = 0;
|
||||
while (rit != rend) {
|
||||
if (counter == 0) {
|
||||
switch (*rit) {
|
||||
case ')':
|
||||
counter = 1;
|
||||
open_token = ')';
|
||||
close_token = '(';
|
||||
break;
|
||||
case '>':
|
||||
counter = 1;
|
||||
open_token = '>';
|
||||
close_token = '<';
|
||||
break;
|
||||
case ']':
|
||||
counter = 1;
|
||||
open_token = ']';
|
||||
close_token = '[';
|
||||
break;
|
||||
case ' ':
|
||||
++rit;
|
||||
continue;
|
||||
}
|
||||
if (counter == 0) break;
|
||||
} else {
|
||||
if (*rit == open_token) counter++;
|
||||
if (*rit == close_token) counter--;
|
||||
}
|
||||
++rit;
|
||||
}
|
||||
if (counter == 0) break;
|
||||
} else {
|
||||
if (*rit == open_token) counter++;
|
||||
if (*rit == close_token) counter--;
|
||||
}
|
||||
++rit;
|
||||
auto rbeg = rit;
|
||||
while ((rit != rend) && (*rit != ' ') && (*rit != ':')) rit++;
|
||||
return name.substr(rend - rit, rit - rbeg);
|
||||
}
|
||||
auto rbeg = rit;
|
||||
while ((rit != rend) && (*rit != ' ') && (*rit != ':')) rit++;
|
||||
return name.substr(rend - rit, rit - rbeg);
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
// C++ symbol demangle
|
||||
|
||||
@@ -73,6 +73,7 @@ void __attribute__((constructor)) globalsetting() {
|
||||
gfx_path << app_path << metrics_path;
|
||||
setenv("ROCPROFILER_METRICS_PATH", gfx_path.str().c_str(), true);
|
||||
setenv("ROCPROFILER_MAX_ATT_PROFILES", "2", 1);
|
||||
setenv("ROCPROFILER_TRUNCATE_KERNEL_PATH", "1", true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -310,7 +310,7 @@ TEST(WhenTrucatingLongKernelNames, KernelNameGetsTruncatedProperly) {
|
||||
"int, int, long long, long long, long long, long long, long long, long "
|
||||
"long, long long, long long, long long, float, float, float, float "
|
||||
"const*, float*, float const*, float*, float const*) [clone .kd]";
|
||||
|
||||
setenv("ROCPROFILER_TRUNCATE_KERNEL_PATH", "1", true);
|
||||
std::string trunkated_name = rocprofiler::truncate_name(long_kernel_name);
|
||||
|
||||
EXPECT_EQ("kernel_7r_3d_pml", trunkated_name);
|
||||
@@ -332,7 +332,28 @@ TEST(WhenTrucatingKokkossKernelNames, KernelNameGetsTruncatedProperly) {
|
||||
"LAMMPS_NS::PairReaxFFKokkos<Kokkos::Experimental::HIP>::params_sing, false>, "
|
||||
"Kokkos::RangePolicy<Kokkos::Experimental::HIP, Kokkos::IndexType<long> >, "
|
||||
"Kokkos::Experimental::HIP> const*)";
|
||||
|
||||
setenv("ROCPROFILER_TRUNCATE_KERNEL_PATH", "1", true);
|
||||
std::string trunkated_name = rocprofiler::truncate_name(long_kernel_name);
|
||||
EXPECT_EQ("hip_parallel_launch_local_memory", trunkated_name);
|
||||
}
|
||||
|
||||
TEST(WhenTrucatingKokkossKernelNames, KernelNameDoesnotTruncated) {
|
||||
std::string long_kernel_name =
|
||||
"void "
|
||||
"Kokkos::Experimental::Impl::hip_parallel_launch_local_memory<Kokkos::Impl::ParallelFor<"
|
||||
"Kokkos::"
|
||||
"Impl::ViewValueFunctor<Kokkos::Device<Kokkos::Experimental::HIP, "
|
||||
"Kokkos::Experimental::HIPSpace>, "
|
||||
"LAMMPS_NS::PairReaxFFKokkos<Kokkos::Experimental::HIP>::params_sing, false>, "
|
||||
"Kokkos::RangePolicy<Kokkos::Experimental::HIP, Kokkos::IndexType<long> >, "
|
||||
"Kokkos::Experimental::HIP>, 1024u, "
|
||||
"1u>(Kokkos::Impl::ParallelFor<Kokkos::Impl::ViewValueFunctor<Kokkos::Device<Kokkos::"
|
||||
"Experimental::"
|
||||
"HIP, Kokkos::Experimental::HIPSpace>, "
|
||||
"LAMMPS_NS::PairReaxFFKokkos<Kokkos::Experimental::HIP>::params_sing, false>, "
|
||||
"Kokkos::RangePolicy<Kokkos::Experimental::HIP, Kokkos::IndexType<long> >, "
|
||||
"Kokkos::Experimental::HIP> const*)";
|
||||
unsetenv("ROCPROFILER_TRUNCATE_KERNEL_PATH");
|
||||
std::string trunkated_name = rocprofiler::truncate_name(long_kernel_name);
|
||||
EXPECT_EQ(long_kernel_name, trunkated_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user