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
169f8aa6
Commit
169f8aa6
authored
Aug 20, 2016
by
Matthieu Schaller
Browse files
Code formatting, threadpool documentation, threadpool memory cleaning.
parent
282e9e36
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
169f8aa6
...
...
@@ -3349,4 +3349,5 @@ void engine_clean(struct engine *e) {
free
(
e
->
links
);
scheduler_clean
(
&
e
->
sched
);
space_clean
(
e
->
s
);
threadpool_clean
(
&
e
->
threadpool
);
}
src/hydro/Gadget2/hydro_iact.h
View file @
169f8aa6
...
...
@@ -432,7 +432,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Are the particles moving towards each others ? */
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Signal velocity */
...
...
@@ -707,7 +707,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
const
float
balsara_j
=
pj
->
force
.
balsara
;
/* Are the particles moving towards each others ? */
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
omega_ij
=
(
dvdr
<
0
.
f
)
?
dvdr
:
0
.
f
;
const
float
mu_ij
=
fac_mu
*
r_inv
*
omega_ij
;
/* This is 0 or negative */
/* Signal velocity */
...
...
src/runner.c
View file @
169f8aa6
...
...
@@ -487,8 +487,8 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
h_corr
=
(
target_wcount
-
p
->
density
.
wcount
)
/
p
->
density
.
wcount_dh
;
/* Truncate to the range [ -p->h/2 , p->h ]. */
h_corr
=
(
h_corr
<
p
->
h
)
?
h_corr
:
p
->
h
;
h_corr
=
(
h_corr
>
-
0
.
5
f
*
p
->
h
)
?
h_corr
:
-
0
.
5
f
*
p
->
h
;
h_corr
=
(
h_corr
<
p
->
h
)
?
h_corr
:
p
->
h
;
h_corr
=
(
h_corr
>
-
0
.
5
f
*
p
->
h
)
?
h_corr
:
-
0
.
5
f
*
p
->
h
;
}
/* Did we get the right number density? */
...
...
@@ -622,7 +622,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
const
float
dx2
=
gp
->
x_diff
[
0
]
*
gp
->
x_diff
[
0
]
+
gp
->
x_diff
[
1
]
*
gp
->
x_diff
[
1
]
+
gp
->
x_diff
[
2
]
*
gp
->
x_diff
[
2
];
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
}
/* Loop over all the particles in the cell (more work for these !) */
...
...
@@ -640,7 +640,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
const
float
dx2
=
xp
->
x_diff
[
0
]
*
xp
->
x_diff
[
0
]
+
xp
->
x_diff
[
1
]
*
xp
->
x_diff
[
1
]
+
xp
->
x_diff
[
2
]
*
xp
->
x_diff
[
2
];
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
dx2_max
=
(
dx2_max
>
dx2
)
?
dx2_max
:
dx2
;
/* Maximal smoothing length */
h_max
=
(
h_max
>
p
->
h
)
?
h_max
:
p
->
h
;
...
...
src/serial_io.c
View file @
169f8aa6
...
...
@@ -225,11 +225,11 @@ void prepareArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
}
/* Impose data compression */
if
(
e
->
snapshotCompression
>
0
)
{
if
(
e
->
snapshotCompression
>
0
)
{
h_err
=
H5Pset_deflate
(
h_prop
,
e
->
snapshotCompression
);
if
(
h_err
<
0
)
{
error
(
"Error while setting compression options for field '%s'."
,
props
.
name
);
props
.
name
);
}
}
...
...
src/threadpool.c
View file @
169f8aa6
...
...
@@ -71,6 +71,12 @@ void *threadpool_runner(void *data) {
}
}
/**
* @brief Initialises the #threadpool with a given number of threads.
*
* @param tp The #threadpool.
* @param num_threads The number of threads.
*/
void
threadpool_init
(
struct
threadpool
*
tp
,
int
num_threads
)
{
/* Initialize the thread counters. */
...
...
@@ -126,7 +132,6 @@ void threadpool_init(struct threadpool *tp, int num_threads) {
* @param extra_data Addtitional pointer that will be passed to the mapping
* function, may contain additional data.
*/
void
threadpool_map
(
struct
threadpool
*
tp
,
threadpool_map_function
map_function
,
void
*
map_data
,
size_t
N
,
int
stride
,
int
chunk
,
void
*
extra_data
)
{
...
...
@@ -154,3 +159,8 @@ void threadpool_map(struct threadpool *tp, threadpool_map_function map_function,
}
pthread_mutex_unlock
(
&
tp
->
thread_mutex
);
}
/**
* @brief Frees up the memory allocated for this #threadpool.
*/
void
threadpool_clean
(
struct
threadpool
*
tp
)
{
free
(
tp
->
threads
);
}
src/threadpool.h
View file @
169f8aa6
...
...
@@ -57,5 +57,6 @@ void threadpool_init(struct threadpool *tp, int num_threads);
void
threadpool_map
(
struct
threadpool
*
tp
,
threadpool_map_function
map_function
,
void
*
map_data
,
size_t
N
,
int
stride
,
int
chunk
,
void
*
extra_data
);
void
threadpool_clean
(
struct
threadpool
*
tp
);
#endif
/* SWIFT_THREADPOOL_H */
src/timestep.h
View file @
169f8aa6
...
...
@@ -74,7 +74,8 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep(
/* gravity_compute_timestep_self(e->physical_constants, gp); */
const
float
new_dt_self
=
FLT_MAX
;
// MATTHIEU
float
new_dt
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
float
new_dt
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
/* Limit timestep within the allowed range */
new_dt
=
(
new_dt
<
e
->
dt_max
)
?
new_dt
:
e
->
dt_max
;
...
...
@@ -111,11 +112,12 @@ __attribute__((always_inline)) INLINE static int get_part_timestep(
/* gravity_compute_timestep_self(e->physical_constants, p->gpart); */
const
float
new_dt_self
=
FLT_MAX
;
// MATTHIEU
new_dt_grav
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
new_dt_grav
=
(
new_dt_external
<
new_dt_self
)
?
new_dt_external
:
new_dt_self
;
}
/* Final time-step is minimum of hydro and gravity */
float
new_dt
=
(
new_dt_hydro
<
new_dt_grav
)
?
new_dt_hydro
:
new_dt_grav
;
float
new_dt
=
(
new_dt_hydro
<
new_dt_grav
)
?
new_dt_hydro
:
new_dt_grav
;
/* Limit change in h */
const
float
dt_h_change
=
...
...
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