Nicer solution for fftw3_threads

This commit is contained in:
Bastian M. Wojek 2009-12-27 15:26:11 +00:00
parent e0c893503f
commit 199ff918f0
6 changed files with 42 additions and 41 deletions

View File

@ -177,9 +177,19 @@ if test "${FFTW3_FOUND}" != "1"; then
FFTW3_LIBS="-L${FFTW3_PREFIX}/lib -lfftw3 -lm" FFTW3_LIBS="-L${FFTW3_PREFIX}/lib -lfftw3 -lm"
FFTW3_CFLAGS="-I${FFTW3_PREFIX}/include" FFTW3_CFLAGS="-I${FFTW3_PREFIX}/include"
fi fi
# Check for fftw3_threads-library. If available musrfit is also linked against it (used in libTFitPofB).
SAVED_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $FFTW3_CFLAGS"
SAVED_LIBSS="$LIBS"
LIBS="$LIBS $FFTW3_LIBS"
AC_SEARCH_LIBS([fftw_init_threads], [fftw3_threads], [FFTW3_LIBS="$FFTW3_LIBS -lfftw3_threads -lpthread"
AC_DEFINE([HAVE_LIBFFTW3_THREADS], [1], [Define to 1 if fftw3_threads are available])], [], [-lpthread])
CFLAGS="$SAVED_CFLAGS"
LIBS="$SAVED_LIBS"
AC_SUBST(FFTW3_LIBS) AC_SUBST(FFTW3_LIBS)
AC_SUBST(FFTW3_CFLAGS) AC_SUBST(FFTW3_CFLAGS)
dnl ----------------------------------------------- dnl -----------------------------------------------
dnl Ask user for path to gsl dnl Ask user for path to gsl
dnl ----------------------------------------------- dnl -----------------------------------------------
@ -278,6 +288,17 @@ ROOT_PATH([5.22/00], [], AC_MSG_ERROR([Either ROOT is not installed correctly or
ROOT_LIBS="-L${ROOTLIBDIR} ${ROOTGLIBS} ${ROOTAUXLIBS} -lMinuit2 -lMathMore -lXMLParser" ROOT_LIBS="-L${ROOTLIBDIR} ${ROOTGLIBS} ${ROOTAUXLIBS} -lMinuit2 -lMathMore -lXMLParser"
ROOT_CFLAGS="-I${ROOTINCDIR} ${ROOTCFLAGS} ${ROOTAUXCFLAGS}" ROOT_CFLAGS="-I${ROOTINCDIR} ${ROOTCFLAGS} ${ROOTAUXCFLAGS}"
## Check for Minuit2-library - not working at the moment, needs some more thoughts
#SAVED_CXXFLAGS="$CXXFLAGS"
#CXXFLAGS="$CXXFLAGS -I${ROOTINCDIR}/../include/Minuit2 $ROOT_CFLAGS"
#SAVED_LIBSS="$LIBS"
#LIBS="$LIBS $ROOT_LIBS"
#AC_SEARCH_LIBS([MnMinimize], [Minuit2], [ROOT_LIBS="$ROOT_LIBS -lMinuit2 -lMathMore"],
# [AC_MSG_ERROR([Minuit2 library not found... Please check!])], [-lMathMore])
#CXXFLAGS="$SAVED_CXXFLAGS"
#LIBS="$SAVED_LIBS"
AC_SUBST(ROOT_LIBS) AC_SUBST(ROOT_LIBS)
AC_SUBST(ROOT_CFLAGS) AC_SUBST(ROOT_CFLAGS)
@ -332,36 +353,6 @@ AC_ARG_ENABLE([BMWlibs], [AC_HELP_STRING([--enable-BMWlibs],[build optional BMW
AC_SUBST(CUBA_LIBS) AC_SUBST(CUBA_LIBS)
AC_SUBST(CUBA_CFLAGS) AC_SUBST(CUBA_CFLAGS)
# Since it is not clear to me, how to use the AC_SEARCH_LIBS macro correctly, I introduce a primitive file check here...
FFTW3_THREADS_LIBS=$(echo ${FFTW3_LIBS} | grep "lfftw3_threads")
if test "$FFTW3_THREADS_LIBS" == ""; then
if [test -r ${FFTW3_PREFIX}/lib/libfftw3_threads.a || test -r ${FFTW3_PREFIX}/lib/libfftw3_threads.so || \
test -r ${FFTW3_PREFIX}/lib/libfftw3_threads.dll.a || test -r ${FFTW3_PREFIX}/lib/libfftw3_threads.dll || \
test -r ${FFTW3_PREFIX}/lib/libfftw3_threads.dylib]; then
AC_MSG_RESULT([FFTW3 threads library found... OK])
elif [test -r /usr/local/lib/libfftw3_threads.a || test -r /usr/local/lib/libfftw3_threads.so || \
test -r /usr/local/lib/libfftw3_threads.dll.a || test -r /usr/local/lib/libfftw3_threads.dll || \
test -r /usr/local/lib/libfftw3_threads.dylib]; then
AC_MSG_RESULT([FFTW3 threads library found... OK])
elif [test -r /usr/lib/libfftw3_threads.a || test -r /usr/lib/libfftw3_threads.so || \
test -r /usr/lib/libfftw3_threads.dll.a || test -r /usr/lib/libfftw3_threads.dll || \
test -r /usr/lib/libfftw3_threads.dylib]; then
AC_MSG_RESULT([FFTW3 threads library found... OK])
elif [test -r /sw/lib/libfftw3_threads.a || test -r /sw/lib/libfftw3_threads.so || \
test -r /sw/lib/libfftw3_threads.dll.a || test -r /sw/lib/libfftw3_threads.dll || \
test -r /sw/lib/libfftw3_threads.dylib]; then
AC_MSG_RESULT([FFTW3 threads library found... OK])
elif [test -r /opt/local/lib/libfftw3_threads.a || test -r /opt/local/lib/libfftw3_threads.so || \
test -r /opt/local/lib/libfftw3_threads.dll.a || test -r /opt/local/lib/libfftw3_threads.dll || \
test -r /opt/local/lib/libfftw3_threads.dylib]; then
AC_MSG_RESULT([FFTW3 threads library found... OK])
else
AC_MSG_WARN([FFTW3 threads library not found. Please check! The BMWlibs will not run without it at the moment!])
fi
FFTW3_THREADS_LIBS="${FFTW3_LIBS} -lfftw3_threads -lpthread"
fi
AC_SUBST(FFTW3_THREADS_LIBS)
BUILD_BMW_LIBS=1 BUILD_BMW_LIBS=1
], ],
[BUILD_BMW_LIBS=0] [BUILD_BMW_LIBS=0]

View File

@ -1283,18 +1283,18 @@ Bool_t PRunDataHandler::ReadMudFile()
MUD_closeRead(fh); MUD_closeRead(fh);
/* /*
cout << endl << "fRunName : " << runData.fRunName.Data(); cout << endl << "fRunName : " << runData.GetRunName()->Data();
cout << endl << "fRunTitle : " << runData.fRunTitle.Data(); cout << endl << "fRunTitle : " << runData.GetRunTitle()->Data();
cout << endl << "fSetup : " << runData.fSetup.Data(); cout << endl << "fSetup : " << runData.GetSetup()->Data();
cout << endl << "fField : " << runData.fField; cout << endl << "fField : " << runData.GetField();
cout << endl << "fTemp : " << runData.fTemp[0].first; cout << endl << "fTemp : " << runData.GetTemperature(1);
cout << endl << "noOfHistos : " << noOfHistos; cout << endl << "noOfHistos : " << noOfHistos;
cout << endl << "fTimeResolution : " << runData.fTimeResolution; cout << endl << "fTimeResolution : " << runData.GetTimeResolution();
for (Int_t i=0; i<noOfHistos; i++) { for (Int_t i=0; i<noOfHistos; i++) {
cout << endl << "------"; cout << endl << "------";
cout << endl << i << " : t0 = " << runData.fT0s[i]; cout << endl << i << " : t0 = " << runData.GetT0(i);
cout << endl << i << " : bkg bins = " << runData.fBkgBin[i].first << "..." << runData.fBkgBin[i].second; cout << endl << i << " : bkg bins = " << runData.GetBkgBin(i).first << "..." << runData.GetBkgBin(i).second;
cout << endl << i << " : good bins = " << runData.fGoodDataBin[i].first << "..." << runData.fGoodDataBin[i].second; cout << endl << i << " : good bins = " << runData.GetGoodDataBin(i).first << "..." << runData.GetGoodDataBin(i).second;
} }
cout << endl; cout << endl;
*/ */

View File

@ -56,7 +56,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core
lib_LTLIBRARIES = libTFitPofB.la lib_LTLIBRARIES = libTFitPofB.la
libTFitPofB_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) libTFitPofB_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources)
libTFitPofB_la_LIBADD = $(LEM_LIBS) $(PMUSR_LIBS) $(FFTW3_THREADS_LIBS) $(ROOT_LIBS) libTFitPofB_la_LIBADD = $(LEM_LIBS) $(PMUSR_LIBS) $(FFTW3_LIBS) $(ROOT_LIBS)
libTFitPofB_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(PLUGIN_RELEASE) $(AM_LDFLAGS) libTFitPofB_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(PLUGIN_RELEASE) $(AM_LDFLAGS)
## For the moment do not build pkgconfig files for musrfit plug-ins... ## For the moment do not build pkgconfig files for musrfit plug-ins...

View File

@ -128,9 +128,11 @@ TBulkTriVortexLondonFieldCalc::TBulkTriVortexLondonFieldCalc(const string& wisdo
fParam.resize(3); fParam.resize(3);
fGridExists = false; fGridExists = false;
#ifdef HAVE_LIBFFTW3_THREADS
int init_threads(fftw_init_threads()); int init_threads(fftw_init_threads());
if (init_threads) if (init_threads)
fftw_plan_with_nthreads(2); fftw_plan_with_nthreads(2);
#endif /* HAVE_LIBFFTW3_THREADS */
fFFTin = new fftw_complex[(fSteps/2 + 1) * fSteps]; fFFTin = new fftw_complex[(fSteps/2 + 1) * fSteps];
fFFTout = new double[fSteps*fSteps]; fFFTout = new double[fSteps*fSteps];
@ -295,9 +297,11 @@ TBulkTriVortexMLFieldCalc::TBulkTriVortexMLFieldCalc(const string& wisdom, const
fParam.resize(3); fParam.resize(3);
fGridExists = false; fGridExists = false;
#ifdef HAVE_LIBFFTW3_THREADS
int init_threads(fftw_init_threads()); int init_threads(fftw_init_threads());
if (init_threads) if (init_threads)
fftw_plan_with_nthreads(2); fftw_plan_with_nthreads(2);
#endif /* HAVE_LIBFFTW3_THREADS */
fFFTin = new fftw_complex[(fSteps/2 + 1) * fSteps]; fFFTin = new fftw_complex[(fSteps/2 + 1) * fSteps];
fFFTout = new double[fSteps*fSteps]; fFFTout = new double[fSteps*fSteps];
@ -465,9 +469,11 @@ TBulkTriVortexAGLFieldCalc::TBulkTriVortexAGLFieldCalc(const string& wisdom, con
fParam.resize(3); fParam.resize(3);
fGridExists = false; fGridExists = false;
#ifdef HAVE_LIBFFTW3_THREADS
int init_threads(fftw_init_threads()); int init_threads(fftw_init_threads());
if (init_threads) if (init_threads)
fftw_plan_with_nthreads(2); fftw_plan_with_nthreads(2);
#endif /* HAVE_LIBFFTW3_THREADS */
fFFTin = new fftw_complex[(fSteps/2 + 1) * fSteps]; fFFTin = new fftw_complex[(fSteps/2 + 1) * fSteps];
fFFTout = new double[fSteps*fSteps]; fFFTout = new double[fSteps*fSteps];
@ -655,9 +661,11 @@ TBulkTriVortexNGLFieldCalc::TBulkTriVortexNGLFieldCalc(const string& wisdom, con
fParam.resize(3); fParam.resize(3);
fGridExists = false; fGridExists = false;
#ifdef HAVE_LIBFFTW3_THREADS
int init_threads(fftw_init_threads()); int init_threads(fftw_init_threads());
if (init_threads) if (init_threads)
fftw_plan_with_nthreads(2); fftw_plan_with_nthreads(2);
#endif /* HAVE_LIBFFTW3_THREADS */
const unsigned int stepsSq(fSteps*fSteps); const unsigned int stepsSq(fSteps*fSteps);

View File

@ -65,11 +65,13 @@
TPofTCalc::TPofTCalc (const TPofBCalc *PofB, const string &wisdom, const vector<double> &par) : fWisdom(wisdom) { TPofTCalc::TPofTCalc (const TPofBCalc *PofB, const string &wisdom, const vector<double> &par) : fWisdom(wisdom) {
#ifdef HAVE_LIBFFTW3_THREADS
int init_threads(fftw_init_threads()); int init_threads(fftw_init_threads());
if (!init_threads) if (!init_threads)
cout << "TPofTCalc::TPofTCalc: Couldn't initialize multiple FFTW-threads ..." << endl; cout << "TPofTCalc::TPofTCalc: Couldn't initialize multiple FFTW-threads ..." << endl;
else else
fftw_plan_with_nthreads(2); fftw_plan_with_nthreads(2);
#endif /* HAVE_LIBFFTW3_THREADS */
fNFFT = static_cast<int>(1.0/(gBar*par[1]*par[2])); fNFFT = static_cast<int>(1.0/(gBar*par[1]*par[2]));
if (fNFFT % 2) { if (fNFFT % 2) {

View File

@ -33,7 +33,7 @@ CLEANFILES = *Dict.cpp *Dict.h *~ core
lib_LTLIBRARIES = libLFRelaxation.la lib_LTLIBRARIES = libLFRelaxation.la
libLFRelaxation_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) libLFRelaxation_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources)
libLFRelaxation_la_LIBADD = $(PMUSR_LIBS) $(FFTW3_THREADS_LIBS) $(GSL_LIBS) $(ROOT_LIBS) $(CUBA_LIBS) libLFRelaxation_la_LIBADD = $(PMUSR_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) $(CUBA_LIBS)
libLFRelaxation_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(PLUGIN_RELEASE) $(AM_LDFLAGS) libLFRelaxation_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(PLUGIN_RELEASE) $(AM_LDFLAGS)
## For the moment do not build pkgconfig files for musrfit plug-ins... ## For the moment do not build pkgconfig files for musrfit plug-ins...