Skip to content

Commit

Permalink
cpu/cuda_thread_pool fix streaming bug
Browse files Browse the repository at this point in the history
This fixes a bug introduced in 7120ecb. There the early termination
criteria was dropped from the loop that scans for completed work. Early
termination is the basis for streaming and without it we were waiting
for all work to complete before returning effictively disabling
streaming.
  • Loading branch information
burlen committed Aug 30, 2023
1 parent 9871f37 commit 812a601
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions core/teca_cpu_thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,12 @@ int teca_cpu_thread_pool<task_t, data_t>::wait_some(long n_to_wait,
}
}

// if we have not accumulated the requested number of datasets
// we have the requested number of datasets
if (data.size() >= static_cast<unsigned int>(n_to_wait))
break;

// wait for the user supplied duration before re-scanning
if (thread_valid && (data.size() < static_cast<unsigned int>(n_to_wait)))
if (thread_valid)
std::this_thread::sleep_for(std::chrono::nanoseconds(poll_interval));
}

Expand Down
9 changes: 6 additions & 3 deletions core/teca_cuda_thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int teca_cuda_thread_pool<task_t, data_t>::wait_some(long n_to_wait,

// gather the requested number of datasets
size_t thread_valid = 1;
while (thread_valid)
while (thread_valid && ((data.size() < static_cast<unsigned int>(n_to_wait))))
{
{
thread_valid = 0;
Expand All @@ -259,9 +259,12 @@ int teca_cuda_thread_pool<task_t, data_t>::wait_some(long n_to_wait,
}
}

// if we have not accumulated the requested number of datasets
// we have the requested number of datasets
if (data.size() >= static_cast<unsigned int>(n_to_wait))
break;

// wait for the user supplied duration before re-scanning
if (thread_valid && (data.size() < static_cast<unsigned int>(n_to_wait)))
if (thread_valid)
std::this_thread::sleep_for(std::chrono::nanoseconds(poll_interval));
}

Expand Down

0 comments on commit 812a601

Please sign in to comment.