Skip to content

Commit

Permalink
flush queue on wait()
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaily authored and scchan committed Aug 2, 2019
1 parent d7bc256 commit a9eec7b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/hsa/mcwamp_hsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ int HCC_MAX_QUEUES = 20;
#define HCC_PROFILE_SUMMARY (1<<0)
#define HCC_PROFILE_TRACE (1<<1)
int HCC_PROFILE=0;
int HCC_FLUSH_ON_WAIT=1;


#define HCC_PROFILE_VERBOSE_BASIC (1 << 0) // 0x1
Expand Down Expand Up @@ -1625,6 +1626,16 @@ class HSAQueue final : public KalmarQueue
DBOUT(DB_CMD2, "No future found in wait, enqueued marker into " << *this << "\n");
}
back()->getFuture()->wait();
if (HCC_FLUSH_ON_WAIT) {
// aggressively cleanup resources
// but keep back() as a valid HSAOp, so decrement current insert index twice
int back_op_index = decrement(asyncOpsIndex); // index of back() op
int index = decrement(back_op_index); // index of first op to free
while (asyncOps[index] != nullptr && index != back_op_index) {
asyncOps[index] = nullptr;
index = decrement(index);
}
}
}

void LaunchKernel(void *ker, size_t nr_dim, size_t *global, size_t *local) override {
Expand Down Expand Up @@ -3770,6 +3781,7 @@ void HSAContext::ReadHccEnv()
GET_ENV_INT (HCC_PROFILE, "Enable HCC kernel and data profiling. 1=summary, 2=trace");
GET_ENV_INT (HCC_PROFILE_VERBOSE, "Bitmark to control profile verbosity and format. 0x1=default, 0x2=show begin/end, 0x4=show barrier");
GET_ENV_STRING (HCC_PROFILE_FILE, "Set file name for HCC_PROFILE mode. Default=stderr");
GET_ENV_INT (HCC_FLUSH_ON_WAIT, "recover all resources on queue wait");

};

Expand Down

0 comments on commit a9eec7b

Please sign in to comment.