rc file options: 'basenames', 'timestamp', 'ctx-limit', 'heartbeat', 'sqtt-size'

[ROCm/rocprofiler commit: 62531b88ed]
This commit is contained in:
Evgeny
2018-04-11 13:26:51 -05:00
parent ecfc347ede
commit d4817a45b1
12 changed files with 135 additions and 153 deletions
+2 -3
View File
@@ -375,9 +375,8 @@ class Context {
}
}
static void SetTimeout(uint64_t timeout) {
timeout_ = timeout;
}
static void SetTimeout(uint64_t timeout) { timeout_ = timeout; }
static uint64_t GetTimeout() { return timeout_; }
private:
// Getting profling packets
@@ -144,6 +144,7 @@ class InterceptQueue {
static void SetTimeout(uint64_t timeout) { timeout_ = timeout; }
static void TrackerOn(bool on) { tracker_on_ = on; }
static bool IsTrackerOn() { return tracker_on_; }
private:
InterceptQueue(const hsa_agent_t& agent, hsa_queue_t* const queue, ProxyQueue* proxy) :
+1 -1
View File
@@ -212,7 +212,7 @@ class PmcProfile : public Profile {
class SqttProfile : public Profile {
public:
static inline void SetSize(const uint32_t& size) { output_buffer_size_ = size; }
// static inline uint32_t GetSize() { return output_buffer_size_; }
static inline uint32_t GetSize() { return output_buffer_size_; }
SqttProfile(const util::AgentInfo* agent_info) : Profile(agent_info) {
profile_.type = HSA_VEN_AMD_AQLPROFILE_EVENT_TYPE_SQTT;
@@ -1,8 +1,6 @@
#include "core/proxy_queue.h"
#ifdef ROCP_HSA_PROXY
#include "core/hsa_proxy_queue.h"
#endif
#include "core/simple_proxy_queue.h"
namespace rocprofiler {
@@ -17,12 +15,8 @@ ProxyQueue* ProxyQueue::Create(hsa_agent_t agent, uint32_t size, hsa_queue_type3
uint32_t group_segment_size, hsa_queue_t** queue,
hsa_status_t* status) {
hsa_status_t suc = HSA_STATUS_ERROR;
#ifdef ROCP_HSA_PROXY
ProxyQueue* instance =
(rocp_type_) ? (ProxyQueue*) new SimpleProxyQueue() : (ProxyQueue*) new HsaProxyQueue();
#else
ProxyQueue* instance = new SimpleProxyQueue();
#endif
if (instance != NULL) {
suc = instance->Init(agent, size, type, callback, data, private_segment_size,
group_segment_size, queue);
@@ -20,14 +20,10 @@ typedef void (*on_submit_cb_t)(const void* packet, uint64_t count, uint64_t que_
class ProxyQueue : public Queue {
public:
static void InitFactory() {
#ifdef ROCP_HSA_PROXY
const char* type = getenv("ROCP_PROXY_QUEUE");
if (type != NULL) {
if (strncmp(type, "rocp", 4) == 0) rocp_type_ = true;
}
#else
rocp_type_ = true;
#endif
}
static void HsaIntercept(HsaApiTable* table);
+34 -36
View File
@@ -48,10 +48,8 @@ decltype(hsa_queue_load_write_index_scacquire)* hsa_queue_load_write_index_scacq
decltype(hsa_queue_store_write_index_screlease)* hsa_queue_store_write_index_screlease_fn;
decltype(hsa_queue_load_read_index_scacquire)* hsa_queue_load_read_index_scacquire_fn;
#ifdef ROCP_HSA_PROXY
decltype(hsa_amd_queue_intercept_create)* hsa_amd_queue_intercept_create_fn;
decltype(hsa_amd_queue_intercept_register)* hsa_amd_queue_intercept_register_fn;
#endif
::HsaApiTable* kHsaApiTable;
@@ -71,10 +69,8 @@ void SaveHsaApi(::HsaApiTable* table) {
hsa_queue_store_write_index_screlease_fn = table->core_->hsa_queue_store_write_index_screlease_fn;
hsa_queue_load_read_index_scacquire_fn = table->core_->hsa_queue_load_read_index_scacquire_fn;
#ifdef ROCP_HSA_PROXY
hsa_amd_queue_intercept_create_fn = table->amd_ext_->hsa_amd_queue_intercept_create_fn;
hsa_amd_queue_intercept_register_fn = table->amd_ext_->hsa_amd_queue_intercept_register_fn;
#endif
}
void RestoreHsaApi() {
@@ -93,37 +89,58 @@ void RestoreHsaApi() {
table->core_->hsa_queue_store_write_index_screlease_fn = hsa_queue_store_write_index_screlease_fn;
table->core_->hsa_queue_load_read_index_scacquire_fn = hsa_queue_load_read_index_scacquire_fn;
#ifdef ROCP_HSA_PROXY
table->amd_ext_->hsa_amd_queue_intercept_create_fn = hsa_amd_queue_intercept_create_fn;
table->amd_ext_->hsa_amd_queue_intercept_register_fn = hsa_amd_queue_intercept_register_fn;
#endif
}
typedef void (*tool_handler_t)();
typedef void (*tool_handler_prop_t)(rocprofiler_settings_t*);
void * kTtoolHandle = NULL;
void LoadTool(const char* tool_lib) {
bool LoadTool() {
bool intercept_mode = false;
const char* tool_lib = getenv("ROCP_TOOL_LIB");
if (tool_lib) {
intercept_mode = true;
kTtoolHandle = dlopen(tool_lib, RTLD_NOW);
if (kTtoolHandle == NULL) {
fprintf(stderr, "ROCProfiler: can't load tool library \"%s\"\n", tool_lib);
fprintf(stderr, "%s\n", dlerror());
exit(1);
abort();
}
tool_handler_t handler = reinterpret_cast<tool_handler_t>(dlsym(kTtoolHandle, "OnLoadTool"));
if (handler == NULL) {
fprintf(stderr, "ROCProfiler: tool library corrupted, OnLoadTool() method is expected\n");
tool_handler_prop_t handler_prop = reinterpret_cast<tool_handler_prop_t>(dlsym(kTtoolHandle, "OnLoadToolProp"));
if ((handler == NULL) && (handler_prop == NULL)) {
fprintf(stderr, "ROCProfiler: tool library corrupted, OnLoadTool()/OnLoadToolProp() method is expected\n");
fprintf(stderr, "%s\n", dlerror());
exit(1);
abort();
}
tool_handler_t on_unload_handler = reinterpret_cast<tool_handler_t>(dlsym(kTtoolHandle, "OnUnloadTool"));
if (on_unload_handler == NULL) {
fprintf(stderr, "ROCProfiler: tool library corrupted, OnUnloadTool() method is expected\n");
fprintf(stderr, "%s\n", dlerror());
exit(1);
abort();
}
handler();
rocprofiler_settings_t settings{};
settings.intercept_mode = (intercept_mode) ? 1 : 0;
settings.sqtt_size = SqttProfile::GetSize();
settings.timeout = Context::GetTimeout();
settings.timestamp_on = InterceptQueue::IsTrackerOn() ? 1 : 0;
if (handler) handler();
else if (handler_prop) handler_prop(&settings);
intercept_mode = (settings.intercept_mode != 0);
SqttProfile::SetSize(settings.sqtt_size);
Context::SetTimeout(settings.timeout);
InterceptQueue::SetTimeout(settings.timeout);
InterceptQueue::TrackerOn(settings.timestamp_on != 0);
}
return intercept_mode;
}
void UnloadTool() {
@@ -132,7 +149,7 @@ void UnloadTool() {
if (handler == NULL) {
fprintf(stderr, "ROCProfiler error: tool library corrupted, OnUnloadTool() method is expected\n");
fprintf(stderr, "%s\n", dlerror());
exit(1);
abort();
}
handler();
dlclose(kTtoolHandle);
@@ -141,25 +158,6 @@ void UnloadTool() {
CONSTRUCTOR_API void constructor() {
util::Logger::Create();
const char* sqtt_size_str = getenv("ROCP_SQTT_SIZE");
if (sqtt_size_str != NULL) {
const uint32_t sqtt_size_val = strtoull(sqtt_size_str, NULL, 0);
SqttProfile::SetSize(sqtt_size_val);
}
const char* timeout_str = getenv("ROCP_DATA_TIMEOUT");
if (timeout_str != NULL) {
const uint64_t timeout_val = strtoull(timeout_str, NULL, 0);
Context::SetTimeout(timeout_val);
InterceptQueue::SetTimeout(timeout_val);
}
const char* tracker_on_str = getenv("ROCP_TRACKER_ON");
if (tracker_on_str != NULL) {
if (strncmp(tracker_on_str, "true", 4) == 0) InterceptQueue::TrackerOn(true);
if (strncmp(tracker_on_str, "false", 4) == 0) InterceptQueue::TrackerOn(false);
}
}
DESTRUCTOR_API void destructor() {
@@ -185,6 +183,7 @@ const MetricsDict* GetMetrics(const hsa_agent_t& agent) {
return metrics;
}
rocprofiler_properties_t rocprofiler_properties;
uint64_t Context::timeout_ = UINT64_MAX;
uint32_t SqttProfile::output_buffer_size_ = 0x2000000; // 32M
Tracker::mutex_t Tracker::mutex_;
@@ -200,15 +199,14 @@ extern "C" {
// HSA-runtime tool on-load method
PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
const char* const* failed_tool_names) {
const bool intercept_mode = (getenv("ROCP_HSA_INTERCEPT") != NULL);
rocprofiler::SaveHsaApi(table);
rocprofiler::ProxyQueue::InitFactory();
const bool intercept_mode = rocprofiler::LoadTool();
// HSA intercepting
if (intercept_mode) {
rocprofiler::InterceptQueue::HsaIntercept(table);
rocprofiler::ProxyQueue::HsaIntercept(table);
rocprofiler::InterceptQueue::HsaIntercept(table);
}
rocprofiler::LoadTool(getenv("ROCP_TOOL_LIB"));
return true;
}
@@ -140,8 +140,8 @@ class SimpleProxyQueue : public ProxyQueue {
queue_index_(0),
queue_mask_(0),
submit_index_(0),
on_submit_cb_(0),
on_submit_cb_data_(0)
on_submit_cb_(NULL),
on_submit_cb_data_(NULL)
{
printf("ROCProfiler: SimpleProxyQueue is enabled\n");
fflush(stdout);