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
6aec0e08
Commit
6aec0e08
authored
Jan 27, 2013
by
Davis King
Browse files
Added missing asserts
parent
364fd496
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
dlib/threads/parallel_for_extension.h
dlib/threads/parallel_for_extension.h
+72
-0
No files found.
dlib/threads/parallel_for_extension.h
View file @
6aec0e08
...
...
@@ -82,6 +82,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for_blocked()"
<<
"
\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
);
if
(
tp
.
num_threads_in_pool
()
!=
0
)
{
const
long
num
=
end
-
begin
;
...
...
@@ -115,6 +124,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for_blocked()"
<<
"
\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
);
thread_pool
tp
(
num_threads
);
parallel_for_blocked
(
tp
,
begin
,
end
,
obj
,
funct
,
chunks_per_thread
);
}
...
...
@@ -130,6 +148,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for_blocked()"
<<
"
\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
::
helper_parallel_for_funct2
<
T
>
helper
(
funct
);
parallel_for_blocked
(
tp
,
begin
,
end
,
helper
,
&
impl
::
helper_parallel_for_funct2
<
T
>::
run
,
chunks_per_thread
);
}
...
...
@@ -145,6 +172,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for_blocked()"
<<
"
\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
);
thread_pool
tp
(
num_threads
);
parallel_for_blocked
(
tp
,
begin
,
end
,
funct
,
chunks_per_thread
);
}
...
...
@@ -162,6 +198,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for()"
<<
"
\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
::
helper_parallel_for
<
T
>
helper
(
obj
,
funct
);
parallel_for_blocked
(
tp
,
begin
,
end
,
helper
,
&
impl
::
helper_parallel_for
<
T
>::
process_block
,
chunks_per_thread
);
}
...
...
@@ -178,6 +223,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for()"
<<
"
\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
);
thread_pool
tp
(
num_threads
);
parallel_for
(
tp
,
begin
,
end
,
obj
,
funct
,
chunks_per_thread
);
}
...
...
@@ -193,6 +247,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for()"
<<
"
\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
::
helper_parallel_for_funct
<
T
>
helper
(
funct
);
parallel_for
(
tp
,
begin
,
end
,
helper
,
&
impl
::
helper_parallel_for_funct
<
T
>::
run
,
chunks_per_thread
);
}
...
...
@@ -208,6 +271,15 @@ namespace dlib
long
chunks_per_thread
=
4
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
begin
<=
end
&&
chunks_per_thread
>
0
,
"
\t
void parallel_for()"
<<
"
\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
);
thread_pool
tp
(
num_threads
);
parallel_for
(
tp
,
begin
,
end
,
funct
,
chunks_per_thread
);
}
...
...
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