Comhaid
rocm-systems/runtime/hsa-ext-aql-profile/src/perfcounter/info_set.cpp
T
Evgeny 25035b8d09 Adding HSA extension AMD AQL profile library, see Readme.txt
Change-Id: Icbc1e0fb0185642eabbab411a2138ea030d22be8
2017-06-13 16:18:06 -04:00

75 línte
1.3 KiB
C++

#include "info_set.h"
#include "var_data.h"
using namespace std;
namespace pm4_profile {
InfoSet::InfoSet() {
releaseParameters();
info_table_.clear();
p_data_ = NULL;
}
InfoSet::~InfoSet() {
releaseParameters();
info_table_.clear();
free(p_data_);
p_data_ = NULL;
}
bool InfoSet::setInfo(uint32_t info, uint32_t info_size, void* p_data) {
if (info_table_.end() != info_table_.find(info)) {
return false;
}
VarData data;
if (!data.set(info_size, p_data)) {
return false;
}
info_table_.insert(VarDataMap::value_type(info, data));
return true;
}
bool InfoSet::getInfo(uint32_t info, uint32_t& ret_size, void** pp_data) {
if (!pp_data || (0 == info_table_.size())) {
return false;
}
VarDataMap::iterator it = info_table_.find(info);
if (it == info_table_.end()) {
return false;
}
int size = it->second.getSize();
if (size == 0) {
return false;
}
free(p_data_);
p_data_ = NULL;
p_data_ = malloc(size);
if (!p_data_) {
return false;
}
*pp_data = p_data_;
ret_size = info_table_[info].get(size, *pp_data);
return true;
}
void InfoSet::releaseParameters() {
VarDataMap::iterator it = info_table_.begin();
VarDataMap::iterator table_end = info_table_.end();
for (; it != table_end; it++) {
it->second.clear();
}
return;
}
} // pm4_profile