Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
9a634a15
Commit
9a634a15
authored
Jul 26, 2017
by
Pedro Gonnet
Browse files
if chunk is zero, split the input into num_thread * threadpool_default_chunk_ratio chunks.
parent
3bcec4cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/threadpool.c
View file @
9a634a15
...
...
@@ -36,6 +36,7 @@
/* Local headers. */
#include
"atomic.h"
#include
"error.h"
#include
"minmax.h"
#ifdef SWIFT_DEBUG_THREADPOOL
/**
...
...
@@ -250,7 +251,8 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
* @param map_data The data on which the mapping function will be called.
* @param N Number of elements in @c map_data.
* @param stride Size, in bytes, of each element of @c map_data.
* @param chunk Number of map data elements to pass to the function at a time.
* @param chunk Number of map data elements to pass to the function at a time,
* or zero to choose the number automatically.
* @param extra_data Addtitional pointer that will be passed to the mapping
* function, may contain additional data.
*/
...
...
@@ -269,7 +271,10 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
tp
->
map_data_stride
=
stride
;
tp
->
map_data_size
=
N
;
tp
->
map_data_count
=
0
;
tp
->
map_data_chunk
=
chunk
;
tp
->
map_data_chunk
=
chunk
?
chunk
:
max
((
int
)(
N
/
(
tp
->
num_threads
*
threadpool_default_chunk_ratio
)),
1
);
tp
->
map_function
=
map_function
;
tp
->
map_data
=
map_data
;
tp
->
map_extra_data
=
extra_data
;
...
...
src/threadpool.h
View file @
9a634a15
...
...
@@ -30,6 +30,7 @@
/* Local defines. */
#define threadpool_log_initial_size 1000
#define threadpool_default_chunk_ratio 5
/* Function type for mappings. */
typedef
void
(
*
threadpool_map_function
)(
void
*
map_data
,
int
num_elements
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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