Commit 364fd496 authored by Davis King's avatar Davis King

Simplified the code a little by replacing some stuff with calls to

parallel_for_blocked()
parent aeaf6e87
......@@ -216,10 +216,6 @@ namespace dlib
data.num = problem.get_num_samples();
// how many samples to process in a single task (aim for 4 jobs per worker)
const long num_workers = std::max(1UL, tp.num_threads_in_pool());
const long block_size = std::max(1L, data.num/(num_workers*4));
const uint64 start_time = ts.get_timestamp();
// pick fastest buffering strategy
......@@ -233,11 +229,7 @@ namespace dlib
}
binder b(*this, req, data, buffer_subgradients_locally);
for (long i = 0; i < data.num; i+=block_size)
{
tp.add_task(b, &binder::call_oracle, i, std::min(i + block_size, data.num));
}
tp.wait_for_all_tasks();
parallel_for_blocked(tp, 0, data.num, b, &binder::call_oracle);
const uint64 stop_time = ts.get_timestamp();
if (buffer_subgradients_locally)
......
......@@ -116,11 +116,6 @@ namespace dlib
) const
{
++num_iterations_executed;
const long num = this->get_num_samples();
// how many samples to process in a single task (aim for 4 jobs per worker)
const long num_workers = std::max(1UL, tp.num_threads_in_pool());
const long block_size = std::max(1L, num/(num_workers*4));
const uint64 start_time = ts.get_timestamp();
......@@ -133,13 +128,8 @@ namespace dlib
buffer_subgradients_locally = !buffer_subgradients_locally;
}
binder b(*this, w, subgradient, total_loss, buffer_subgradients_locally);
for (long i = 0; i < num; i+=block_size)
{
tp.add_task(b, &binder::call_oracle, i, std::min(i+block_size, num));
}
tp.wait_for_all_tasks();
parallel_for_blocked(tp, 0, this->get_num_samples(), b, &binder::call_oracle);
const uint64 stop_time = ts.get_timestamp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment