Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
364fd496
Commit
364fd496
authored
Jan 27, 2013
by
Davis King
Browse files
Simplified the code a little by replacing some stuff with calls to
parallel_for_blocked()
parent
aeaf6e87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
20 deletions
+2
-20
dlib/svm/structural_svm_distributed.h
dlib/svm/structural_svm_distributed.h
+1
-9
dlib/svm/structural_svm_problem_threaded.h
dlib/svm/structural_svm_problem_threaded.h
+1
-11
No files found.
dlib/svm/structural_svm_distributed.h
View file @
364fd496
...
@@ -216,10 +216,6 @@ namespace dlib
...
@@ -216,10 +216,6 @@ namespace dlib
data
.
num
=
problem
.
get_num_samples
();
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
();
const
uint64
start_time
=
ts
.
get_timestamp
();
// pick fastest buffering strategy
// pick fastest buffering strategy
...
@@ -233,11 +229,7 @@ namespace dlib
...
@@ -233,11 +229,7 @@ namespace dlib
}
}
binder
b
(
*
this
,
req
,
data
,
buffer_subgradients_locally
);
binder
b
(
*
this
,
req
,
data
,
buffer_subgradients_locally
);
for
(
long
i
=
0
;
i
<
data
.
num
;
i
+=
block_size
)
parallel_for_blocked
(
tp
,
0
,
data
.
num
,
b
,
&
binder
::
call_oracle
);
{
tp
.
add_task
(
b
,
&
binder
::
call_oracle
,
i
,
std
::
min
(
i
+
block_size
,
data
.
num
));
}
tp
.
wait_for_all_tasks
();
const
uint64
stop_time
=
ts
.
get_timestamp
();
const
uint64
stop_time
=
ts
.
get_timestamp
();
if
(
buffer_subgradients_locally
)
if
(
buffer_subgradients_locally
)
...
...
dlib/svm/structural_svm_problem_threaded.h
View file @
364fd496
...
@@ -116,11 +116,6 @@ namespace dlib
...
@@ -116,11 +116,6 @@ namespace dlib
)
const
)
const
{
{
++
num_iterations_executed
;
++
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
();
const
uint64
start_time
=
ts
.
get_timestamp
();
...
@@ -133,13 +128,8 @@ namespace dlib
...
@@ -133,13 +128,8 @@ namespace dlib
buffer_subgradients_locally
=
!
buffer_subgradients_locally
;
buffer_subgradients_locally
=
!
buffer_subgradients_locally
;
}
}
binder
b
(
*
this
,
w
,
subgradient
,
total_loss
,
buffer_subgradients_locally
);
binder
b
(
*
this
,
w
,
subgradient
,
total_loss
,
buffer_subgradients_locally
);
for
(
long
i
=
0
;
i
<
num
;
i
+=
block_size
)
parallel_for_blocked
(
tp
,
0
,
this
->
get_num_samples
(),
b
,
&
binder
::
call_oracle
);
{
tp
.
add_task
(
b
,
&
binder
::
call_oracle
,
i
,
std
::
min
(
i
+
block_size
,
num
));
}
tp
.
wait_for_all_tasks
();
const
uint64
stop_time
=
ts
.
get_timestamp
();
const
uint64
stop_time
=
ts
.
get_timestamp
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment