Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
5b361945
Commit
5b361945
authored
Aug 30, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added overloads of the parallel for functions that use default_thread_pool()
parent
3de7ddf1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
0 deletions
+152
-0
parallel_for_extension.h
dlib/threads/parallel_for_extension.h
+71
-0
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