rpl_run w/o input file; queue create callback; test for n gpus and n threads

Change-Id: I37157c49cf6454de591cae97b5cc43287ea95956
This commit is contained in:
Evgeny
2018-10-30 14:19:45 -05:00
parent c05bded17c
commit f977ac2fbf
12 changed files with 137 additions and 73 deletions
+7 -3
View File
@@ -26,7 +26,7 @@ THE SOFTWARE.
#include "ctrl/test_hsa.h"
#include "util/test_assert.h"
template <class Kernel, class Test> bool RunKernel(int argc = 0, char* argv[] = NULL, int count = 1) {
template <class Kernel, class Test> bool RunKernel(int argc = 0, char* argv[] = NULL, const AgentInfo* agent_info = NULL, hsa_queue_t* queue = NULL, int count = 1) {
bool ret_val = false;
if (getenv("ROC_TEST_TRACE") == NULL) std::clog.rdbuf(NULL);
@@ -34,8 +34,12 @@ template <class Kernel, class Test> bool RunKernel(int argc = 0, char* argv[] =
// Create test kernel object
Kernel test_kernel;
TestAql* test_aql = new TestHsa(&test_kernel);
test_aql = new Test(test_aql);
TestHsa* test_hsa = new TestHsa(&test_kernel);
test_hsa->SetAgentInfo(agent_info);
test_hsa->SetQueue(queue);
TestAql* test_aql = new Test(test_hsa);
TEST_ASSERT(test_aql != NULL);
if (test_aql == NULL) return 1;
+25 -30
View File
@@ -29,60 +29,54 @@ THE SOFTWARE.
#include "util/hsa_rsrc_factory.h"
HsaRsrcFactory* TestHsa::hsa_rsrc_ = NULL;
const AgentInfo* TestHsa::agent_info_ = NULL;
hsa_queue_t* TestHsa::hsa_queue_ = NULL;
uint32_t TestHsa::agent_id_ = 0;
HsaRsrcFactory* TestHsa::HsaInstantiate(const uint32_t agent_ind) {
HsaRsrcFactory* TestHsa::HsaInstantiate() {
// Instantiate an instance of Hsa Resources Factory
if (hsa_rsrc_ == NULL) {
agent_id_ = agent_ind;
hsa_rsrc_ = HsaRsrcFactory::Create();
// Print properties of the agents
hsa_rsrc_->PrintGpuAgents("> GPU agents");
// Create an instance of Gpu agent
if (!hsa_rsrc_->GetGpuAgentInfo(agent_ind, &agent_info_)) {
agent_info_ = NULL;
std::cerr << "> error: agent[" << agent_ind << "] is not found" << std::endl;
return NULL;
}
std::clog << "> Using agent[" << agent_ind << "] : " << agent_info_->name << std::endl;
}
return hsa_rsrc_;
}
void TestHsa::HsaShutdown() {
if (hsa_queue_ != NULL) {
hsa_queue_destroy(hsa_queue_);
hsa_queue_ = NULL;
}
if (hsa_rsrc_) hsa_rsrc_->Destroy();
}
bool TestHsa::Initialize(int /*arg_cnt*/, char** /*arg_list*/) {
std::clog << "TestHsa::Initialize :" << std::endl;
// Create an instance of Aql Queue
if (hsa_queue_ == NULL) {
uint32_t num_pkts = 128;
if (hsa_rsrc_->CreateQueue(agent_info_, num_pkts, &hsa_queue_) == false) {
hsa_queue_ = NULL;
TEST_ASSERT(false);
}
}
// Instantiate a Timer object
setup_timer_idx_ = hsa_timer_.CreateTimer();
dispatch_timer_idx_ = hsa_timer_.CreateTimer();
if (HsaInstantiate(agent_id_) == NULL) {
if (hsa_rsrc_ == NULL) {
TEST_ASSERT(false);
return false;
}
// Create an instance of Gpu agent
if (agent_info_ == NULL) {
const uint32_t agent_id = 0;
if (!hsa_rsrc_->GetGpuAgentInfo(agent_id, &agent_info_)) {
agent_info_ = NULL;
std::cerr << "> error: agent[" << agent_id << "] is not found" << std::endl;
return NULL;
}
}
std::clog << "> Using agent[" << agent_info_->dev_index << "] : " << agent_info_->name << std::endl;
// Create an instance of Aql Queue
if (hsa_queue_ == NULL) {
const uint32_t num_pkts = 128;
if (hsa_rsrc_->CreateQueue(agent_info_, num_pkts, &hsa_queue_) == false) {
hsa_queue_ = NULL;
TEST_ASSERT(false);
}
my_queue_ = true;
}
// Obtain handle of signal
hsa_rsrc_->CreateSignal(1, &hsa_signal_);
@@ -283,7 +277,8 @@ void TestHsa::PrintTime() {
bool TestHsa::Cleanup() {
hsa_executable_destroy(hsa_exec_);
hsa_signal_destroy(hsa_signal_);
hsa_queue_destroy(hsa_queue_);
if (my_queue_) hsa_queue_destroy(hsa_queue_);
hsa_queue_ = NULL;
agent_info_ = NULL;
return true;
}
+12 -11
View File
@@ -32,24 +32,27 @@ THE SOFTWARE.
class TestHsa : public TestAql {
public:
// Instantiate HSA resources
static HsaRsrcFactory* HsaInstantiate(const uint32_t agent_ind = agent_id_);
static HsaRsrcFactory* HsaInstantiate();
static void HsaShutdown();
static void SetQueue(hsa_queue_t* queue) { hsa_queue_ = queue; }
static hsa_agent_t HsaAgent() { return agent_info_->dev_id; }
static uint32_t HsaAgentId() { return agent_id_; }
// Constructor
explicit TestHsa(TestKernel* test) : test_(test), name_(test->Name()) {
total_time_taken_ = 0;
setup_time_taken_ = 0;
dispatch_time_taken_ = 0;
agent_info_ = NULL;
hsa_queue_ = NULL;
my_queue_ = false;
hsa_exec_ = {};
}
// Get methods for Agent Info, HAS queue, HSA Resourcse Manager
const AgentInfo* GetAgentInfo() { return agent_info_; }
hsa_queue_t* GetQueue() { return hsa_queue_; }
HsaRsrcFactory* GetRsrcFactory() { return hsa_rsrc_; }
hsa_agent_t HsaAgent() { return agent_info_->dev_id; }
const AgentInfo* GetAgentInfo() { return agent_info_; }
void SetAgentInfo(const AgentInfo* agent_info) { agent_info_ = agent_info; }
hsa_queue_t* GetQueue() { return hsa_queue_; }
void SetQueue(hsa_queue_t* queue) { hsa_queue_ = queue; }
// Initialize application environment including setting
// up of various configuration parameters based on
@@ -106,14 +109,12 @@ class TestHsa : public TestAql {
// Instance of Hsa Resources Factory
static HsaRsrcFactory* hsa_rsrc_;
// GPU id
static uint32_t agent_id_;
// Handle to an Hsa Gpu Agent
static const AgentInfo* agent_info_;
const AgentInfo* agent_info_;
// Handle to an Hsa Queue
static hsa_queue_t* hsa_queue_;
hsa_queue_t* hsa_queue_;
bool my_queue_;
// Test kernel name
std::string name_;