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
0f6b13c7
Commit
0f6b13c7
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Use the threaded version of FFTW to speed-up the PM part of the code.
parent
daa00858
No related branches found
No related tags found
1 merge request
!608
Use the threaded version of FFTW to speed-up the PM part of the code.
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
configure.ac
+3
-3
3 additions, 3 deletions
configure.ac
examples/main.c
+1
-1
1 addition, 1 deletion
examples/main.c
src/mesh_gravity.c
+17
-1
17 additions, 1 deletion
src/mesh_gravity.c
src/mesh_gravity.h
+4
-1
4 additions, 1 deletion
src/mesh_gravity.h
with
25 additions
and
6 deletions
configure.ac
+
3
−
3
View file @
0f6b13c7
...
...
@@ -588,7 +588,7 @@ AH_VERBATIM([__STDC_FORMAT_MACROS],
# Check for FFTW. We test for this in the standard directories by default,
# and only disable if using --with-fftw=no or --without-fftw. When a value
# is given
GSL
must be found.
# is given
FFTW
must be found.
have_fftw="no"
AC_ARG_WITH([fftw],
[AS_HELP_STRING([--with-fftw=PATH],
...
...
@@ -599,10 +599,10 @@ AC_ARG_WITH([fftw],
)
if test "x$with_fftw" != "xno"; then
if test "x$with_fftw" != "xyes" -a "x$with_fftw" != "xtest" -a "x$with_fftw" != "x"; then
FFTW_LIBS="-L$with_fftw/lib -lfftw3"
FFTW_LIBS="-L$with_fftw/lib
-lfftw3_threads
-lfftw3"
FFTW_INCS="-I$with_fftw/include"
else
FFTW_LIBS="-lfftw3"
FFTW_LIBS="
-lfftw3_threads
-lfftw3"
FFTW_INCS=""
fi
# FFTW is not specified, so just check if we have it.
...
...
This diff is collapsed.
Click to expand it.
examples/main.c
+
1
−
1
View file @
0f6b13c7
...
...
@@ -801,7 +801,7 @@ int main(int argc, char *argv[]) {
/* Initialise the long-range gravity mesh */
if
(
with_self_gravity
&&
periodic
)
{
#ifdef HAVE_FFTW
pm_mesh_init
(
&
mesh
,
&
gravity_properties
,
s
.
dim
);
pm_mesh_init
(
&
mesh
,
&
gravity_properties
,
s
.
dim
,
nr_threads
);
#else
/* Need the FFTW library if periodic and self gravity. */
error
(
...
...
This diff is collapsed.
Click to expand it.
src/mesh_gravity.c
+
17
−
1
View file @
0f6b13c7
...
...
@@ -596,9 +596,10 @@ void pm_mesh_interpolate_forces(const struct pm_mesh* mesh,
* @param mesh The #pm_mesh to initialise.
* @param props The propoerties of the gravity scheme.
* @param dim The (comoving) side-lengths of the simulation volume.
* @param nr_threads The number of threads on this MPI rank.
*/
void
pm_mesh_init
(
struct
pm_mesh
*
mesh
,
const
struct
gravity_props
*
props
,
double
dim
[
3
])
{
double
dim
[
3
]
,
int
nr_threads
)
{
#ifdef HAVE_FFTW
...
...
@@ -608,6 +609,7 @@ void pm_mesh_init(struct pm_mesh* mesh, const struct gravity_props* props,
const
int
N
=
props
->
mesh_size
;
const
double
box_size
=
dim
[
0
];
mesh
->
nr_threads
=
nr_threads
;
mesh
->
periodic
=
1
;
mesh
->
N
=
N
;
mesh
->
dim
[
0
]
=
dim
[
0
];
...
...
@@ -622,6 +624,12 @@ void pm_mesh_init(struct pm_mesh* mesh, const struct gravity_props* props,
if
(
2
.
*
mesh
->
r_cut_max
>
box_size
)
error
(
"Mesh too small or r_cut_max too big for this box size"
);
/* Initialise the thread-parallel FFTW version */
if
(
N
>=
64
)
{
fftw_init_threads
();
fftw_plan_with_nthreads
(
nr_threads
);
}
/* Allocate the memory for the combined density and potential array */
mesh
->
potential
=
(
double
*
)
fftw_malloc
(
sizeof
(
double
)
*
N
*
N
*
N
);
if
(
mesh
->
potential
==
NULL
)
...
...
@@ -660,6 +668,8 @@ void pm_mesh_init_no_mesh(struct pm_mesh* mesh, double dim[3]) {
*/
void
pm_mesh_clean
(
struct
pm_mesh
*
mesh
)
{
fftw_cleanup_threads
();
if
(
mesh
->
potential
)
free
(
mesh
->
potential
);
mesh
->
potential
=
0
;
}
...
...
@@ -692,6 +702,12 @@ void pm_mesh_struct_restore(struct pm_mesh* mesh, FILE* stream) {
#ifdef HAVE_FFTW
const
int
N
=
mesh
->
N
;
/* Initialise the thread-parallel FFTW version */
if
(
N
>=
64
)
{
fftw_init_threads
();
fftw_plan_with_nthreads
(
mesh
->
nr_threads
);
}
/* Allocate the memory for the combined density and potential array */
mesh
->
potential
=
(
double
*
)
fftw_malloc
(
sizeof
(
double
)
*
N
*
N
*
N
);
if
(
mesh
->
potential
==
NULL
)
...
...
This diff is collapsed.
Click to expand it.
src/mesh_gravity.h
+
4
−
1
View file @
0f6b13c7
...
...
@@ -39,6 +39,9 @@ struct pm_mesh {
/*! Is the calculation using periodic BCs? */
int
periodic
;
/*! The number of threads used by the FFTW library */
int
nr_threads
;
/*! Side-length of the mesh */
int
N
;
...
...
@@ -65,7 +68,7 @@ struct pm_mesh {
};
void
pm_mesh_init
(
struct
pm_mesh
*
mesh
,
const
struct
gravity_props
*
props
,
double
dim
[
3
]);
double
dim
[
3
]
,
int
nr_threads
);
void
pm_mesh_init_no_mesh
(
struct
pm_mesh
*
mesh
,
double
dim
[
3
]);
void
pm_mesh_compute_potential
(
struct
pm_mesh
*
mesh
,
const
struct
space
*
s
,
struct
threadpool
*
tp
,
int
verbose
);
...
...
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