consolidate all FFT related redundant defines and typedefs in a single header

This commit is contained in:
Axel Kohlmeyer
2022-05-06 11:27:17 -04:00
parent 6ec169fa9d
commit aae44892c0
8 changed files with 59 additions and 106 deletions

View File

@ -27,27 +27,6 @@ KSpaceStyle(pppm/electrode, PPPMElectrode);
#include "electrode_kspace.h" #include "electrode_kspace.h"
#include "pppm.h" #include "pppm.h"
#if defined(FFT_FFTW3)
#define LMP_FFT_LIB "FFTW3"
#elif defined(FFT_MKL)
#define LMP_FFT_LIB "MKL FFT"
#elif defined(FFT_CUFFT)
#define LMP_FFT_LIB "cuFFT"
#else
#define LMP_FFT_LIB "KISS FFT"
#endif
#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define LMP_FFT_PREC "single"
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define LMP_FFT_PREC "double"
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
namespace LAMMPS_NS { namespace LAMMPS_NS {
class PPPMElectrode : public PPPM, public ElectrodeKSpace { class PPPMElectrode : public PPPM, public ElectrodeKSpace {

View File

@ -23,20 +23,7 @@
#ifndef LMP_FFT_DATA_KOKKOS_H #ifndef LMP_FFT_DATA_KOKKOS_H
#define LMP_FFT_DATA_KOKKOS_H #define LMP_FFT_DATA_KOKKOS_H
// User-settable FFT precision #include "lmpfftsettings.h"
// FFT_PRECISION = 1 is single-precision complex (4-byte real, 4-byte imag)
// FFT_PRECISION = 2 is double-precision complex (8-byte real, 8-byte imag)
#ifdef FFT_SINGLE
#define FFT_PRECISION 1
#define MPI_FFT_SCALAR MPI_FLOAT
typedef float FFT_SCALAR;
#else
#define FFT_PRECISION 2
#define MPI_FFT_SCALAR MPI_DOUBLE
typedef double FFT_SCALAR;
#endif
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -13,24 +13,8 @@
#include <mpi.h> #include <mpi.h>
// User-settable FFT precision
// FFT_PRECISION = 1 is single-precision complex (4-byte real, 4-byte imag) #include "lmpfftsettings.h"
// FFT_PRECISION = 2 is double-precision complex (8-byte real, 8-byte imag)
#ifdef FFT_SINGLE
#define FFT_PRECISION 1
typedef float FFT_SCALAR;
#else
#define FFT_PRECISION 2
typedef double FFT_SCALAR;
#endif
// if user set FFTW, it means FFTW3
#ifdef FFT_FFTW
#define FFT_FFTW3
#endif
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -21,27 +21,7 @@ KSpaceStyle(pppm,PPPM);
#define LMP_PPPM_H #define LMP_PPPM_H
#include "kspace.h" #include "kspace.h"
#include "lmpfftsettings.h"
#if defined(FFT_FFTW3)
#define LMP_FFT_LIB "FFTW3"
#elif defined(FFT_MKL)
#define LMP_FFT_LIB "MKL FFT"
#elif defined(FFT_CUFFT)
#define LMP_FFT_LIB "cuFFT"
#else
#define LMP_FFT_LIB "KISS FFT"
#endif
#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define LMP_FFT_PREC "single"
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define LMP_FFT_PREC "double"
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
namespace LAMMPS_NS { namespace LAMMPS_NS {

View File

@ -21,24 +21,7 @@ KSpaceStyle(pppm/disp,PPPMDisp);
#define LMP_PPPM_DISP_H #define LMP_PPPM_DISP_H
#include "kspace.h" #include "kspace.h"
#include "lmpfftsettings.h"
#if defined(FFT_FFTW3)
#define LMP_FFT_LIB "FFTW3"
#elif defined(FFT_MKL)
#define LMP_FFT_LIB "MKL FFT"
#else
#define LMP_FFT_LIB "KISS FFT"
#endif
#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define LMP_FFT_PREC "single"
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define LMP_FFT_PREC "double"
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
namespace LAMMPS_NS { namespace LAMMPS_NS {

View File

@ -13,13 +13,7 @@
#include <mpi.h> #include <mpi.h>
#ifdef FFT_SINGLE #include "lmpfftsettings.h"
typedef float FFT_SCALAR;
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
// details of how to do a 3d remap // details of how to do a 3d remap

View File

@ -32,15 +32,9 @@ FixStyle(phonon,FixPhonon);
#ifndef FIX_PHONON_H #ifndef FIX_PHONON_H
#define FIX_PHONON_H #define FIX_PHONON_H
#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
#include "fix.h" #include "fix.h"
#include "lmpfftsettings.h"
#include <complex> #include <complex>
#include <map> #include <map>

52
src/lmpfftsettings.h Normal file
View File

@ -0,0 +1,52 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
// common FFT library related defines and compilation settings
#ifndef LMP_FFT_SETTINGS_H
#define LMP_FFT_SETTINGS_H
// if user set FFTW, it means FFTW3
#ifdef FFT_FFTW
#ifndef FFT_FFTW3
#define FFT_FFTW3
#endif
#endif
// set strings for library info output
#if defined(FFT_FFTW3)
#define LMP_FFT_LIB "FFTW3"
#elif defined(FFT_MKL)
#define LMP_FFT_LIB "MKL FFT"
#elif defined(FFT_CUFFT)
#define LMP_FFT_LIB "cuFFT"
#else
#define LMP_FFT_LIB "KISS FFT"
#endif
#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define FFT_PRECISION 1
#define LMP_FFT_PREC "single"
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define FFT_PRECISION 2
#define LMP_FFT_PREC "double"
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
#endif