* googletest submodule

* cmake folder

* misc root files

- clang-format
- cmake-format
- pyproject.toml
- requirements.txt
- VERSION

* workflows

* RPM files

* external folder

* samples folder

* tests root folder

* source/bin folder

* source/include folder

* source/lib/common folder

* source/lib/plugins folder

* source/lib/tests folder

- for library unit tests

* source/lib/rocprofiler folder

- rocprofiler library implementation

* Remaining cmake files

* lib/common/containers

- ring_buffer
- atomic_ring_buffer
- stable_vector
- static_vector

* Update .gitignore

* Update hsa.hpp

- include cstdint

* cmake formatting (cmake-format) (#2)

Co-authored-by: jrmadsen <jrmadsen@users.noreply.github.com>

* Remove linting.yml

- uses self-hosted runners

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Этот коммит содержится в:
Jonathan R. Madsen
2023-08-08 18:39:01 -05:00
коммит произвёл GitHub
родитель 7d1c7757a8
Коммит 527aa71f5a
75 изменённых файлов: 20094 добавлений и 0 удалений
+4
Просмотреть файл
@@ -0,0 +1,4 @@
#
#
#
add_subdirectory(rocprofiler)
+8
Просмотреть файл
@@ -0,0 +1,8 @@
#
#
# Installation of public headers
#
#
set(ROCPROFILER_INCLUDE_FILES config.h rocprofiler.h rocprofiler_plugin.h)
install(FILES ${ROCPROFILER_INCLUDE_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocprofiler)
+189
Просмотреть файл
@@ -0,0 +1,189 @@
#pragma once
#include <hip/hip_runtime.h>
#include <rocprofiler/rocprofiler.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ROCPROFILER_API_VERSION_ID 1
#define ROCPROFILER_DOMAIN_OPS_MAX 512
#define ROCPROFILER_DOMAIN_OPS_RESERVED ((ROCPROFILER_DOMAIN_OPS_MAX * ACTIVITY_DOMAIN_NUMBER / 8))
typedef uint64_t (*rocprofiler_external_cid_cb_t)(rocprofiler_tracer_activity_domain_t,
uint32_t,
uint64_t);
typedef int (*rocprofiler_filter_name_t)(const char*);
typedef int (*rocprofiler_filter_op_id_t)(uint32_t);
typedef int (*rocprofiler_filter_range_t)(uint32_t, uint32_t);
typedef int (*rocprofiler_filter_dispatch_id_t)(uint64_t);
/// permits tools opportunity to modify the correlation id based on the domain, op, and
/// the rocprofiler generated correlation id
struct rocprofiler_correlation_config
{
rocprofiler_external_cid_cb_t external_id_callback;
};
/// how the tools specify the tracing domain and (optionally) which operations in the
/// domain they want to trace
struct rocprofiler_domain_config
{
rocprofiler_sync_callback_t callback;
char reserved0[sizeof(uint64_t)];
char reserved1[ROCPROFILER_DOMAIN_OPS_RESERVED];
};
/// for buffered callbacks, the tool provides a callback to create a buffer and the size
struct rocprofiler_buffer_config
{
rocprofiler_buffer_callback_t callback;
uint64_t buffer_size;
// void* reserved0;
char reserved1[sizeof(uint64_t)];
};
/// filters are available to make quick decisions about whether rocprofiler should
/// assemble the data necessary for a callback. This is more for convenience and
/// performance -- anything decisions here could be made in the callback but rocprofiler
/// has to first assemble all the infomation on the callback before it (eventually) gets
/// discarded because the tool has decided it (after configuration), that it no longer
/// wants info meeting certain requirements
struct rocprofiler_filter_config
{
// filter callbacks
rocprofiler_filter_name_t name;
rocprofiler_filter_op_id_t hip_function_id;
rocprofiler_filter_op_id_t hsa_function_id;
rocprofiler_filter_range_t range;
rocprofiler_filter_dispatch_id_t dispatch_id;
// reserved padding
char padding[24 * sizeof(void*)];
};
/// this is the "single source of truth" for the capabilities of rocprofiler.
/// you can one configuration that activates all the capabilities you want
/// and holistically start/stop the sum of those features. Alternatively,
/// you can have multiple configurations in order to activate certain features
/// modularly.
///
/// The general workflow is:
///
/// 1. invoke rocprofiler_allocate_config(...)
/// - rocprofiler allocates any space internally needed for the config
/// - rocprofiler sets a few initial values:
/// - "size" to the size of the config structure used internally
/// - "api_version" to the version id of the API in the rocprofiler library that
/// is being used.
/// - these two values can be used by the tool to identify any potential
/// incompatibilities that the tool might want to know about
/// - rocprofiler checks whether it is too late to configure the tool, e.g.
/// something went wrong and rocprofiler was not able to set itself up as
/// the intercepter
/// 2. tool sets up the configuration struct and sets the "size" variable to the size of
/// their configuration struct and sets the "compat_version" field to the
/// ROCPROFILER_API_VERSION_ID defined by the rocprofiler headers when the tool was
/// built
/// - in other words, the user can communicate to rocprofiler, don't read
/// past this distance in my configuration struct and I built against X version
/// so assume the default behavior and capabilties of version X.
/// 3. tool passes this struct to rocprofiler_validate_config(...)
/// - this step checks the config in isolation and will communicate any potential
/// warnings/issues with that configuration, e.g. rocprofiler_X_config is needed,
/// to HW counters XYZ are not available, etc. The tool then has an opportunity
/// to address these issues however they see fit.
/// 4. tool passes this struct to rocprofiler_start_config(...)
/// - internally, we make a call to rocprofiler_validate_config(...) and if any
/// issues still exist with the config in isolation, rocprofiler tells the app
/// to abort -- mechanisms were provided to prevent aborting prior to this call,
/// aborting the app at this point is to guard against rocprofiler "silently"
/// not working because error codes were ignored
/// - rocprofiler then checks whether this config can actually be activated
/// alongside any other active configuration, e.g. this config wants 4 HW counters
/// and another wants 4 HW counters but we can only activate 6 out of 8 of
/// them in this run. Any issues here will not abort execution but, instead,
/// the features of this configuration will not happen (i.e. config won't be
/// activated) and the issues will be communicated with error codes -- giving
/// the tool the opportunity to address the conflicts (i.e. only request tracing
/// and no HW counters) before attempting to activate the modified config.
/// - once rocprofiler determines all features of a config can be activated, it
/// makes an internal copy of the config and returns an identifier for that
/// configuration. The tool is then free to delete the config and any modification
/// to the config will NOT be reflected in the behavior of rocprofiler.
///
///
struct rocprofiler_config
{
// size is used to ensure that we never read past the end of the version
size_t size; // = sizeof(rocprofiler_config)
uint32_t compat_version; // set by user
uint32_t api_version; // set by rocprofiler
uint64_t reserved0; // internal field
void* user_data; // data passed to callbacks
struct rocprofiler_correlation_config* correlation_id; // = &my_cid_config (optional)
struct rocprofiler_buffer_config* buffer; // = &my_buffer_config (required)
struct rocprofiler_domain_config* domain; // = &my_domain_config (required)
struct rocprofiler_filter_config* filter; // = &my_filter_config (optional)
};
/// \brief returns a properly initialized config struct and allocates any data structures
/// necessary for the config to be used
///
/// \param [out] cfg may adjust config or assign values within structs.
rocprofiler_status_t
rocprofiler_allocate_config(struct rocprofiler_config* cfg);
/// \brief rocprofiler validates config, checks for conflicts, etc. Ensures that
/// the configuration is valid *in isolation*, e.g. it may check that the user
/// set the compat_version field and that required config fields, such as buffer
/// are set. This function will be called before \ref rocprofiler_start_config
/// but is provided to help the user validate one or more configs without starting
/// them
///
/// \param [in] cfg configuration to validate
rocprofiler_status_t
rocprofiler_validate_config(const struct rocprofiler_config* cfg);
/// \brief rocprofiler activates configuration and provides a session identifier
/// \param [in] cfg may adjust config or assign values within structs. If error
/// occurs, could nullptr valid sub-configs and leave the pointers to
/// invalid configs
/// \param [out] id the session identifier for this config.
rocprofiler_status_t
rocprofiler_start_config(struct rocprofiler_config*, rocprofiler_session_id_t* id);
/// \brief disable the configuration.
rocprofiler_status_t rocprofiler_stop_config(rocprofiler_session_id_t);
///
///
/// the following 4 functions may be changed to permit removing domain/ops and/or
/// identifying domains and operations via strings
///
///
rocprofiler_status_t
rocprofiler_domain_set_domain(struct rocprofiler_domain_config*,
rocprofiler_tracer_activity_domain_t);
rocprofiler_status_t
rocprofiler_domain_add_domains(struct rocprofiler_domain_config*,
rocprofiler_tracer_activity_domain_t*,
size_t);
rocprofiler_status_t
rocprofiler_domain_add_op(struct rocprofiler_domain_config*,
rocprofiler_tracer_activity_domain_t,
uint32_t);
rocprofiler_status_t
rocprofiler_domain_add_ops(struct rocprofiler_domain_config*,
rocprofiler_tracer_activity_domain_t,
uint32_t*,
size_t);
#ifdef __cplusplus
}
#endif
Разница между файлами не показана из-за своего большого размера Загрузить разницу
+142
Просмотреть файл
@@ -0,0 +1,142 @@
/* Copyright (c) 2022 Advanced Micro Devices, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
/** \section rocprofiler_plugin_api ROCProfiler Plugin API
*
* The ROCProfiler Plugin API is used by the ROCProfiler Tool to output all
* profiling information. Different implementations of the ROCProfiler Plugin
* API can be developed that output the data in different formats. The
* ROCProfiler Tool can be configured to load a specific library that supports
* the user desired format.
*
* The API is not thread safe. It is the responsibility of the ROCProfiler Tool
* to ensure the operations are synchronized and not called concurrently. There
* is no requirement for the ROCProfiler Tool to report trace data in any
* specific order. If the format supported by plugin requires specific
* ordering, it is the responsibility of the plugin implementation to perform
* any necessary sorting.
*/
/**
* \file
* ROCProfiler Tool Plugin API interface.
*/
#ifndef ROCPROFILER_PLUGIN_H_
#define ROCPROFILER_PLUGIN_H_
#include <stdint.h>
#include "rocprofiler.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** \defgroup rocprofiler_plugins ROCProfiler Plugin API Specification
* @{
*/
/** \defgroup initialization_group Initialization and Finalization
* \ingroup rocprofiler_plugins
*
* The ROCProfiler Plugin API must be initialized before using any of the
* operations to report trace data, and finalized after the last trace data has
* been reported.
*
* @{
*/
/**
* Initialize plugin.
* Must be called before any other operation.
*
* @param[in] rocprofiler_major_version The major version of the ROCProfiler API
* being used by the ROCProfiler Tool. An error is reported if this does not
* match the major version of the ROCProfiler API used to build the plugin
* library. This ensures compatibility of the trace data format.
* @param[in] rocprofiler_minor_version The minor version of the ROCProfiler API
* being used by the ROCProfiler Tool. An error is reported if the
* \p rocprofiler_major_version matches and this is greater than the minor
* version of the ROCProfiler API used to build the plugin library. This ensures
* compatibility of the trace data format.
* @param[in] data Pointer to the data passed to the ROCProfiler Plugin by the tool
* @return Returns 0 on success and -1 on error.
*/
ROCPROFILER_EXPORT int
rocprofiler_plugin_initialize(uint32_t rocprofiler_major_version,
uint32_t rocprofiler_minor_version,
void* data);
/**
* Finalize plugin.
* This must be called after ::rocprofiler_plugin_initialize and after all
* profiling data has been reported by
* ::rocprofiler_plugin_write_kernel_records
*/
ROCPROFILER_EXPORT void
rocprofiler_plugin_finalize();
/** @} */
/** \defgroup profiling_record_write_functions Profiling data reporting
* \ingroup rocprofiler_plugins
* Operations to output profiling data.
* @{
*/
// TODO(aelwazir): Recheck wording of the description
/**
* Report Buffer Records.
*
* @param[in] begin Pointer to the first record.
* @param[in] end Pointer to one past the last record.
* @param[in] session_id Session ID
* @param[in] buffer_id Buffer ID
* @return Returns 0 on success and -1 on error.
*/
ROCPROFILER_EXPORT int
rocprofiler_plugin_write_buffer_records(const rocprofiler_record_header_t* begin,
const rocprofiler_record_header_t* end,
rocprofiler_session_id_t session_id,
rocprofiler_buffer_id_t buffer_id);
/**
* Report Synchronous Record.
*
* @param[in] record Synchronous Tracer record.
* @param[in] data : api_data
* @param[in] tracer_data :Tracer record extra data such as function name and kernel name
* @return Returns 0 on success and -1 on error.
*/
ROCPROFILER_EXPORT int
rocprofiler_plugin_write_record(rocprofiler_record_tracer_t record);
/** @} */
/** @} */
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* ROCPROFILER_PLUGIN_H_ */