minor changes
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ The library source tree:
|
|||||||
|
|
||||||
Build environment:
|
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_BUILD_TYPE=<debug|release> # release by default
|
||||||
$ export CMAKE_DEBUG_TRACE=1 # 1 to enable debug tracing
|
$ export CMAKE_DEBUG_TRACE=1 # 1 to enable debug tracing
|
||||||
|
|
||||||
|
|||||||
+12
-11
@@ -34,7 +34,7 @@ set ( CMAKE_SKIP_BUILD_RPATH TRUE )
|
|||||||
|
|
||||||
## CLANG options
|
## CLANG options
|
||||||
if ( "$ENV{CXX}" STREQUAL "/usr/bin/clang++" )
|
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()
|
endif()
|
||||||
|
|
||||||
## Enable debug trace
|
## Enable debug trace
|
||||||
@@ -52,7 +52,12 @@ if ( NOT "$ENV{CMAKE_HSA_PROXY}" STREQUAL "no" )
|
|||||||
add_definitions ( -DROCP_HSA_PROXY=1 )
|
add_definitions ( -DROCP_HSA_PROXY=1 )
|
||||||
endif()
|
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 ( NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "" )
|
||||||
if ( DEFINED ENV{CMAKE_BUILD_TYPE} )
|
if ( DEFINED ENV{CMAKE_BUILD_TYPE} )
|
||||||
set ( CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE} )
|
set ( CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE} )
|
||||||
@@ -83,19 +88,15 @@ elseif ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86" )
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
## Find hsa-runtime headers/lib
|
## Find hsa-runtime headers/lib
|
||||||
find_file ( HSA_RUNTIME_INC "hsa/hsa.h" )
|
find_file ( HSA_RUNTIME_INC "hsa.h" )
|
||||||
get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY )
|
|
||||||
if ( "${HSA_RUNTIME_INC_PATH}" STREQUAL "" )
|
if ( "${HSA_RUNTIME_INC_PATH}" STREQUAL "" )
|
||||||
find_file ( HSA_RUNTIME_INC "hsa.h" )
|
find_file ( HSA_RUNTIME_INC "hsa/hsa.h" )
|
||||||
get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY )
|
|
||||||
endif()
|
endif()
|
||||||
|
find_library ( HSA_RUNTIME_LIB "libhsa-runtime${NBIT}.so" )
|
||||||
set ( HSA_RUNTIME_NAME "hsa-runtime64" )
|
get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY )
|
||||||
find_library ( HSA_RUNTIME_LIB "lib${HSA_RUNTIME_NAME}.so" )
|
|
||||||
get_filename_component ( HSA_RUNTIME_LIB_PATH ${HSA_RUNTIME_LIB} DIRECTORY )
|
get_filename_component ( HSA_RUNTIME_LIB_PATH ${HSA_RUNTIME_LIB} DIRECTORY )
|
||||||
|
|
||||||
set ( HSA_KMT_NAME "hsakmt" )
|
find_library ( HSA_KMT_LIB "libhsakmt.so" )
|
||||||
find_library ( HSA_KMT_LIB "lib${HSA_KMT_NAME}.so" )
|
|
||||||
get_filename_component ( HSA_KMT_LIB_PATH ${HSA_KMT_LIB} DIRECTORY )
|
get_filename_component ( HSA_KMT_LIB_PATH ${HSA_KMT_LIB} DIRECTORY )
|
||||||
|
|
||||||
set ( API_PATH ${HSA_RUNTIME_INC_PATH} )
|
set ( API_PATH ${HSA_RUNTIME_INC_PATH} )
|
||||||
|
|||||||
+22
-12
@@ -27,6 +27,7 @@ typedef std::vector<const counter_t*> counters_vec_t;
|
|||||||
class Metric {
|
class Metric {
|
||||||
public:
|
public:
|
||||||
Metric(const std::string& name) : name_(name) {}
|
Metric(const std::string& name) : name_(name) {}
|
||||||
|
virtual ~Metric() {}
|
||||||
std::string GetName() const { return name_; }
|
std::string GetName() const { return name_; }
|
||||||
virtual void GetCounters(counters_vec_t& vec) const = 0;
|
virtual void GetCounters(counters_vec_t& vec) const = 0;
|
||||||
counters_vec_t GetCounters() const {
|
counters_vec_t GetCounters() const {
|
||||||
@@ -64,7 +65,6 @@ class ExprMetric : public Metric {
|
|||||||
const xml::Expr* expr_;
|
const xml::Expr* expr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MetricsDict {
|
class MetricsDict {
|
||||||
public:
|
public:
|
||||||
typedef std::map<std::string, const Metric*> cache_t;
|
typedef std::map<std::string, const Metric*> cache_t;
|
||||||
@@ -99,6 +99,12 @@ class MetricsDict {
|
|||||||
return ret.first->second;
|
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* Get(const std::string& name) const {
|
||||||
const Metric* metric = NULL;
|
const Metric* metric = NULL;
|
||||||
auto it = cache_.find(name);
|
auto it = cache_.find(name);
|
||||||
@@ -106,6 +112,10 @@ class MetricsDict {
|
|||||||
return metric;
|
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:
|
private:
|
||||||
MetricsDict(const util::AgentInfo* agent_info) : xml_(NULL) {
|
MetricsDict(const util::AgentInfo* agent_info) : xml_(NULL) {
|
||||||
const char* xml_name = getenv("ROCP_METRICS");
|
const char* xml_name = getenv("ROCP_METRICS");
|
||||||
@@ -120,6 +130,7 @@ class MetricsDict {
|
|||||||
|
|
||||||
~MetricsDict() {
|
~MetricsDict() {
|
||||||
xml::Xml::Destroy(xml_);
|
xml::Xml::Destroy(xml_);
|
||||||
|
for (auto& entry : cache_) delete entry.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportMetrics(const util::AgentInfo* agent_info, const char* scope) {
|
void ImportMetrics(const util::AgentInfo* agent_info, const char* scope) {
|
||||||
@@ -163,7 +174,6 @@ class MetricsDict {
|
|||||||
<< "'");
|
<< "'");
|
||||||
} else {
|
} else {
|
||||||
xml::Expr* expr_obj = new xml::Expr(expr_str, new ExprCache(&cache_));
|
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;
|
counters_vec_t counters_vec;
|
||||||
for (const std::string var : expr_obj->GetVars()) {
|
for (const std::string var : expr_obj->GetVars()) {
|
||||||
auto it = cache_.find(var);
|
auto it = cache_.find(var);
|
||||||
@@ -175,18 +185,18 @@ class MetricsDict {
|
|||||||
cache_[name] = new ExprMetric(name, counters_vec, expr_obj);
|
cache_[name] = new ExprMetric(name, counters_vec, expr_obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
void Print() {
|
||||||
for (auto& v : cache_) {
|
for (auto& v : cache_) {
|
||||||
const Metric* metric = v.second;
|
const Metric* metric = v.second;
|
||||||
counters_vec_t counters_vec;
|
counters_vec_t counters_vec;
|
||||||
printf("> Metric '%s'\n", metric->GetName().c_str());
|
printf("> Metric '%s'\n", metric->GetName().c_str());
|
||||||
metric->GetCounters(counters_vec);
|
metric->GetCounters(counters_vec);
|
||||||
for (auto c : 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);
|
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();
|
setup_timer_idx_ = hsa_timer_.CreateTimer();
|
||||||
dispatch_timer_idx_ = hsa_timer_.CreateTimer();
|
dispatch_timer_idx_ = hsa_timer_.CreateTimer();
|
||||||
|
|
||||||
hsa_rsrc_ = HsaInstantiate(agent_id_);
|
if (HsaInstantiate(agent_id_) == NULL) {
|
||||||
if (hsa_rsrc_ == NULL) {
|
|
||||||
TEST_ASSERT(false);
|
TEST_ASSERT(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,8 +120,11 @@ HsaRsrcFactory::HsaRsrcFactory() {
|
|||||||
|
|
||||||
// Get AqlProfile API table
|
// Get AqlProfile API table
|
||||||
aqlprofile_api_ = {0};
|
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_);
|
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);
|
CHECK_STATUS("aqlprofile API table load failed", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user