several fixes; adding direct loading of alprofile library

此提交包含在:
Evgeny committed 2017-12-19 15:32:34 -06:00
1 父節點 84644dc732
當前提交 8270530fec
16 file changed
+195 -136

No files matched your search

+4 -2
查看文件
@@ -55,12 +55,14 @@ class InterceptQueue {
ProxyQueue* proxy = ProxyQueue::Create(agent, size, type, callback, data, private_segment_size,
group_segment_size, queue, &status);
if (status != HSA_STATUS_SUCCESS) {
if (status == HSA_STATUS_SUCCESS) {
InterceptQueue* obj = new InterceptQueue(agent, proxy);
(*obj_map_)[(uint64_t)(*queue)] = obj;
status = proxy->SetInterceptCB(OnSubmitCB, obj);
}
if (status != HSA_STATUS_SUCCESS) abort();
return status;
}
@@ -97,7 +99,7 @@ class InterceptQueue {
dispatch_packet->kernel_object,
GetKernelName(dispatch_packet)};
hsa_status_t status = on_dispatch_cb_(&data, on_dispatch_cb_data_, &group);
if (status == HSA_STATUS_SUCCESS) {
if ((status == HSA_STATUS_SUCCESS) && (group.context != NULL)) {
Context* context = reinterpret_cast<Context*>(group.context);
const pkt_vector_t& start_vector = context->StartPackets(group.index);
const pkt_vector_t& stop_vector = context->StopPackets(group.index);
+6 -1
查看文件
@@ -110,13 +110,18 @@ class MetricsDict {
MetricsDict(const util::AgentInfo* agent_info) : xml_(NULL) {
const char* xml_name = getenv("ROCP_METRICS");
if (xml_name != NULL) {
xml_ = new xml::Xml(xml_name);
xml_ = xml::Xml::Create(xml_name);
if (xml_ == NULL) EXC_RAISING(HSA_STATUS_ERROR, "metrics .xml open error '" << xml_name << "'");
std::cout << "ROCProfiler: importing metrics from '" << xml_name << "':" << std::endl;
ImportMetrics(agent_info, agent_info->gfxip);
ImportMetrics(agent_info, "global");
}
}
~MetricsDict() {
xml::Xml::Destroy(xml_);
}
void ImportMetrics(const util::AgentInfo* agent_info, const char* scope) {
auto scope_list = xml_->GetNodes("top." + std::string(scope) + ".metric");
if (!scope_list.empty()) {
+3 -1
查看文件
@@ -24,7 +24,7 @@ ProxyQueue* ProxyQueue::Create(hsa_agent_t agent, uint32_t size, hsa_queue_type3
ProxyQueue* instance = new SimpleProxyQueue();
#endif
if (instance != NULL) {
const auto suc = instance->Init(agent, size, type, callback, data, private_segment_size,
suc = instance->Init(agent, size, type, callback, data, private_segment_size,
group_segment_size, queue);
if (suc != HSA_STATUS_SUCCESS) {
delete instance;
@@ -32,10 +32,12 @@ ProxyQueue* ProxyQueue::Create(hsa_agent_t agent, uint32_t size, hsa_queue_type3
}
}
*status = suc;
assert(*status == HSA_STATUS_SUCCESS);
return instance;
}
hsa_status_t ProxyQueue::Destroy(const ProxyQueue* obj) {
assert(obj != NULL);
auto suc = obj->Cleanup();
delete obj;
return suc;
+1 -1
查看文件
@@ -7,5 +7,5 @@ void SimpleProxyQueue::HsaIntercept(HsaApiTable* table) {
table->core_->hsa_queue_store_write_index_relaxed_fn = rocprofiler::SimpleProxyQueue::StoreIndex;
}
std::map<signal_handle_t, SimpleProxyQueue*> SimpleProxyQueue::queue_map_;
SimpleProxyQueue::queue_map_t* SimpleProxyQueue::queue_map_ = NULL;
} // namespace rocprofiler
+16 -8
查看文件
@@ -24,8 +24,8 @@ class SimpleProxyQueue : public ProxyQueue {
static void HsaIntercept(HsaApiTable* table);
static void SignalStore(hsa_signal_t signal, hsa_signal_value_t que_idx) {
auto it = queue_map_.find(signal.handle);
if (it != queue_map_.end()) {
auto it = queue_map_->find(signal.handle);
if (it != queue_map_->end()) {
SimpleProxyQueue* instance = it->second;
const uint64_t begin = instance->submit_index_;
const uint64_t end = que_idx + 1;
@@ -46,8 +46,8 @@ class SimpleProxyQueue : public ProxyQueue {
static uint64_t LoadIndex(const hsa_queue_t* queue) {
uint64_t index = 0;
auto it = queue_map_.find(queue->doorbell_signal.handle);
if (it != queue_map_.end()) {
auto it = queue_map_->find(queue->doorbell_signal.handle);
if (it != queue_map_->end()) {
SimpleProxyQueue* instance = it->second;
instance->mutex_.lock();
index = instance->queue_index_;
@@ -58,8 +58,8 @@ class SimpleProxyQueue : public ProxyQueue {
}
static void StoreIndex(const hsa_queue_t* queue, uint64_t value) {
auto it = queue_map_.find(queue->doorbell_signal.handle);
if (it != queue_map_.end()) {
auto it = queue_map_->find(queue->doorbell_signal.handle);
if (it != queue_map_->end()) {
SimpleProxyQueue* instance = it->second;
instance->queue_index_ = value;
instance->mutex_.unlock();
@@ -115,6 +115,8 @@ class SimpleProxyQueue : public ProxyQueue {
~SimpleProxyQueue() {}
private:
typedef std::map<signal_handle_t, SimpleProxyQueue*> queue_map_t;
hsa_status_t Init(hsa_agent_t agent, uint32_t size, hsa_queue_type32_t type,
void (*callback)(hsa_status_t status, hsa_queue_t* source, void* data),
void* data, uint32_t private_segment_size, uint32_t group_segment_size,
@@ -129,6 +131,7 @@ class SimpleProxyQueue : public ProxyQueue {
agent_info_ = util::HsaRsrcFactory::Instance().GetAgentInfo(agent);
if (agent_info_ != NULL) {
if (agent_info_->dev_type == HSA_DEVICE_TYPE_GPU) {
printf("queue_create size 0x%x(%d)\n", size, (int)size);
status = hsa_queue_create_fn(agent, size, HSA_QUEUE_TYPE_MULTI, NULL, NULL, UINT32_MAX,
UINT32_MAX, &queue_);
if (status == HSA_STATUS_SUCCESS) {
@@ -138,11 +141,16 @@ class SimpleProxyQueue : public ProxyQueue {
uintptr_t addr = (uintptr_t)data_array_;
queue_->base_address = (void*)((addr + align_mask_) & ~align_mask_);
status = hsa_signal_create(1, 0, NULL, &(queue_->doorbell_signal));
if (status != HSA_STATUS_SUCCESS) abort();
queue_mask_ = size - 1;
queue_map_[queue_->doorbell_signal.handle] = this;
if (queue_map_ == NULL) queue_map_ = new queue_map_t;
(*queue_map_)[queue_->doorbell_signal.handle] = this;
}
else abort();
}
}
if (status != HSA_STATUS_SUCCESS) abort();
return status;
}
@@ -155,7 +163,7 @@ class SimpleProxyQueue : public ProxyQueue {
return status;
}
static std::map<signal_handle_t, SimpleProxyQueue*> queue_map_;
static queue_map_t* queue_map_;
const util::AgentInfo* agent_info_;
hsa_queue_t* queue_;
static const uintptr_t align_mask_ = sizeof(packet_t) - 1;