@@ -17,7 +17,7 @@ The library source tree:
|
||||
|
||||
Build environment:
|
||||
|
||||
$ export CMAKE_PREFIX_PATH="<path to hsa-runtime includes>;<path to hsa-runtime library>"
|
||||
$ export CMAKE_PREFIX_PATH=<path to hsa-runtime includes>:<path to hsa-runtime library>
|
||||
$ export CMAKE_BUILD_TYPE=<debug|release> # release by default
|
||||
$ export CMAKE_DEBUG_TRACE=1 # 1 to enable debug tracing
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ set ( CMAKE_SKIP_BUILD_RPATH TRUE )
|
||||
|
||||
## CLANG options
|
||||
if ( "$ENV{CXX}" STREQUAL "/usr/bin/clang++" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=1000000" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=1000000" )
|
||||
endif()
|
||||
|
||||
## Enable debug trace
|
||||
@@ -52,7 +52,12 @@ if ( NOT "$ENV{CMAKE_HSA_PROXY}" STREQUAL "no" )
|
||||
add_definitions ( -DROCP_HSA_PROXY=1 )
|
||||
endif()
|
||||
|
||||
## Check env vars
|
||||
## Enable direct loading of AQL-profile HSA extension
|
||||
if ( DEFINED ENV{CMAKE_LD_AQLPROFILE} )
|
||||
add_definitions ( -DROCP_LD_AQLPROFILE=1 )
|
||||
endif()
|
||||
|
||||
## Make env vars
|
||||
if ( NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "" )
|
||||
if ( DEFINED ENV{CMAKE_BUILD_TYPE} )
|
||||
set ( CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE} )
|
||||
@@ -83,19 +88,15 @@ elseif ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86" )
|
||||
endif ()
|
||||
|
||||
## Find hsa-runtime headers/lib
|
||||
find_file ( HSA_RUNTIME_INC "hsa/hsa.h" )
|
||||
get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY )
|
||||
find_file ( HSA_RUNTIME_INC "hsa.h" )
|
||||
if ( "${HSA_RUNTIME_INC_PATH}" STREQUAL "" )
|
||||
find_file ( HSA_RUNTIME_INC "hsa.h" )
|
||||
get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY )
|
||||
find_file ( HSA_RUNTIME_INC "hsa/hsa.h" )
|
||||
endif()
|
||||
|
||||
set ( HSA_RUNTIME_NAME "hsa-runtime64" )
|
||||
find_library ( HSA_RUNTIME_LIB "lib${HSA_RUNTIME_NAME}.so" )
|
||||
find_library ( HSA_RUNTIME_LIB "libhsa-runtime${NBIT}.so" )
|
||||
get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY )
|
||||
get_filename_component ( HSA_RUNTIME_LIB_PATH ${HSA_RUNTIME_LIB} DIRECTORY )
|
||||
|
||||
set ( HSA_KMT_NAME "hsakmt" )
|
||||
find_library ( HSA_KMT_LIB "lib${HSA_KMT_NAME}.so" )
|
||||
find_library ( HSA_KMT_LIB "libhsakmt.so" )
|
||||
get_filename_component ( HSA_KMT_LIB_PATH ${HSA_KMT_LIB} DIRECTORY )
|
||||
|
||||
set ( API_PATH ${HSA_RUNTIME_INC_PATH} )
|
||||
|
||||
@@ -27,6 +27,7 @@ typedef std::vector<const counter_t*> counters_vec_t;
|
||||
class Metric {
|
||||
public:
|
||||
Metric(const std::string& name) : name_(name) {}
|
||||
virtual ~Metric() {}
|
||||
std::string GetName() const { return name_; }
|
||||
virtual void GetCounters(counters_vec_t& vec) const = 0;
|
||||
counters_vec_t GetCounters() const {
|
||||
@@ -64,7 +65,6 @@ class ExprMetric : public Metric {
|
||||
const xml::Expr* expr_;
|
||||
};
|
||||
|
||||
|
||||
class MetricsDict {
|
||||
public:
|
||||
typedef std::map<std::string, const Metric*> cache_t;
|
||||
@@ -99,6 +99,12 @@ class MetricsDict {
|
||||
return ret.first->second;
|
||||
}
|
||||
|
||||
static void Destroy() {
|
||||
for (auto& entry : *map_) delete entry.second;
|
||||
delete map_;
|
||||
map_ = NULL;
|
||||
}
|
||||
|
||||
const Metric* Get(const std::string& name) const {
|
||||
const Metric* metric = NULL;
|
||||
auto it = cache_.find(name);
|
||||
@@ -106,6 +112,10 @@ class MetricsDict {
|
||||
return metric;
|
||||
}
|
||||
|
||||
uint32_t Size() const { return cache_.size(); }
|
||||
const_iterator_t Begin() const { return cache_.begin(); }
|
||||
const_iterator_t End() const { return cache_.end(); }
|
||||
|
||||
private:
|
||||
MetricsDict(const util::AgentInfo* agent_info) : xml_(NULL) {
|
||||
const char* xml_name = getenv("ROCP_METRICS");
|
||||
@@ -120,6 +130,7 @@ class MetricsDict {
|
||||
|
||||
~MetricsDict() {
|
||||
xml::Xml::Destroy(xml_);
|
||||
for (auto& entry : cache_) delete entry.second;
|
||||
}
|
||||
|
||||
void ImportMetrics(const util::AgentInfo* agent_info, const char* scope) {
|
||||
@@ -163,7 +174,6 @@ class MetricsDict {
|
||||
<< "'");
|
||||
} else {
|
||||
xml::Expr* expr_obj = new xml::Expr(expr_str, new ExprCache(&cache_));
|
||||
//std::cout << " " << name << " = " << expr_obj->String() << std::endl;
|
||||
counters_vec_t counters_vec;
|
||||
for (const std::string var : expr_obj->GetVars()) {
|
||||
auto it = cache_.find(var);
|
||||
@@ -175,18 +185,18 @@ class MetricsDict {
|
||||
cache_[name] = new ExprMetric(name, counters_vec, expr_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (auto& v : cache_) {
|
||||
const Metric* metric = v.second;
|
||||
counters_vec_t counters_vec;
|
||||
printf("> Metric '%s'\n", metric->GetName().c_str());
|
||||
metric->GetCounters(counters_vec);
|
||||
for (auto c : counters_vec) {
|
||||
printf(" counter %s, b(%u), i (%u), e (%u)\n", c->name.c_str(), c->event.block_name, c->event.block_index, c->event.counter_id);
|
||||
}
|
||||
void Print() {
|
||||
for (auto& v : cache_) {
|
||||
const Metric* metric = v.second;
|
||||
counters_vec_t counters_vec;
|
||||
printf("> Metric '%s'\n", metric->GetName().c_str());
|
||||
metric->GetCounters(counters_vec);
|
||||
for (auto c : counters_vec) {
|
||||
printf(" counter %s, b(%u), i (%u), e (%u)\n", c->name.c_str(), c->event.block_name, c->event.block_index, c->event.counter_id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,7 @@ bool TestHsa::Initialize(int arg_cnt, char** arg_list) {
|
||||
setup_timer_idx_ = hsa_timer_.CreateTimer();
|
||||
dispatch_timer_idx_ = hsa_timer_.CreateTimer();
|
||||
|
||||
hsa_rsrc_ = HsaInstantiate(agent_id_);
|
||||
if (hsa_rsrc_ == NULL) {
|
||||
if (HsaInstantiate(agent_id_) == NULL) {
|
||||
TEST_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -120,8 +120,11 @@ HsaRsrcFactory::HsaRsrcFactory() {
|
||||
|
||||
// Get AqlProfile API table
|
||||
aqlprofile_api_ = {0};
|
||||
#ifdef ROCP_LD_AQLPROFILE
|
||||
status = LoadAqlProfileLib(&aqlprofile_api_);
|
||||
#else
|
||||
status = hsa_system_get_extension_table(HSA_EXTENSION_AMD_AQLPROFILE, 1, 0, &aqlprofile_api_);
|
||||
if (status != HSA_STATUS_SUCCESS) status = LoadAqlProfileLib(&aqlprofile_api_);
|
||||
#endif
|
||||
CHECK_STATUS("aqlprofile API table load failed", status);
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user