Skip to content
GitLab
Menu
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
1b555c0e
Commit
1b555c0e
authored
Feb 11, 2020
by
Pedro Gonnet
Browse files
Use a named value `threadpool_auto_chunk_size` instead of just passing zero to `threadpool_map`.
parent
2b948447
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/threadpool.c
View file @
1b555c0e
...
...
@@ -252,7 +252,7 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
* @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,
* or ze
ro
to choose the number automatically.
* or
#threadpool_auto_chunk_si
ze to choose the number automatically.
* @param extra_data Addtitional pointer that will be passed to the mapping
* function, may contain additional data.
*/
...
...
@@ -278,10 +278,8 @@ 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
?
chunk
:
max
((
int
)(
N
/
(
tp
->
num_threads
*
threadpool_default_chunk_ratio
)),
1
);
tp
->
map_data_chunk
=
(
chunk
==
threadpool_auto_chunk_size
)
?
max
((
int
)(
N
/
(
tp
->
num_threads
*
threadpool_default_chunk_ratio
)),
1
)
:
chunk
;
tp
->
map_function
=
map_function
;
tp
->
map_data
=
map_data
;
tp
->
map_extra_data
=
extra_data
;
...
...
src/threadpool.h
View file @
1b555c0e
...
...
@@ -32,6 +32,7 @@
/* Local defines. */
#define threadpool_log_initial_size 1000
#define threadpool_default_chunk_ratio 7
#define threadpool_auto_chunk_size 0
/* 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
.
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