Incremental Counter Profile Creation (#933)

* Incremental Counter Profile Creation

Adds support for incremental counter creation. How this functions is the
behavior of rocprofiler_create_profile_config has been changed.

rocprofiler_create_profile_config(rocprofiler_agent_id_t           agent_id,
                                  rocprofiler_counter_id_t*        counters_list,
                                  size_t                           counters_count,
                                  rocprofiler_profile_config_id_t* config_id)

The behavior of this function now allows an existing config_id to be
supplied via config_id. The counters contained in this config will be
copied over and used as a base for a new config along with any counters
supplied in counters_list. The new config id is returned via config_id
and can be used in future dispatch/agent counting sessions.

A new config is created over modifying an existing config since there
is no gaurentee that the existing config isn't already in use. While we
could add locks (or other mutual exclusion properties) to check if its
in use and reject an update, the benefit from doing so is minor in
comparison to just creating a new config. This also side steps a common
pattern a tool may use to add additional counters at some point later on
during execution. Now they can do that without destroying the existing
config.

---------

Co-authored-by: Benjamin Welton <ben@amd.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Benjamin Welton
2024-06-19 00:11:03 -07:00
committed by GitHub
parent ab92bef1a4
commit 81d1407565
12 changed files with 140 additions and 46 deletions
+1
View File
@@ -105,6 +105,7 @@ typedef enum // NOLINT(performance-enum-size)
ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE, ///< The service is not available.
///< Please refer to API functions that return this
///< status code for more information.
ROCPROFILER_STATUS_ERROR_EXCEEDS_HW_LIMIT, ///< Exceeds hardware limits for collection
ROCPROFILER_STATUS_LAST,
} rocprofiler_status_t;
@@ -40,12 +40,18 @@ ROCPROFILER_EXTERN_C_INIT
* be used across many contexts. The profile has a fixed set of counters
* that are collected (and specified by counter_list). The available
* counters for an agent can be queried using
* @ref rocprofiler_iterate_agent_supported_counters.
* @ref rocprofiler_iterate_agent_supported_counters. An existing profile
* may be supplied via config_id to use as a base for the new profile.
* All counters in the existing profile will be copied over to the new
* profile. The existing profile will remain unmodified and usable with
* the new profile id being returned in config_id.
*
* @param [in] agent_id Agent identifier
* @param [in] counters_list List of GPU counters
* @param [in] counters_count Size of counters list
* @param [out] config_id Identifier for GPU counters group
* @param [in/out] config_id Identifier for GPU counters group. If an existing
profile is supplied, that profiles counters will be copied
over to a new profile (returned via this id)
* @return ::rocprofiler_status_t
* @retval ROCPROFILER_STATUS_SUCCESS if profile created
* @retval ROCPROFILER_STATUS_ERROR if profile could not be created