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
5b361945
Commit
5b361945
authored
Aug 30, 2016
by
Davis King
Browse files
Added overloads of the parallel for functions that use default_thread_pool()
parent
3de7ddf1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
0 deletions
+152
-0
dlib/threads/parallel_for_extension.h
dlib/threads/parallel_for_extension.h
+71
-0
dlib/threads/parallel_for_extension_abstract.h
dlib/threads/parallel_for_extension_abstract.h
+81
-0
No files found.
dlib/threads/parallel_for_extension.h
View file @
5b361945
...
...
@@ -6,6 +6,7 @@
#include "parallel_for_extension_abstract.h"
#include "thread_pool_extension.h"
#include "../console_progress_indicator.h"
#include "async.h"
namespace
dlib
{
...
...
@@ -186,6 +187,17 @@ namespace dlib
parallel_for_blocked
(
tp
,
begin
,
end
,
funct
,
chunks_per_thread
);
}
template
<
typename
T
>
void
parallel_for_blocked
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
)
{
parallel_for_blocked
(
default_thread_pool
(),
begin
,
end
,
funct
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
@@ -285,6 +297,19 @@ namespace dlib
parallel_for
(
tp
,
begin
,
end
,
funct
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
)
{
parallel_for
(
default_thread_pool
(),
begin
,
end
,
funct
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
@@ -499,6 +524,29 @@ namespace dlib
parallel_for
(
num_threads
,
begin
,
end
,
helper
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for_verbose
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for_verbose()"
<<
"
\n\t
Invalid inputs were given to this function"
<<
"
\n\t
begin: "
<<
begin
<<
"
\n\t
end: "
<<
end
<<
"
\n\t
chunks_per_thread: "
<<
chunks_per_thread
);
impl
::
parfor_verbose_helper2
<
T
>
helper
(
funct
,
begin
,
end
);
parallel_for
(
begin
,
end
,
helper
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
...
...
@@ -597,6 +645,29 @@ namespace dlib
parallel_for_blocked
(
num_threads
,
begin
,
end
,
helper
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for_blocked_verbose
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for_blocked_verbose()"
<<
"
\n\t
Invalid inputs were given to this function"
<<
"
\n\t
begin: "
<<
begin
<<
"
\n\t
end: "
<<
end
<<
"
\n\t
chunks_per_thread: "
<<
chunks_per_thread
);
impl
::
parfor_verbose_helper2
<
T
>
helper
(
funct
,
begin
,
end
);
parallel_for_blocked
(
begin
,
end
,
helper
,
chunks_per_thread
);
}
// ----------------------------------------------------------------------------------------
}
...
...
dlib/threads/parallel_for_extension_abstract.h
View file @
5b361945
...
...
@@ -4,6 +4,7 @@
#ifdef DLIB_PARALLEL_FoR_ABSTRACT_Hh_
#include "thread_pool_extension_abstract.h"
#include "async_abstract.h"
namespace
dlib
{
...
...
@@ -123,6 +124,25 @@ namespace dlib
parallel_for_blocked(tp, begin, end, funct, chunks_per_thread);
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for_blocked
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
);
/*!
requires
- begin <= end
- chunks_per_thread > 0
- funct does not throw any exceptions
ensures
- This function is equivalent to the following block of code:
parallel_for_blocked(default_thread_pool(), begin, end, funct, chunks_per_thread);
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
@@ -225,6 +245,25 @@ namespace dlib
parallel_for(tp, begin, end, funct, chunks_per_thread);
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
);
/*!
requires
- begin <= end
- chunks_per_thread > 0
- funct does not throw any exceptions
ensures
- This function is equivalent to the following block of code:
parallel_for(default_thread_pool(), begin, end, funct, chunks_per_thread);
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
@@ -312,6 +351,27 @@ namespace dlib
parallel for loop.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for_verbose
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
);
/*!
requires
- begin <= end
- chunks_per_thread > 0
- funct does not throw any exceptions
ensures
- This function is identical to the parallel_for() routine defined above except
that it will print messages to cout showing the progress in executing the
parallel for loop.
- It will also use the default_thread_pool().
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
@@ -399,6 +459,27 @@ namespace dlib
executing the parallel for loop.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
void
parallel_for_blocked_verbose
(
long
begin
,
long
end
,
const
T
&
funct
,
long
chunks_per_thread
=
8
);
/*!
requires
- begin <= end
- chunks_per_thread > 0
- funct does not throw any exceptions
ensures
- This function is identical to the parallel_for_blocked() routine defined
above except that it will print messages to cout showing the progress in
executing the parallel for loop.
- It will also use the default_thread_pool()
!*/
// ----------------------------------------------------------------------------------------
}
...
...
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