Add support for device counter collection ioctl (#46)

Add support for device counter colleciton ioctl

Adds support for the device counter collection IOCTL. This IOCTL
allows for device wide counters to be collected even if the queue
is not intercepted by rocprofiler-sdk (required for system profilers).

A test is also included which checks this behavior by creating a queue
that does not have profiling enabled on it and checks to see if SQ
counters can be read from it. Note: this test will be skipped if the KFD
version does not contain this IOCTL.

Right now the check is "soft" in that if the IOCTL is present and there
is an error with permissions, rocprofiler will continue but will print
an error stating that system wide device profiling and collected counter
values may be degraded. This is primarily to avoid breaking existing
users (like PAPI) who may not need the IOCTL's capability and to give
them time to update.

Co-authored-by: Benjamin Welton <ben@amd.com>
This commit is contained in:
Welton, Benjamin
2024-12-19 13:27:35 -08:00
committad av GitHub
förälder 9c21c49aa1
incheckning c574881cdb
12 ändrade filer med 305 tillägg och 61 borttagningar
@@ -106,9 +106,9 @@ rocprofiler_configure_device_counting_service(rocprofiler_context_id_t context_i
* @param [in] context_id context id
* @param [in] user_data User supplied data, included in records outputted to buffer.
* @param [in] flags Flags to specify how the counter data should be collected (defaults to sync).
* @param [in/out] output_records Output records collected via sampling (output is also written to
* @param [in] output_records Output records collected via sampling (output is also written to
* buffer). Must be allocated by caller.
* @param [in/out] rec_count On entry, this is the maximum number of records rocprof can store in
* @param [in] rec_count On entry, this is the maximum number of records rocprof can store in
* output_records. On exit, contains the number of actual records.
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the context does not exist or
+2 -1
Visa fil
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
// Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -106,6 +106,7 @@ typedef enum // NOLINT(performance-enum-size)
///< status code for more information.
ROCPROFILER_STATUS_ERROR_EXCEEDS_HW_LIMIT, ///< Exceeds hardware limits for collection.
ROCPROFILER_STATUS_ERROR_AGENT_ARCH_NOT_SUPPORTED, ///< Agent HW architecture not supported.
ROCPROFILER_STATUS_ERROR_PERMISSION_DENIED, ///< Permission denied.
ROCPROFILER_STATUS_LAST,
} rocprofiler_status_t;