[Profiler] Enable ROCTX during build by default (#1506)
* Enable ROCTX during build by default * Check for roctx support in cmake
Αυτή η υποβολή περιλαμβάνεται σε:
1 γονέας
bd0f5cccbe
υποβολή
35fe9e06f3
4 files changed
+71
-40
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
* Copyright (c) 2024-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
*
|
||||
* See LICENSE.txt for license information
|
||||
************************************************************************/
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
|
||||
#ifndef ROCTX_NO_IMPL
|
||||
#ifdef ROCTX_ENABLE
|
||||
#include <roctracer/roctx.h>
|
||||
#endif
|
||||
#include "nvtx3/nvtx3.hpp"
|
||||
@@ -126,40 +126,23 @@ public:
|
||||
* 'numEntries', and 'schemaName'
|
||||
*/
|
||||
explicit roctx_scoped_range_in(const nvtxPayloadSchemaEntry_t* schema, const nvtxPayloadData_t* data,
|
||||
const size_t numEntries, const char* schemaName) noexcept
|
||||
{
|
||||
#ifndef ROCTX_NO_IMPL
|
||||
roctxAlloc(&payloadInfo, numEntries);
|
||||
extractPayloadInfo(schema, data, numEntries, schemaName, &payloadInfo);
|
||||
roctxRangePushA(payloadInfo.message);
|
||||
#endif
|
||||
}
|
||||
const size_t numEntries, const char* schemaName) noexcept;
|
||||
|
||||
/**
|
||||
* Construct a 'roctx_scoped_range_in' with the specified 'message'
|
||||
*/
|
||||
explicit roctx_scoped_range_in(const char* message) noexcept
|
||||
{
|
||||
#ifndef ROCTX_NO_IMPL
|
||||
roctxRangePushA(message);
|
||||
#endif
|
||||
}
|
||||
explicit roctx_scoped_range_in(const char* message) noexcept;
|
||||
|
||||
/**
|
||||
* Default constructor 'roctx_scoped_range_in'
|
||||
*/
|
||||
roctx_scoped_range_in() noexcept : roctx_scoped_range_in{""} {/*no impl*/}
|
||||
roctx_scoped_range_in() noexcept;
|
||||
|
||||
/**
|
||||
* Destroy the roctx_scoped_range_in, ending the ROCTX range event.
|
||||
*/
|
||||
~roctx_scoped_range_in() noexcept
|
||||
{
|
||||
#ifndef ROCTX_NO_IMPL
|
||||
roctxRangePop();
|
||||
roctxFree(&payloadInfo);
|
||||
#endif
|
||||
}
|
||||
~roctx_scoped_range_in() noexcept;
|
||||
|
||||
private:
|
||||
roctxPayloadInfo payloadInfo;
|
||||
};
|
||||
|
||||
+41
-5
@@ -1,10 +1,12 @@
|
||||
/*************************************************************************
|
||||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
* Copyright (c) 2024-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
*
|
||||
* See LICENSE.txt for license information
|
||||
************************************************************************/
|
||||
|
||||
#include "roctx.h"
|
||||
#include "param.h"
|
||||
#include "debug.h"
|
||||
|
||||
std::map<uint64_t, roctxPayloadEntryType> nvtxToRoctx {
|
||||
{NVTX_PAYLOAD_ENTRY_TYPE_INT, ROCTX_PAYLOAD_ENTRY_TYPE_INT},
|
||||
@@ -15,21 +17,17 @@ const char* roctxEntryTypeStr[ROCTX_PAYLOAD_NUM_ENTRY_TYPES] = {"ROCTX_PAYLOAD_E
|
||||
const char* ncclRedOpStr[ncclNumDevRedOps] = { "Sum", "Prod", "MinMax", "PreMulSum", "SumPostDiv" };
|
||||
|
||||
void roctxAlloc(roctxPayloadInfo_t payloadInfo, const size_t numEntries) {
|
||||
#ifndef ROCTX_NO_IMPL
|
||||
// Allocate enough memory for numEntries in payloadEntries
|
||||
payloadInfo->payloadEntries = (roctxPayloadSchemaEntryInfo*)malloc(numEntries * sizeof(roctxPayloadSchemaEntryInfo));
|
||||
|
||||
// Allocate memory for the message that will be constructed
|
||||
payloadInfo->message = (char*)malloc(MAX_MESSAGE_LENGTH * sizeof(char));
|
||||
#endif
|
||||
}
|
||||
|
||||
void roctxFree(roctxPayloadInfo_t payloadInfo) {
|
||||
#ifndef ROCTX_NO_IMPL
|
||||
// Free all the dynamically allocated resources by roctx
|
||||
if (payloadInfo->payloadEntries) free(payloadInfo->payloadEntries);
|
||||
if (payloadInfo->message) free((void*)payloadInfo->message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void extractPayloadInfo(const nvtxPayloadSchemaEntry_t* schema, const nvtxPayloadData_t* data, const size_t numEntries,
|
||||
@@ -96,4 +94,42 @@ void stringify(roctxPayloadInfo_t payloadInfo) {
|
||||
}
|
||||
|
||||
snprintf(payloadInfo->message + offset, MAX_MESSAGE_LENGTH - offset, "}");
|
||||
}
|
||||
|
||||
RCCL_PARAM(LogRoctx, "LOG_ROCTX", 0);
|
||||
|
||||
roctx_scoped_range_in::roctx_scoped_range_in(const nvtxPayloadSchemaEntry_t* schema, const nvtxPayloadData_t* data,
|
||||
const size_t numEntries, const char* schemaName) noexcept {
|
||||
if (rcclParamLogRoctx()) {
|
||||
roctxAlloc(&payloadInfo, numEntries);
|
||||
extractPayloadInfo(schema, data, numEntries, schemaName, &payloadInfo);
|
||||
#ifdef ROCTX_ENABLE
|
||||
roctxRangePushA(payloadInfo.message);
|
||||
#else
|
||||
WARN("ROCTX_ENABLE is not defined. Please rebuild with -DROCTX_ENABLE=ON");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
roctx_scoped_range_in::roctx_scoped_range_in(const char* message) noexcept {
|
||||
if (rcclParamLogRoctx()) {
|
||||
#ifdef ROCTX_ENABLE
|
||||
roctxRangePushA(message);
|
||||
#else
|
||||
WARN("ROCTX_ENABLE is not defined. Please rebuild with -DROCTX_ENABLE=ON");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
roctx_scoped_range_in::roctx_scoped_range_in() noexcept : roctx_scoped_range_in{""} {/*no impl*/}
|
||||
|
||||
roctx_scoped_range_in::~roctx_scoped_range_in() noexcept {
|
||||
if (rcclParamLogRoctx()) {
|
||||
#ifdef ROCTX_ENABLE
|
||||
roctxRangePop();
|
||||
#else
|
||||
WARN("ROCTX_ENABLE is not defined. Please rebuild with -DROCTX_ENABLE=ON");
|
||||
#endif
|
||||
roctxFree(&payloadInfo);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user