[rocprofiler-compute] Use native tool for counter collection (#1212)

* Use native tool for counter collection

* Add native counter collection tool which uses rocprofiler-sdk C++
  library public API to get counter collection data
    * This is enabled by default, unless --no-native-tool option is
      provided or ROCPROF=rocprofv3 env. var. is provided
    * This tool is only supported for ROCm version >=7.x.x
    * This tool is not supported for attach/detach scenario
* Build native tool shared object during build time
* If using rocprof-compute without building then runtime compilation of
  t push native tool shared object is performed
* rocprofiler-sdk tools is still used for services other than counter
  collection and data collected by native tool is merged into the
  rocpd/csv output of rocprofiler-sdk tool

* Make `rocpd` choice the default choice for `--format-rocprof-output`
  option
    * If `rocpd` public API from rocprofiler-sdk library is not present,
      then fallback to `csv` choice
    * In this case only `pmc_perf.csv` is written in workload folder
      instead of multiple `csv` files for each profiling run
* Remove `json` choice from `--format-rocprof-output` option since it
  functions identical to `csv` option

* Rename option `--rocprofiler-sdk-library-path` to
  `--rocprofiler-sdk-tool-path` since we LD_PRELOAD the
  rocprofiler-sdk tool shared object and not the rocprofiler-sdk library
shared object

* Fix the meaning of `--dispatch` option in `profile` mode to mention
  dispatch iteration filtering instead of dispatch id filtering
    * --dispatch option in analyze mode does dispatch id filtering

* Move standalone binary creation logic from cmake file to docker file

* fix native counter collection tool during attach/detach

* improve logging

* fix attach detach with native tool

* fix attach detach with native tool

* do not support attach/detach in native tool

* Update changelog

* add standalone binary creation functionality in cmake

* address review comments

* address review comments

* fix formatting

* address review comments

* Adding paths for cmake to search. Also updated min. cmake requirement to 3.21 as this was when hip was supported.

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* Update hip compiler ID check, sometimes comes up as Clang, sometimes ROCMClang- depends on setup.
Updated formatting.

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* RHEL8.10 unable to compile due to defaulting to old c++ version, need to force c++17

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* Updating changelog per docs team recommendations

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* Apply suggestions from code review to changelog

Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>

* Do not required HIP complier to build native counter collection tool

* fix cmake

* gersemi formatting on latest cmake change

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* ex ci updated dependencies to include rocprofiler-sdk, but cmake was still not capturing the path- there was a commit that added to the cmake_prefix_path entry that specified rocprof-sdk's cmake location ut was too specific for the search paths in find_package's config mode.
removing the cmake_prefix_path var and adding hints to find_package call instead, and specifying config mode so it knows how to construct the search paths

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* gersemi run for formatting

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* Still need prefix path, should not have been removed in last commit but does need to be shortened to just the rocm path to allow for find_package config mode to do the job

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* include cstdint for uint32_t

* Run formatting on helper.cpp

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* Remove rocm 7.2 release stuff from version and changelog and handle it in separate pr

* fix version

* fix changelog

* fix changelog

* run ruff formatter

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>

* fix rocprofiler-sdk attach so path

---------

Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
Co-authored-by: Carrie Fallows <Carrie.Fallows@amd.com>
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
Этот коммит содержится в:
authored and GitHub committed 2025-11-18 23:34:38 -05:00
1 родитель 8418895b92
Коммит ae8f72fa79
25 files changed
+1599 -573

No files matched your search

+31 -11
Просмотреть файл
@@ -178,7 +178,10 @@ Examples:
metavar="",
default=None,
required=False,
help="\t\t\tProcess id to be attached for profiling.",
help=(
"\t\t\tProcess id to be attached for profiling.\n"
"\t\t\tImplies --no-native-tool"
),
)
profile_group.add_argument(
"--attach-duration-msec",
@@ -188,9 +191,9 @@ Examples:
default=None,
required=False,
help=(
"\t\t\tWhen --attach-pid is used, it specifies the attach duration "
"in milliseconds. If not set, detachment occurs when "
'"Enter" key is pressed.'
"\t\t\tWhen --attach-pid is used, it specifies the attach duration\n"
"\t\t\tin milliseconds. If not set, detachment occurs when\n"
'\t\t\t"Enter" key is pressed.'
),
)
profile_group.add_argument(
@@ -255,7 +258,10 @@ Examples:
nargs="+",
dest="dispatch",
required=False,
help="\t\t\tDispatch ID filtering.",
help=(
"\t\t\tWhich dispatch iterations of the kernel to filter \n"
"\t\t\t(e.g. 1 3:5 captures 1st, 3rd, 4th and 5th iterations)."
),
)
profile_group.add_argument(
@@ -342,8 +348,8 @@ Examples:
metavar="",
dest="format_rocprof_output",
choices=["csv", "rocpd"],
default="csv",
help="\t\t\tSet the format of output file of rocprof.",
default="rocpd",
help=("\t\t\tSet the format of output file of rocprof."),
)
profile_group.add_argument(
"--pc-sampling-method",
@@ -370,14 +376,28 @@ Examples:
),
)
profile_group.add_argument(
"--rocprofiler-sdk-library-path",
"--rocprofiler-sdk-tool-path",
type=str,
dest="rocprofiler_sdk_library_path",
dest="rocprofiler_sdk_tool_path",
required=False,
default=str(
Path(os.getenv("ROCM_PATH", "/opt/rocm")) / "lib/librocprofiler-sdk.so"
Path(os.getenv("ROCM_PATH", "/opt/rocm"))
/ "lib/rocprofiler-sdk/librocprofiler-sdk-tool.so"
),
help="\t\t\tSet the path to rocprofiler-sdk tool.",
)
profile_group.add_argument(
"--no-native-tool",
required=False,
default=False,
action="store_true",
help=(
"\t\t\tDo not use the native counter collection tool.\n"
"\t\t\tNative tool is not used if ROCPROF env. var. is set "
"and not equal to rocprofiler-sdk.\n"
"\t\t\tNative tool is not used for ROCm version < 7.x.x.\n"
"\t\t\tNative tool is not used attach/detach scenario"
),
help="\t\t\tSet the path to rocprofiler SDK library.",
)
profile_group.add_argument(
"--retain-rocpd-output",