Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two bugs in batched-wav-nnet3-cuda binary. #3600

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/cudadecoderbin/batched-wav-nnet3-cuda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ int main(int argc, char *argv[]) {

nvtxRangePush("Global Timer");

int num_groups_done=0;

// starting timer here so we
// can measure throughput
// without allocation
Expand Down Expand Up @@ -271,27 +273,29 @@ int main(int argc, char *argv[]) {
cuda_pipeline.OpenDecodeHandle(key, wave_data, task_group,
finish_one_decode_lamba);
num_task_submitted++;
std::string group_done;
// Non-blocking way to check if a group is done
// returns false if zero groups are ready
if (cuda_pipeline.IsAnyGroupCompleted(&group_done)) {
cuda_pipeline.CloseAllDecodeHandlesForGroup(group_done);
double total_time = timer.Elapsed();
int32 iter = std::atoi(group_done.c_str());
KALDI_LOG << "~Group " << group_done << " completed"
<< " Aggregate Total Time: " << total_time
<< " Audio: " << total_audio * (iter + 1)
<< " RealTimeX: " << total_audio * (iter + 1) / total_time;
}

nvtxRangePop();
if (num_todo != -1 && num_task_submitted >= num_todo) break;
} // end utterance loop

std::string group_done;
// Non-blocking way to check if a group is done
// returns false if zero groups are ready
while (cuda_pipeline.IsAnyGroupCompleted(&group_done)) {
cuda_pipeline.CloseAllDecodeHandlesForGroup(group_done);
double total_time = timer.Elapsed();
int32 iter = std::atoi(group_done.c_str());
KALDI_LOG << "~Group " << group_done << " completed"
<< " Aggregate Total Time: " << total_time
<< " Audio: " << total_audio * (iter + 1)
<< " RealTimeX: " << total_audio * (iter + 1) / total_time;
num_groups_done++;
}
} // end iterations loop

// We've submitted all tasks. Now waiting for them to complete
// We could also have called WaitForAllTasks and CloseAllDecodeHandles
while (cuda_pipeline.GetNumberOfTasksPending()) {
while (num_groups_done<iterations) {
// WaitForAnyGroup is blocking. It will hold until one group is ready
std::string group_done = cuda_pipeline.WaitForAnyGroup();
cuda_pipeline.CloseAllDecodeHandlesForGroup(group_done);
Expand All @@ -301,6 +305,7 @@ int main(int argc, char *argv[]) {
<< " Aggregate Total Time: " << total_time
<< " Audio: " << total_audio * (iter + 1)
<< " RealTimeX: " << total_audio * (iter + 1) / total_time;
num_groups_done++;
}

// number of seconds elapsed since the creation of timer
Expand Down