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
b1aa697a
Commit
b1aa697a
authored
7 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
make the logging work even if we're using a single thread.
parent
03735423
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!375
Threadpool task plots
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/threadpool.c
+19
-13
19 additions, 13 deletions
src/threadpool.c
with
19 additions
and
13 deletions
src/threadpool.c
+
19
−
13
View file @
b1aa697a
...
...
@@ -195,6 +195,19 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
tp
->
num_threads
=
num_threads
;
tp
->
num_threads_waiting
=
0
;
#ifdef SWIFT_DEBUG_THREADPOOL
if
((
tp
->
logs
=
(
struct
mapper_log
*
)
malloc
(
sizeof
(
struct
mapper_log
)
*
num_threads
))
==
NULL
)
error
(
"Failed to allocate mapper logs."
);
for
(
int
k
=
0
;
k
<
num_threads
;
k
++
)
{
tp
->
logs
[
k
].
size
=
threadpool_log_initial_size
;
tp
->
logs
[
k
].
count
=
0
;
if
((
tp
->
logs
[
k
].
log
=
(
struct
mapper_log_entry
*
)
malloc
(
sizeof
(
struct
mapper_log_entry
)
*
tp
->
logs
[
k
].
size
))
==
NULL
)
error
(
"Failed to allocate mapper log."
);
}
#endif
/* If there is only a single thread, do nothing more as of here as
we will just do work in the (blocked) calling thread. */
if
(
num_threads
==
1
)
return
;
...
...
@@ -213,19 +226,6 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
tp
->
map_data_chunk
=
0
;
tp
->
map_function
=
NULL
;
#ifdef SWIFT_DEBUG_THREADPOOL
if
((
tp
->
logs
=
(
struct
mapper_log
*
)
malloc
(
sizeof
(
struct
mapper_log
)
*
num_threads
))
==
NULL
)
error
(
"Failed to allocate mapper logs."
);
for
(
int
k
=
0
;
k
<
num_threads
;
k
++
)
{
tp
->
logs
[
k
].
size
=
threadpool_log_initial_size
;
tp
->
logs
[
k
].
count
=
0
;
if
((
tp
->
logs
[
k
].
log
=
(
struct
mapper_log_entry
*
)
malloc
(
sizeof
(
struct
mapper_log_entry
)
*
tp
->
logs
[
k
].
size
))
==
NULL
)
error
(
"Failed to allocate mapper log."
);
}
#endif
/* Allocate the threads. */
if
((
tp
->
threads
=
(
pthread_t
*
)
malloc
(
sizeof
(
pthread_t
)
*
num_threads
))
==
NULL
)
{
...
...
@@ -268,7 +268,13 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
/* If we just have a single thread, call the map function directly. */
if
(
tp
->
num_threads
==
1
)
{
#ifdef SWIFT_DEBUG_THREADPOOL
ticks
tic
=
getticks
();
#endif
map_function
(
map_data
,
N
,
extra_data
);
#ifdef SWIFT_DEBUG_THREADPOOL
threadpool_log
(
tp
,
0
,
N
,
tic
,
getticks
());
#endif
return
;
}
...
...
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