Thread trace and Trace Decoder API tests and samples (#416)

* Adding test and samples to decoder

* Fix sample

* Formatting

* Fix multi test

* Disable sample

* Fix tests

* Format

* Version fix

* Locking the decoder

* Add atomic

* Review comments

* Format

* Adding readme

* merge conflict and adding PCS+ATT test

* Review comments

* Properly disable PCS test

* Update tests/rocprofv3/advanced-thread-trace/CMakeLists.txt

* Adding back env var test

* Name fix

* Preload sample

* Addressing review comments

* Update docs

---------

Co-authored-by: Giovanni Baraldi <gbaraldi@amd.com>
This commit is contained in:
Baraldi, Giovanni
2025-07-23 03:08:12 +02:00
committed by GitHub
parent bf0fad1d54
commit e898079a13
22 changed files with 982 additions and 404 deletions
+13 -49
View File
@@ -40,60 +40,21 @@
#include <unordered_map>
#include <vector>
#define ROCPROFILER_VAR_NAME_COMBINE(X, Y) X##Y
#define ROCPROFILER_VARIABLE(X, Y) ROCPROFILER_VAR_NAME_COMBINE(X, Y)
#define C_API_BEGIN \
try \
{
#define C_API_END \
} \
catch(std::exception & e) \
{ \
std::cerr << "Error in " << __FILE__ << ':' << __LINE__ << ' ' << e.what() << std::endl; \
} \
catch(...) { std::cerr << "Error in " << __FILE__ << ':' << __LINE__ << std::endl; }
#define ROCPROFILER_CALL(result, msg) \
if((result) != ROCPROFILER_STATUS_SUCCESS) \
{ \
rocprofiler_status_t CHECKSTATUS = result; \
if(CHECKSTATUS != ROCPROFILER_STATUS_SUCCESS) \
{ \
std::string status_msg = rocprofiler_get_status_string(CHECKSTATUS); \
std::cerr << "[" #result "][" << __FILE__ << ":" << __LINE__ << "] " << msg \
<< " failed with error code " << CHECKSTATUS << ": " << status_msg \
<< std::endl; \
std::stringstream errmsg{}; \
errmsg << "[" #result "][" << __FILE__ << ":" << __LINE__ << "] " << msg " failure (" \
<< status_msg << ")"; \
throw std::runtime_error(errmsg.str()); \
} \
std::cerr << "Error: " << msg << std::endl; \
abort(); \
}
#define DECODER_CALL(result) \
if((result) != ROCPROFILER_STATUS_SUCCESS) \
{ \
std::cerr << "Error: Generic decoder error" << std::endl; \
}
namespace Callbacks
{
struct CodeobjInfo
{
int64_t addr = 0;
size_t size = 0;
size_t id = 0;
std::string filename{};
std::string uri{};
};
struct ToolData
{
ToolData(const char* out)
: out_dir(out){};
std::string out_dir{};
std::mutex mut{};
std::vector<CodeobjInfo> codeobjs{};
std::vector<std::string> att_files{};
std::unordered_map<uint64_t, std::string> kernel_id_to_kernel_name = {};
};
void
tool_codeobj_tracing_callback(rocprofiler_callback_tracing_record_t record,
rocprofiler_user_data_t*,
@@ -107,6 +68,9 @@ shader_data_callback(rocprofiler_agent_id_t agent,
rocprofiler_user_data_t userdata);
void
finalize_json(void* userdata);
init();
void
finalize(void* /* tool_data */);
} // namespace Callbacks