2
0

context array valid bit reverted

Change-Id: Ibbbf19ffd2e66750d7296d2b45850c21bb86445a


[ROCm/rocprofiler commit: aea5d8e0d9]
Este cometimento está contido em:
Evgeny
2018-03-21 21:11:42 -05:00
ascendente 6a3a1f1906
cometimento ade8a8c868
3 ficheiros modificados com 22 adições e 10 eliminações
+1 -1
Ver ficheiro
@@ -356,7 +356,7 @@ class Context {
if (expr) {
auto it = info_map_.find(name);
if (it == info_map_.end())
EXC_RAISING(HSA_STATUS_ERROR, "metric '" << name << "', rocprofiler info is not found");
EXC_RAISING(HSA_STATUS_ERROR, "metric '" << name << "', rocprofiler info is not found " << this);
rocprofiler_feature_t* info = it->second;
info->data.result_int64 = expr->Eval(args);
info->data.kind = ROCPROFILER_DATA_KIND_INT64;
+8
Ver ficheiro
@@ -7,6 +7,14 @@
#include <sstream>
#include <string>
#define EXC_ABORT(error, stream) \
{ \
std::ostringstream oss; \
oss << __FUNCTION__ << "(), " << stream; \
std::cout << oss.str() << std::endl; \
abort(); \
}
#define EXC_RAISING(error, stream) \
{ \
std::ostringstream oss; \
+13 -9
Ver ficheiro
@@ -40,6 +40,7 @@ struct callbacks_data_t {
// Context stored entry type
struct context_entry_t {
uint32_t valid;
uint32_t index;
rocprofiler_group_t group;
rocprofiler_feature_t* features;
@@ -71,7 +72,7 @@ FILE* result_file_handle = NULL;
// True if a result file is opened
bool result_file_opened = false;
// Dispatch filters
// GPU index filter
// GPU index filter
std::vector<uint32_t>* gpu_index_vec = NULL;
// Kernel name filter
std::vector<std::string>* kernel_string_vec = NULL;
@@ -93,13 +94,12 @@ uint32_t next_context_count() {
perror("pthread_mutex_lock");
exit(1);
}
const uint32_t prev_val = context_count;
context_count = prev_val + 1;
++context_count;
if (pthread_mutex_unlock(&mutex) != 0) {
perror("pthread_mutex_unlock");
exit(1);
}
return prev_val;
return context_count;
}
// Allocate entry to store profiling context
@@ -109,7 +109,7 @@ context_entry_t* alloc_context_entry() {
exit(1);
}
const uint32_t index = context_count;
const uint32_t index = next_context_count();
auto ret = context_array->insert({index, context_entry_t{}});
if (ret.second == false) {
fprintf(stderr, "context_array corruption, index repeated %u\n", index);
@@ -122,6 +122,7 @@ context_entry_t* alloc_context_entry() {
}
context_entry_t* entry = &(ret.first->second);
entry->index = index;
return entry;
}
@@ -249,6 +250,8 @@ void output_group(FILE* file, const rocprofiler_group_t* group, const char* str)
bool dump_context(context_entry_t* entry) {
hsa_status_t status = HSA_STATUS_ERROR;
if (entry->valid == 0) return true;
const rocprofiler_dispatch_record_t* record = entry->data.record;
if (record) {
if (record->complete == 0) {
@@ -263,7 +266,7 @@ bool dump_context(context_entry_t* entry) {
const unsigned feature_count = entry->feature_count;
fprintf(file_handle, "dispatch[%u], queue_index(%lu), kernel_name(\"%s\")",
index,
index - 1,
entry->data.queue_index,
entry->data.kernel_name);
if (record) fprintf(file_handle, ", time(%lu,%lu,%lu,%lu)",
@@ -297,10 +300,11 @@ bool dump_context(context_entry_t* entry) {
rocprofiler_close(group.context);
}
entry->valid = 0;
return true;
}
// Profiling completion handler
// Dump and clean a given context entry
static inline bool dump_context_entry(context_entry_t* entry) {
const bool ret = dump_context(entry);
if (ret) dealloc_context_entry(entry);
@@ -333,7 +337,7 @@ void dump_context_array() {
auto end = context_array->end();
while (it != end) {
auto cur = it++;
dump_context_entry(&(cur->second));
dump_context(&(cur->second));
}
}
@@ -447,7 +451,7 @@ hsa_status_t dispatch_callback(const rocprofiler_callback_data_t* callback_data,
entry->data = *callback_data;
entry->data.kernel_name = strdup(callback_data->kernel_name);
entry->file_handle = tool_data->file_handle;
entry->index = next_context_count();
entry->valid = 1;
if (trace_on) {
fprintf(stdout, "tool::dispatch: context_array %d\n", (int)(context_array->size()));