Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
1b555c0e
Commit
1b555c0e
authored
5 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
Use a named value `threadpool_auto_chunk_size` instead of just passing zero to `threadpool_map`.
parent
2b948447
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1018
Threadpool auto chunk size
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/threadpool.c
+3
-5
3 additions, 5 deletions
src/threadpool.c
src/threadpool.h
+1
-0
1 addition, 0 deletions
src/threadpool.h
with
4 additions
and
5 deletions
src/threadpool.c
+
3
−
5
View file @
1b555c0e
...
@@ -252,7 +252,7 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
...
@@ -252,7 +252,7 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
* @param N Number of elements in @c map_data.
* @param N Number of elements in @c map_data.
* @param stride Size, in bytes, of each element of @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 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
* @param extra_data Addtitional pointer that will be passed to the mapping
* function, may contain additional data.
* function, may contain additional data.
*/
*/
...
@@ -278,10 +278,8 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
...
@@ -278,10 +278,8 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
tp
->
map_data_stride
=
stride
;
tp
->
map_data_stride
=
stride
;
tp
->
map_data_size
=
N
;
tp
->
map_data_size
=
N
;
tp
->
map_data_count
=
0
;
tp
->
map_data_count
=
0
;
tp
->
map_data_chunk
=
tp
->
map_data_chunk
=
(
chunk
==
threadpool_auto_chunk_size
)
?
chunk
?
chunk
max
((
int
)(
N
/
(
tp
->
num_threads
*
threadpool_default_chunk_ratio
)),
1
)
:
chunk
;
:
max
((
int
)(
N
/
(
tp
->
num_threads
*
threadpool_default_chunk_ratio
)),
1
);
tp
->
map_function
=
map_function
;
tp
->
map_function
=
map_function
;
tp
->
map_data
=
map_data
;
tp
->
map_data
=
map_data
;
tp
->
map_extra_data
=
extra_data
;
tp
->
map_extra_data
=
extra_data
;
...
...
This diff is collapsed.
Click to expand it.
src/threadpool.h
+
1
−
0
View file @
1b555c0e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
/* Local defines. */
/* Local defines. */
#define threadpool_log_initial_size 1000
#define threadpool_log_initial_size 1000
#define threadpool_default_chunk_ratio 7
#define threadpool_default_chunk_ratio 7
#define threadpool_auto_chunk_size 0
/* Function type for mappings. */
/* Function type for mappings. */
typedef
void
(
*
threadpool_map_function
)(
void
*
map_data
,
int
num_elements
,
typedef
void
(
*
threadpool_map_function
)(
void
*
map_data
,
int
num_elements
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment