Commit 0577a01a authored by cortes_c's avatar cortes_c
Browse files

changes

parents d015aec1 fb4c9ed9
......@@ -44,7 +44,6 @@ set (CMAKE_CXX_EXTENSIONS OFF)
add_definitions (-DIPPL_LINUX -DIPPL_STRINGSTREAM)
add_definitions (-DIPPL_MPI -DMPICH_SKIP_MPICXX -DIPPL_DONT_POOL)
add_definitions (-DIPPL_USE_XDIV_RNG -DPETE_BITWISE_COPY)
add_definitions (-DIPPL_HAS_TEMPLATED_COMPLEX)
add_definitions (-DIPPL_USE_PARTIAL_SPECIALIZATION)
add_definitions (-Drestrict=__restrict__ -DNOCTAssert)
......
......@@ -23,8 +23,6 @@
// include standard complex header file
#include <complex>
#ifdef IPPL_HAS_TEMPLATED_COMPLEX
// KAI and others have a templated complex class
#ifdef IPPL_USE_SINGLE_PRECISION
typedef std::complex<float> dcomplex;
......@@ -32,20 +30,4 @@ typedef std::complex<float> dcomplex;
typedef std::complex<double> dcomplex;
#endif
typedef std::complex<float> fComplex;
#else
// This assumes that all other compilers have the old non-templated
// complex type which is like complex<double> in the draft standard.
typedef std::complex dcomplex;
#endif // IPPL_HAS_TEMPLATED_COMPLEX
#endif // DCOMPLEX_H
/***************************************************************************
* $RCSfile: dcomplex.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $
* IPPL_VERSION_ID: $Id: dcomplex.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $
***************************************************************************/
\ No newline at end of file
SET (_SRCS
fftpack.cpp
set (_SRCS
fftpack.cpp
)
SET (_HDRS
f2c.h
set (_HDRS
FFTBase.hpp
FFTBase.h
FFT.hpp
FFT.h
fftpack_FFT.h
SCSL_FFT.h
)
INCLUDE_DIRECTORIES (
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}
)
)
ADD_IPPL_SOURCES (${_SRCS})
ADD_IPPL_HEADERS (${_HDRS})
add_ippl_sources (${_SRCS})
add_ippl_headers (${_HDRS})
INSTALL (FILES ${_HDRS} DESTINATION include/FFT)
#install (FILES ${_HDRS} DESTINATION include/FFT)
This diff is collapsed.
This diff is collapsed.
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
//
// IPPL FFT
//
// Copyright (c) 2008-2018
// Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// OPAL is licensed under GNU GPL version 3.
//
//--------------------------------------------------------------------------
// Class FFTBase
......@@ -20,11 +20,7 @@
#include "Index/NDIndex.h"
#include "Field/GuardCellSizes.h"
#if defined(IPPL_USE_SCSL_FFT)
#include "FFT/SCSL_FFT.h"
#else
#include "FFT/fftpack_FFT.h"
#endif
#include <map>
#include <iostream>
......@@ -67,11 +63,7 @@ public:
enum FFT_e { ccFFT, rcFFT, sineFFT, cosineFFT };
// Type used for performing 1D FFTs
#if defined(IPPL_USE_SCSL_FFT)
typedef SCSL<T> InternalFFT_t;
#else
typedef FFTPACK<T> InternalFFT_t;
#endif
FFTBase() {}
......@@ -308,9 +300,9 @@ FFTBase<Dim,T>::checkDomain(const FFTBase<Dim,T>::Domain_t& dom1,
#endif // IPPL_FFT_FFTBASE_H
/***************************************************************************
* $RCSfile: FFTBase.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
* IPPL_VERSION_ID: $Id: FFTBase.h,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
***************************************************************************/
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode:nil
// End:
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
* This program was prepared by PSI.
* All rights in the program are reserved by PSI.
* Neither PSI nor the author(s)
* makes any warranty, express or implied, or assumes any liability or
* responsibility for the use of this software
*
* Visit www.amas.web.psi for more details
*
***************************************************************************/
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
// include files
//
// IPPL FFT
//
// Copyright (c) 2008-2018
// Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// OPAL is licensed under GNU GPL version 3.
//
#include "FFT/FFTBase.h"
#include "Utility/PAssert.h"
/***************************************************************************
FFTBase.cpp: constructors and write() member function for FFTBase class
***************************************************************************/
***************************************************************************/
// instantiate static null GC object
template <unsigned Dim, class T>
......@@ -44,31 +27,29 @@ template <unsigned Dim, class T>
FFTBase<Dim,T>::FFTBase(FFTBase<Dim,T>::FFT_e transform,
const FFTBase<Dim,T>::Domain_t& domain,
const bool transformTheseDims[Dim], bool compressTemps)
: transformType_m(transform), // transform type
: transformType_m(transform), // transform type
Domain_m(domain), // field domain
compressTempFields_m(compressTemps) // compress temp fields?
{
// Tau profiling
// Tau profiling
// Store which dims are transformed, and count up how many there are
nTransformDims_m = 0;
unsigned d;
for (d=0; d<Dim; ++d) {
transformDims_m[d] = transformTheseDims[d];
if (transformTheseDims[d]) ++nTransformDims_m;
}
// check that at least one dimension is being transformed
PInsist(nTransformDims_m>0,"Must transform at least one axis!!");
// Store the "names" (0,1,2) of these dims in an array of computed size
activeDims_m = new unsigned[nTransformDims_m];
int icount = 0;
for (d=0; d<Dim; ++d)
if (transformDims_m[d]) activeDims_m[icount++] = d;
// Store which dims are transformed, and count up how many there are
nTransformDims_m = 0;
unsigned d;
for (d=0; d<Dim; ++d) {
transformDims_m[d] = transformTheseDims[d];
if (transformTheseDims[d]) ++nTransformDims_m;
}
// check that at least one dimension is being transformed
PInsist(nTransformDims_m>0,"Must transform at least one axis!!");
// Store the "names" (0,1,2) of these dims in an array of computed size
activeDims_m = new unsigned[nTransformDims_m];
int icount = 0;
for (d=0; d<Dim; ++d)
if (transformDims_m[d]) activeDims_m[icount++] = d;
}
......@@ -76,22 +57,20 @@ template <unsigned Dim, class T>
FFTBase<Dim,T>::FFTBase(FFTBase<Dim,T>::FFT_e transform,
const FFTBase<Dim,T>::Domain_t& domain,
bool compressTemps)
: transformType_m(transform), // transform type
: transformType_m(transform), // transform type
Domain_m(domain), // field domain
compressTempFields_m(compressTemps) // compress temp fields?
{
// Tau profiling
// Tau profiling
// Default, transform all dims:
nTransformDims_m = Dim;
activeDims_m = new unsigned[Dim];
for (unsigned d=0; d<Dim; d++) {
transformDims_m[d] = true;
activeDims_m[d] = d;
}
// Default, transform all dims:
nTransformDims_m = Dim;
activeDims_m = new unsigned[Dim];
for (unsigned d=0; d<Dim; d++) {
transformDims_m[d] = true;
activeDims_m[d] = d;
}
}
......@@ -102,38 +81,36 @@ FFTBase<Dim,T>::FFTBase(FFTBase<Dim,T>::FFT_e transform,
template <unsigned Dim, class T>
void FFTBase<Dim,T>::write(std::ostream& out) const {
// Tau profiling
// Tau profiling
// Dump contents of FFT object
out << "---------------FFT Object Dump Begin-------------------" << std::endl;
// Output the user-defined names for transform directions:
out << "Map of transform direction names:" << std::endl;
std::map<char*,unsigned>::const_iterator mi, m_end = directions_m.end();
for (mi = directions_m.begin(); mi != m_end; ++mi)
out << "[" << (*mi).first << "," << (*mi).second << "]" << std::endl;
// Output type of transform
out << "Transform type = " << getTransformType(transformType_m) << std::endl;
// Output which dims are transformed:
out << "Transform dimensions: ";
for (unsigned d=0; d<Dim; ++d) {
out << "dim " << d << " = ";
if (transformDims_m[d])
out << "true" << std::endl;
else
out << "false" << std::endl;
}
out << std::endl;
out << "Input Field domain = " << Domain_m << std::endl; // Output the domain.
out << "---------------FFT Object Dump End---------------------" << std::endl;
return;
// Dump contents of FFT object
out << "---------------FFT Object Dump Begin-------------------" << std::endl;
// Output the user-defined names for transform directions:
out << "Map of transform direction names:" << std::endl;
std::map<char*,unsigned>::const_iterator mi, m_end = directions_m.end();
for (mi = directions_m.begin(); mi != m_end; ++mi)
out << "[" << (*mi).first << "," << (*mi).second << "]" << std::endl;
// Output type of transform
out << "Transform type = " << getTransformType(transformType_m) << std::endl;
// Output which dims are transformed:
out << "Transform dimensions: ";
for (unsigned d=0; d<Dim; ++d) {
out << "dim " << d << " = ";
if (transformDims_m[d])
out << "true" << std::endl;
else
out << "false" << std::endl;
}
out << std::endl;
out << "Input Field domain = " << Domain_m << std::endl; // Output the domain.
out << "---------------FFT Object Dump End---------------------" << std::endl;
return;
}
/***************************************************************************
* $RCSfile: FFTBase.cpp,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
* IPPL_VERSION_ID: $Id: FFTBase.cpp,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
***************************************************************************/
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode:nil
// End:
c========================================================================
c
c The IPPL Framework
c
c This program was prepared by the Regents of the University of
c Visit http://people.web.psi.ch/adelmann/ for more details
c
c========================================================================
c========================================================================
c=========================SCSL_FFT.F=====================================
c========================================================================
c I'm adding some Fortran wrappers around SGI/Cray Scientific Library
c routines, so we can call them from C++ code
c========================================================================
c The Cray T3E does not have double-precision versions of these
c routines, since its routines are double-precision by default.
#ifndef IPPL_T3E
subroutine sgizzfft(isign,n,scale,x,y,table,work,isys)
c------------------------------------------------------------------------
implicit double precision (a-h,o-z)
implicit integer (i-n)
c------------------------------------------------------------------------
dimension x(*), y(*), table(*), work(*)
call zzfft(isign,n,scale,x,y,table,work,isys)
return
end
subroutine sgidzfft(isign,n,scale,x,y,table,work,isys)
c------------------------------------------------------------------------
implicit double precision (a-h,o-z)
implicit integer (i-n)
c------------------------------------------------------------------------
dimension x(*), y(*), table(*), work(*)
call dzfft(isign,n,scale,x,y,table,work,isys)
return
end
subroutine sgizdfft(isign,n,scale,x,y,table,work,isys)
c------------------------------------------------------------------------
implicit double precision (a-h,o-z)
implicit integer (i-n)
c------------------------------------------------------------------------
dimension x(*), y(*), table(*), work(*)
call zdfft(isign,n,scale,x,y,table,work,isys)
return
end
#endif
c Single-precision routines
subroutine sgiccfft(isign,n,scale,x,y,table,work,isys)
c------------------------------------------------------------------------
implicit real (a-h,o-z)
implicit integer (i-n)
c------------------------------------------------------------------------
dimension x(*), y(*), table(*), work(*)
call ccfft(isign,n,scale,x,y,table,work,isys)
return
end
subroutine sgiscfft(isign,n,scale,x,y,table,work,isys)
c------------------------------------------------------------------------
implicit real (a-h,o-z)
implicit integer (i-n)
c------------------------------------------------------------------------
dimension x(*), y(*), table(*), work(*)
call scfft(isign,n,scale,x,y,table,work,isys)
return
end
subroutine sgicsfft(isign,n,scale,x,y,table,work,isys)
c------------------------------------------------------------------------
implicit real (a-h,o-z)
implicit integer (i-n)
c------------------------------------------------------------------------
dimension x(*), y(*), table(*), work(*)
call csfft(isign,n,scale,x,y,table,work,isys)
return
end
c========================================================================
c $RCSfile: SCSL_FFT.F,v $ $Author: adelmann $
c $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
c IPPL_VERSION_ID: $Id: SCSL_FFT.F,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
c========================================================================
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
#ifndef IPPL_FFT_SCSL_FFT_H
#define IPPL_FFT_SCSL_FFT_H
// include files
#include "Utility/PAssert.h"
#include "Utility/IpplInfo.h"
/**************************************************************************
* SCSL_FFT.h: Prototypes for accessing Fortran 1D FFT routines from the
* SGI/Cray Scientific Library, and definitions for templated class SCSL,
* which acts as an FFT engine for the FFT class, providing storage for
* trigonometric information and performing the 1D FFTs as needed.
**************************************************************************/
// For platforms that do Fortran symbols in all caps.
#if defined(IPPL_T3E)
#define sgiccfft_ SGICCFFT
#define sgiscfft_ SGISCFFT
#define sgicsfft_ SGICSFFT
#endif
// SCSL Fortran wrapper function prototypes
// These functions are defined in file SCSL_FFT.F, and they just turn
// around and call the native library routines.
#if defined(IPPL_T3E)
// Cray T3E has only "real" routines, which are automatically double precision
extern "C" {
// double-precision CC FFT
void sgiccfft_(int& isign, int& n, double& scale, double& x, double& y,
double& table, double& work, int& isys);
// double-precision RC FFT
void sgiscfft_(int& isign, int& n, double& scale, double& x, double& y,
double& table, double& work, int& isys);
// double-precision CR FFT
void sgicsfft_(int& isign, int& n, double& scale, double& x, double& y,
double& table, double& work, int& isys);
}
#else
// SGI offers separate single- and double-precision routines
extern "C" {
// double-precision CC FFT
void sgizzfft_(int& isign, int& n, double& scale, double& x, double& y,
double& table, double& work, int& isys);
// double-precision RC FFT
void sgidzfft_(int& isign, int& n, double& scale, double& x, double& y,
double& table, double& work, int& isys);
// double-precision CR FFT
void sgizdfft_(int& isign, int& n, double& scale, double& x, double& y,
double& table, double& work, int& isys);
// single-precision CC FFT
void sgiccfft_(int& isign, int& n, float& scale, float& x, float& y,
float& table, float& work, int& isys);
// single-precision RC FFT
void sgiscfft_(int& isign, int& n, float& scale, float& x, float& y,
float& table, float& work, int& isys);
// single-precision CR FFT
void sgicsfft_(int& isign, int& n, float& scale, float& x, float& y,
float& table, float& work, int& isys);
}
#endif // defined(IPPL_T3E)
// SCSL_wrap provides static functions that wrap the Fortran functions
// in a common interface. We specialize this class on precision type.
template <class T>
class SCSL_wrap {};
// Specialization for float
template <>
class SCSL_wrap<float> {
public:
// interface functions used by class SCSL
// complex-to-complex FFT
static void ccfft(int isign, int n, float scale, float* x, float* y,
float* table, float* work, int isys) {
sgiccfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
// real-to-complex FFT
static void rcfft(int isign, int n, float scale, float* x, float* y,
float* table, float* work, int isys) {
sgiscfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
// complex-to-real FFT
static void crfft(int isign, int n, float scale, float* x, float* y,
float* table, float* work, int isys) {
sgicsfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
};
// Specialization for double
#if defined(IPPL_T3E)
// Cray T3E uses single-precision function names for double-precision FFTs
template <>
class SCSL_wrap<double> {
public:
// interface functions used by class SCSL
// complex-to-complex FFT
static void ccfft(int isign, int n, double scale, double* x, double* y,
double* table, double* work, int isys) {
sgiccfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
// real-to-complex FFT
static void rcfft(int isign, int n, double scale, double* x, double* y,
double* table, double* work, int isys) {
sgiscfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
// complex-to-real FFT
static void crfft(int isign, int n, double scale, double* x, double* y,
double* table, double* work, int isys) {
sgicsfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
};
#else
// SGI has special FFT routines for double-precision
template <>
class SCSL_wrap<double> {
public:
// interface functions used by class SCSL
// complex-to-complex FFT
static void ccfft(int isign, int n, double scale, double* x, double* y,
double* table, double* work, int isys) {
sgizzfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
// real-to-complex FFT
static void rcfft(int isign, int n, double scale, double* x, double* y,
double* table, double* work, int isys) {
sgidzfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
// complex-to-real FFT
static void crfft(int isign, int n, double scale, double* x, double* y,
double* table, double* work, int isys) {
sgizdfft_(isign, n, scale, *x, *y, *table, *work, isys);
}
};
#endif // defined(IPPL_T3E)
// Definition of FFT engine class SCSL
template <class T>
class SCSL {
public:
// definition of complex type
typedef complex<T> Complex_t;
// Trivial constructor. Do the real work in setup function.
SCSL(void) {}
// destructor
~SCSL(void);
// setup internal storage and prepare to do FFTs
void setup(unsigned numTransformDims, const int* transformTypes,
const int* axisLengths);
// invoke FFT on complex data for given dimension and direction
void callFFT(unsigned transformDim, int direction, Complex_t* data);