rpl_run w/o input file; queue create callback; test for n gpus and n threads
Change-Id: I37157c49cf6454de591cae97b5cc43287ea95956
This commit is contained in:
@@ -145,8 +145,7 @@ int main() {
|
||||
TEST_STATUS(status == HSA_STATUS_SUCCESS);
|
||||
|
||||
// Test initialization
|
||||
TestHsa::SetQueue(prof_queue);
|
||||
TestHsa::HsaInstantiate(0);
|
||||
TestHsa::HsaInstantiate();
|
||||
|
||||
// Dispatching profiled kernel n-times to collect all counter groups data
|
||||
const unsigned group_n = 0;
|
||||
@@ -157,9 +156,9 @@ int main() {
|
||||
for (unsigned ind = 0; ind < 3; ++ind) {
|
||||
#if 1
|
||||
const unsigned queue_ind = ind % queue_count;
|
||||
TestHsa::SetQueue(queue[queue_ind]);
|
||||
// ret_val = RunKernel<DummyKernel, TestAql>();
|
||||
ret_val = RunKernel<SimpleConvolution, TestAql>();
|
||||
hsa_queue_t* prof_queue = queue[queue_ind];
|
||||
//ret_val = RunKernel<DummyKernel, TestAql>(0, NULL, NULL, prof_queue);
|
||||
ret_val = RunKernel<SimpleConvolution, TestAql>(0, NULL, NULL, prof_queue);
|
||||
std::cout << "run kernel, queue " << queue_ind << std::endl;
|
||||
#else
|
||||
sleep(3);
|
||||
|
||||
+47
-1
@@ -21,20 +21,66 @@ THE SOFTWARE.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <hsa.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "ctrl/run_kernel.h"
|
||||
#include "ctrl/test_aql.h"
|
||||
#include "dummy_kernel/dummy_kernel.h"
|
||||
#include "simple_convolution/simple_convolution.h"
|
||||
|
||||
void thread_fun(const int kiter, const int diter, const uint32_t agents_number) {
|
||||
const AgentInfo* agent_info[agents_number];
|
||||
hsa_queue_t* queue[agents_number];
|
||||
HsaRsrcFactory* rsrc = &HsaRsrcFactory::Instance();
|
||||
|
||||
for (uint32_t n = 0; n < agents_number; ++n) {
|
||||
uint32_t agent_id = n % rsrc->GetCountOfGpuAgents();
|
||||
if (rsrc->GetGpuAgentInfo(agent_id, &agent_info[n]) == false) {
|
||||
fprintf(stderr, "AgentInfo failed\n");
|
||||
abort();
|
||||
}
|
||||
if (rsrc->CreateQueue(agent_info[n], 128, &queue[n]) == false) {
|
||||
fprintf(stderr, "CreateQueue failed\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < kiter; ++i) {
|
||||
for (uint32_t n = 0; n < agents_number; ++n) {
|
||||
// RunKernel<DummyKernel, TestAql>(0, NULL, agent_info[n], queue[n], diter);
|
||||
RunKernel<SimpleConvolution, TestAql>(0, NULL, agent_info[n], queue[n], diter);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t n = 0; n < agents_number; ++n) {
|
||||
hsa_queue_destroy(queue[n]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
const char* kiter_s = getenv("ROCP_KITER");
|
||||
const char* diter_s = getenv("ROCP_DITER");
|
||||
const char* agents_s = getenv("ROCP_AGENTS");
|
||||
const char* thrs_s = getenv("ROCP_THRS");
|
||||
|
||||
const int kiter = (kiter_s != NULL) ? atol(kiter_s) : 1;
|
||||
const int diter = (diter_s != NULL) ? atol(diter_s) : 1;
|
||||
const uint32_t agents_number = (agents_s != NULL) ? (uint32_t)atol(agents_s) : 1;
|
||||
const int thrs = (thrs_s != NULL) ? atol(thrs_s) : 1;
|
||||
|
||||
TestHsa::HsaInstantiate();
|
||||
for (int i = 0; i < kiter; ++i) RunKernel<SimpleConvolution, TestAql>(argc, argv, diter);
|
||||
|
||||
std::thread t[thrs];
|
||||
for (int n = 0; n < thrs; ++n) {
|
||||
t[n] = std::thread(thread_fun, kiter, diter, agents_number);
|
||||
}
|
||||
for (int n = 0; n < thrs; ++n) {
|
||||
t[n].join();
|
||||
}
|
||||
|
||||
TestHsa::HsaShutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user