Skip to content

Commit

Permalink
minor change (Xilinx#2175)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarab96 authored and maxzhen committed Sep 30, 2019
1 parent 3cf446b commit 53ed82c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/xma/include/lib/xmahw_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,24 @@ typedef struct XmaHwDevice
std::vector<XmaHwExecBO> kernel_execbos;
int32_t num_execbo_allocated;

uint32_t cu_cmd_id;//Counter
uint32_t cu_cmd_id1;//Counter
uint32_t cu_cmd_id2;//Counter
std::mt19937 mt_gen;
std::uniform_int_distribution<int32_t> rnd_dis;

uint32_t reserved[16];

// XmaHwDevice(): execbo_locked(new std::atomic<bool>), mt_gen(std::mt19937(std::seed_seq(static_cast<long unsigned int>(time(0)), std::random_device()))), rnd_dis(-97986387, 97986387) {
XmaHwDevice(): execbo_locked(new std::atomic<bool>), rnd_dis(-97986387, 97986387) {
XmaHwDevice(): execbo_locked(std::make_unique<std::atomic<bool>>()), rnd_dis(-97986387, 97986387) {
//in_use = false;
dev_index = -1;
number_of_cus = 0;
*execbo_locked = false;
number_of_mem_banks = 0;
num_execbo_allocated = -1;
handle = NULL;
cu_cmd_id = 0;
cu_cmd_id1 = 0;
cu_cmd_id2 = 0;
//mt = std::mt19937(std::random_device{}());
std::random_device rd;
uint32_t tmp_int = time(0);
Expand Down
22 changes: 14 additions & 8 deletions src/xma/src/xmaplugin/xmaplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,22 +648,25 @@ XmaCUCmdObj xma_plg_schedule_work_item(XmaSession s_handle,

bool found = false;
while(!found) {
dev_tmp1->cu_cmd_id++;
uint32_t tmp_int1 = dev_tmp1->cu_cmd_id;
dev_tmp1->cu_cmd_id1++;
uint32_t tmp_int1 = dev_tmp1->cu_cmd_id1;
if (tmp_int1 == 0) {
tmp_int1 = 1;
dev_tmp1->cu_cmd_id = tmp_int1;
dev_tmp1->cu_cmd_id1 = tmp_int1;
//Change seed of random_generator
std::random_device rd;
uint32_t tmp_int = time(0);
std::seed_seq seed_seq{rd(), tmp_int};
dev_tmp1->mt_gen = std::mt19937(seed_seq);
dev_tmp1->cu_cmd_id2 = dev_tmp1->rnd_dis(dev_tmp1->mt_gen);
} else {
dev_tmp1->cu_cmd_id2++;
}
auto itr_tmp1 = priv1->CU_cmds.emplace(tmp_int1, XmaCUCmdObjPrivate{});
if (itr_tmp1.second) {//It is newly inserted item;
found = true;
cmd_obj.cmd_id1 = tmp_int1;
cmd_obj.cmd_id2 = dev_tmp1->rnd_dis(dev_tmp1->mt_gen);
cmd_obj.cmd_id2 = dev_tmp1->cu_cmd_id2;
itr_tmp1.first->second.cmd_id2 = cmd_obj.cmd_id2;
itr_tmp1.first->second.cu_id = cmd_obj.cu_index;
itr_tmp1.first->second.execbo_id = bo_idx;
Expand Down Expand Up @@ -829,22 +832,25 @@ XmaCUCmdObj xma_plg_schedule_cu_cmd(XmaSession s_handle,

bool found = false;
while(!found) {
dev_tmp1->cu_cmd_id++;
uint32_t tmp_int1 = dev_tmp1->cu_cmd_id;
dev_tmp1->cu_cmd_id1++;
uint32_t tmp_int1 = dev_tmp1->cu_cmd_id1;
if (tmp_int1 == 0) {
tmp_int1 = 1;
dev_tmp1->cu_cmd_id = tmp_int1;
dev_tmp1->cu_cmd_id1 = tmp_int1;
//Change seed of random_generator
std::random_device rd;
uint32_t tmp_int = time(0);
std::seed_seq seed_seq{rd(), tmp_int};
dev_tmp1->mt_gen = std::mt19937(seed_seq);
dev_tmp1->cu_cmd_id2 = dev_tmp1->rnd_dis(dev_tmp1->mt_gen);
} else {
dev_tmp1->cu_cmd_id2++;
}
auto itr_tmp1 = priv1->CU_cmds.emplace(tmp_int1, XmaCUCmdObjPrivate{});
if (itr_tmp1.second) {//It is newly inserted item;
found = true;
cmd_obj.cmd_id1 = tmp_int1;
cmd_obj.cmd_id2 = dev_tmp1->rnd_dis(dev_tmp1->mt_gen);
cmd_obj.cmd_id2 = dev_tmp1->cu_cmd_id2;
itr_tmp1.first->second.cmd_id2 = cmd_obj.cmd_id2;
itr_tmp1.first->second.cu_id = cmd_obj.cu_index;
itr_tmp1.first->second.execbo_id = bo_idx;
Expand Down

0 comments on commit 53ed82c

Please sign in to comment.