From 5ca63a9fdf59fd59345114606a00bf32d2662fb2 Mon Sep 17 00:00:00 2001 From: Thorsten Kurth Date: Tue, 30 Aug 2016 14:38:19 -0700 Subject: [PATCH 01/43] initial commit --- qphix.xcodeproj/project.pbxproj | 67 ++++++++++++++++++ .../contents.xcworkspacedata | 7 ++ .../UserInterfaceState.xcuserstate | Bin 0 -> 7757 bytes 3 files changed, 74 insertions(+) create mode 100644 qphix.xcodeproj/project.pbxproj create mode 100644 qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 qphix.xcodeproj/project.xcworkspace/xcuserdata/tkurth.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/qphix.xcodeproj/project.pbxproj b/qphix.xcodeproj/project.pbxproj new file mode 100644 index 000000000..20b209eda --- /dev/null +++ b/qphix.xcodeproj/project.pbxproj @@ -0,0 +1,67 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 47; + objects = { + +/* Begin PBXGroup section */ + B5E4294F1D76318E0002CB05 = { + isa = PBXGroup; + children = ( + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXProject section */ + B5E429501D76318E0002CB05 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0730; + }; + buildConfigurationList = B5E429531D76318E0002CB05 /* Build configuration list for PBXProject "qphix" */; + compatibilityVersion = "Xcode 6.3"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = B5E4294F1D76318E0002CB05; + projectDirPath = ""; + projectRoot = ""; + targets = ( + ); + }; +/* End PBXProject section */ + +/* Begin XCBuildConfiguration section */ + B5E429541D76318E0002CB05 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Debug; + }; + B5E429551D76318E0002CB05 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B5E429531D76318E0002CB05 /* Build configuration list for PBXProject "qphix" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B5E429541D76318E0002CB05 /* Debug */, + B5E429551D76318E0002CB05 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B5E429501D76318E0002CB05 /* Project object */; +} diff --git a/qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..f9821acb3 --- /dev/null +++ b/qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/qphix.xcodeproj/project.xcworkspace/xcuserdata/tkurth.xcuserdatad/UserInterfaceState.xcuserstate b/qphix.xcodeproj/project.xcworkspace/xcuserdata/tkurth.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..e510e98e8faefca65305a441ab78e401109d5f10 GIT binary patch literal 7757 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 literal 0 HcmV?d00001 From 9e15d7ce203facf0335730a25adbbd458e51ef63 Mon Sep 17 00:00:00 2001 From: Thorsten Kurth Date: Tue, 30 Aug 2016 14:43:22 -0700 Subject: [PATCH 02/43] removed mistake --- qphix.xcodeproj/project.pbxproj | 67 ------------------ .../contents.xcworkspacedata | 7 -- .../UserInterfaceState.xcuserstate | Bin 7757 -> 0 bytes 3 files changed, 74 deletions(-) delete mode 100644 qphix.xcodeproj/project.pbxproj delete mode 100644 qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 qphix.xcodeproj/project.xcworkspace/xcuserdata/tkurth.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/qphix.xcodeproj/project.pbxproj b/qphix.xcodeproj/project.pbxproj deleted file mode 100644 index 20b209eda..000000000 --- a/qphix.xcodeproj/project.pbxproj +++ /dev/null @@ -1,67 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 47; - objects = { - -/* Begin PBXGroup section */ - B5E4294F1D76318E0002CB05 = { - isa = PBXGroup; - children = ( - ); - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXProject section */ - B5E429501D76318E0002CB05 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0730; - }; - buildConfigurationList = B5E429531D76318E0002CB05 /* Build configuration list for PBXProject "qphix" */; - compatibilityVersion = "Xcode 6.3"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = B5E4294F1D76318E0002CB05; - projectDirPath = ""; - projectRoot = ""; - targets = ( - ); - }; -/* End PBXProject section */ - -/* Begin XCBuildConfiguration section */ - B5E429541D76318E0002CB05 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - }; - name = Debug; - }; - B5E429551D76318E0002CB05 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - B5E429531D76318E0002CB05 /* Build configuration list for PBXProject "qphix" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B5E429541D76318E0002CB05 /* Debug */, - B5E429551D76318E0002CB05 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = B5E429501D76318E0002CB05 /* Project object */; -} diff --git a/qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index f9821acb3..000000000 --- a/qphix.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/qphix.xcodeproj/project.xcworkspace/xcuserdata/tkurth.xcuserdatad/UserInterfaceState.xcuserstate b/qphix.xcodeproj/project.xcworkspace/xcuserdata/tkurth.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index e510e98e8faefca65305a441ab78e401109d5f10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7757 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 From 5f961be449bd4ee242018eb5199396b91dd2226b Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Thu, 1 Sep 2016 17:08:44 -0400 Subject: [PATCH 03/43] Alpha version: Added theQDPPoolAllocator currently coded using ThreadedBuildingBlocks. Still to be tested for production tho. --- include/qdp_pool_allocator.h | 68 +++++++++++++++++++ lib/qdp_pool_allocator.cc | 128 +++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 include/qdp_pool_allocator.h create mode 100644 lib/qdp_pool_allocator.cc diff --git a/include/qdp_pool_allocator.h b/include/qdp_pool_allocator.h new file mode 100644 index 000000000..ef4c44545 --- /dev/null +++ b/include/qdp_pool_allocator.h @@ -0,0 +1,68 @@ +// -*- C++ -*- + +/*! \file + * \brief Default memory allocator for QDP + * + */ + +#ifndef QDP_POOL_ALLOCATOR +#define QDP_POOL_ALLOCATOR + + +#define TBB_PREVIEW_MEMORY_POOL 1 +#include "tbb/memory_pool.h" + +#include "qdp_singleton.h" +namespace QDP +{ + namespace Allocator { + + // A Descrptor contains the start block and the number of blocks + // In an object + // The idea is that when we allocate n_blocks, they will be contiguous + // so we can just note the start, and the number + // and then pop them off the end of the free list. + // When we return to the pool we can just add back the blocks. + + + + // Quick and Dirty Pool ALlocator + class QDPPoolAllocator { + public: + QDPPoolAllocator(void); + + ~QDPPoolAllocator(); + + void init(size_t PoolSizeInGB); + + void* alloc(size_t size); + void free(void *mem); + + + private: + +// size_t _PoolSize; + // unsigned char* _MyMem; + tbb::memory_pool< std::allocator > _LargePool; + + }; + + + + // Turn into a Singleton. Create with CreateUsingNew + // Has NoDestroy lifetime, as it may be needed for + // the destruction policy is No Destroy, so the + // Singleton is not cleaned up on exit. This is so + // that static objects can refer to it with confidence + // in their own destruction, not having to worry that + // atexit() may have destroyed the allocator before + // the static objects need to feed memory. + typedef SingletonHolder theQDPPoolAllocator; + + } // namespace Allocator +} // namespace QDP + +#endif diff --git a/lib/qdp_pool_allocator.cc b/lib/qdp_pool_allocator.cc new file mode 100644 index 000000000..93673240e --- /dev/null +++ b/lib/qdp_pool_allocator.cc @@ -0,0 +1,128 @@ +/*! @file + * @brief QCDOC memory allocator + */ + +#include "qdp.h" +#include "qdp_config.h" +#include "qdp_default_allocator.h" +#include "qdp_pool_allocator.h" +#include +#include +#include + + +#undef DEBUG_POOL_ALLOCATOR + +namespace QDP { +namespace Allocator { + + struct MemInfo + { + size_t Size; + unsigned char* Unaligned; + }; + + std::map theAllocMap; + +#if 0 + QDPPoolAllocator::QDPPoolAllocator() : _PoolSize(0), + _MyMem(nullptr), _LargePool(nullptr){} +#else + QDPPoolAllocator::QDPPoolAllocator() {} +#endif + +#if 0 + QDPPoolAllocator::~QDPPoolAllocator() { + if ( _LargePool ) delete _LargePool; + if ( _MyMem ) { + delete [] _MyMem; + } + _LargePool = nullptr; + _MyMem = nullptr; + _PoolSize= 0; + } +#else + QDPPoolAllocator::~QDPPoolAllocator() {} +#endif + // Use extensible memory pool -- with large pages + void + QDPPoolAllocator::init(size_t PoolSizeInGB) + { +#if 0 + //QDPIO::cout << "Initializing TBB Pool Allocator" << std::endl; + if( _MyMem != nullptr ) { + //QDPIO::cout << "Allocator Already Inited. Aborting" << std::endl; + QDP_abort(1); + } + theAllocMap.clear(); + ///QDPIO::cout << std::flush; + _PoolSize = PoolSizeInGB*1024*1024*1024; + + //QDPIO::cout << "Allocating " << PoolSizeInGB << " GB" << std::endl; + _MyMem = new unsigned char [ _PoolSize ]; + _LargePool = new tbb::fixed_pool((void *)_MyMem, + _PoolSize); +#endif + + } + + void* + QDPPoolAllocator::alloc(size_t Size) + { + size_t BytesToAlloc; + BytesToAlloc = Size; + BytesToAlloc += QDP_ALIGNMENT_SIZE; + + + unsigned char* Unaligned = (unsigned char *)(_LargePool.malloc(BytesToAlloc)); + + unsigned char* Aligned = (unsigned char *) + ( ( (unsigned long)Unaligned + (QDP_ALIGNMENT_SIZE-1) ) & ~(QDP_ALIGNMENT_SIZE - 1)); + +#ifdef DEBUG_POOL_ALLOCATOR + QDPIO::cout << " Allocated: " << BytesToAlloc << " Bytes, Unaligend=" <<(unsigned long) Unaligned + << " Aligned=" << (unsigned long) Aligned << std::endl; +#endif + // Insert into the map + auto r = theAllocMap.insert(std::make_pair(Aligned, MemInfo{BytesToAlloc,Unaligned})); + + // Check success of insertion. + if( ! r.second ) { + //QDPIO::cerr << "Failed to insert (unaligned,aligned) pair into map" << std::endl; + QDP_abort(1); + } + + // Return the aligned pointer + return (void *)Aligned; + } + + void QDPPoolAllocator::free(void *mem) + { + try { + // Look it up. + auto d = theAllocMap[(unsigned char *)mem]; +#ifdef DEBUG_POOL_ALLOCATOR + QDPIO::cout << "PoolAlloc::free: Descriptor Found: Size="<< d.Size + << " Unaligned =" << std::hex <<(unsigned long)d.Unaligned << std::endl; +#endif + + _LargePool.free(d.Unaligned); + +#ifdef DEBUG_POOL_ALLOCATOR + QDPIO::cout << "PoolAlloc::free: Erasing Addr from theAllocMap... "; +#endif + + // Delete _InUseMap entry + theAllocMap.erase((unsigned char *)mem); + +#ifdef DEBUG_POOL_ALLOCATOR + QDPIO::cout << " ... done" < Date: Fri, 2 Sep 2016 15:23:15 -0400 Subject: [PATCH 04/43] Forgot these --- aclocal.m4 | 576 +++++++++++++------------------ include/Makefile.am | 3 +- include/qdp_config_internal.h.in | 3 - include/qdp_outer.h | 25 +- include/qdp_outersubtype.h | 10 +- lib/Makefile.am | 2 +- lib/qdp_parscalar_init.cc | 16 +- lib/qdp_parscalar_layout.cc | 9 +- lib/qdp_xmlio.cc | 3 +- 9 files changed, 297 insertions(+), 350 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index fba53890b..4f079f97b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.13.4 -*- Autoconf -*- - -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,16 +11,15 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],, +[m4_warning([this file was generated for autoconf 2.63. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) +To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +31,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.13' +[am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.13.4], [], +m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,22 +50,22 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.13.4])dnl +[AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -85,7 +84,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you +# harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -111,19 +110,22 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 9 + # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -142,14 +144,16 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 10 -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing @@ -159,7 +163,7 @@ fi])]) # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was @@ -172,13 +176,12 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], @@ -186,9 +189,8 @@ AC_CACHE_CHECK([dependency style of $depcc], # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -227,16 +229,16 @@ AC_CACHE_CHECK([dependency style of $depcc], : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -245,16 +247,16 @@ AC_CACHE_CHECK([dependency style of $depcc], test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -302,7 +304,7 @@ AM_CONDITIONAL([am__fastdep$1], [ # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl @@ -312,39 +314,34 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' - am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +#serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ - # Older Autoconf quotes --file arguments for eval, but not when files + # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in @@ -357,7 +354,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but + # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. @@ -369,19 +366,21 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], continue fi # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. + # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue + test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` @@ -399,7 +398,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will +# is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], @@ -409,12 +408,15 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 16 + # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -430,7 +432,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.65])dnl +[AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -459,40 +461,31 @@ AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl @@ -503,32 +496,28 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], @@ -556,7 +545,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -575,14 +564,16 @@ if test x"${install_sh}" != xset; then install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST([install_sh])]) +AC_SUBST(install_sh)]) -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], @@ -598,12 +589,14 @@ AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 4 + # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. @@ -621,7 +614,7 @@ am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. +# Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include @@ -648,12 +641,15 @@ rm -f confinc confmf # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 6 + # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], @@ -661,10 +657,11 @@ AC_DEFUN([AM_MISSING_PROG], $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) + # AM_MISSING_HAS_RUN # ------------------ -# Define MISSING if not defined so far and test if it is modern enough. -# If it is, set am_missing_run to use it, otherwise, to nothing. +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl @@ -677,35 +674,63 @@ if test x"${MISSING+set}" != xset; then esac fi # Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " else am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) + AC_MSG_WARN([`missing' script is too old or missing]) fi ]) +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 4 + # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# -------------------- +# ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) -# ------------------------ +# ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -718,16 +743,22 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 5 + # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -738,40 +769,32 @@ case `pwd` in esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac -# Do 'set' in a subshell so we don't clobber the current shell's +# Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + test "$[2]" = conftest.file ) then @@ -781,85 +804,9 @@ else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) - -# Copyright (C) 2009-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) +AC_MSG_RESULT(yes)]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -867,32 +814,34 @@ _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor 'install' (even GNU) is that you can't +# One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize +# always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -900,22 +849,24 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- +# --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -925,114 +876,75 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar -# AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], - - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi - done + # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) - +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR diff --git a/include/Makefile.am b/include/Makefile.am index 667f913e3..a05ec4541 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -129,7 +129,8 @@ BAGEL_HDRS = qdp_scalarsite_bagel_qdp.h \ # HEADERS for the memory allocator MEMORY_HDRS = qdp_allocator.h \ qdp_singleton.h \ - qdp_default_allocator.h + qdp_default_allocator.h \ + qdp_pool_allocator.h # All the include files - avoid flattening of dirs by using nobase nobase_include_HEADERS = \ diff --git a/include/qdp_config_internal.h.in b/include/qdp_config_internal.h.in index f2d5baa27..c88fc9c2e 100644 --- a/include/qdp_config_internal.h.in +++ b/include/qdp_config_internal.h.in @@ -48,9 +48,6 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME -/* Define to the home page for this package. */ -#undef PACKAGE_URL - /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/include/qdp_outer.h b/include/qdp_outer.h index 9241ce822..3c0973bca 100644 --- a/include/qdp_outer.h +++ b/include/qdp_outer.h @@ -5,7 +5,7 @@ #include "qdp_config.h" #include "qdp_allocator.h" - +#include "qdp_pool_allocator.h" /*! \file * \brief Outer grid classes */ @@ -413,28 +413,41 @@ class OLattice: public QDPType > { mem=true; // Barfs if allocator fails + size_t NSites = static_cast(Layout::sitesOnNode()); try { - F=(T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*Layout::sitesOnNode(),QDP::Allocator::DEFAULT); + //F=(T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*Layout::sitesOnNode(),QDP::Allocator::DEFAULT); + F=(T*)QDP::Allocator::theQDPPoolAllocator::Instance().alloc(sizeof(T)*NSites); } catch(std::bad_alloc) { QDPIO::cerr << "Allocation failed in OLattice alloc_mem" << std::endl; - QDP::Allocator::theQDPAllocator::Instance().dump(); +// QDP::Allocator::theQDPAllocator::Instance().dump(); + QDP_abort(1); } + +#if 0 + // Nuke touch for now +#pragma omp parallel for + for(int j=0; j < NSites; ++j) { + *((char *)&F[j])=0; + } +#endif + } //! Internal memory free inline void free_mem() { if (!mem) return; - if( F != 0x0 ) + if( F != nullptr ) { - QDP::Allocator::theQDPAllocator::Instance().free(F); + // QDP::Allocator::theQDPAllocator::Instance().free(F); + QDP::Allocator::theQDPPoolAllocator::Instance().free(F); } mem = false; - F = 0x0; + F = nullptr; } diff --git a/include/qdp_outersubtype.h b/include/qdp_outersubtype.h index 6ef19c3c4..45414e2b0 100644 --- a/include/qdp_outersubtype.h +++ b/include/qdp_outersubtype.h @@ -7,6 +7,7 @@ #ifndef QDP_OUTERSUBTYPE_H #define QDP_OUTERSUBTYPE_H +#include "qdp_pool_allocator.h" namespace QDP { //! OScalar class narrowed to a subset @@ -142,12 +143,14 @@ class OSubLattice: public QDPSubType > //QDP_info("OSubLattice alloc for %d sites",s->numSiteTable()); try { - F = (T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*s->numSiteTable(),QDP::Allocator::DEFAULT); + //F = (T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*s->numSiteTable(),QDP::Allocator::DEFAULT); + + F = (T*)QDP::Allocator::theQDPPoolAllocator::Instance().alloc(sizeof(T)*s->numSiteTable()); } catch(std::bad_alloc) { QDPIO::cerr << "Allocation failed in OSubLattice" << std::endl; - QDP::Allocator::theQDPAllocator::Instance().dump(); + //QDP::Allocator::theQDPAllocator::Instance().dump(); QDP_abort(1); } } @@ -159,7 +162,8 @@ class OSubLattice: public QDPSubType > } void free_mem() { - QDP::Allocator::theQDPAllocator::Instance().free(F); + // QDP::Allocator::theQDPAllocator::Instance().free(F); + QDP::Allocator::theQDPPoolAllocator::Instance().free(F); } #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 708db8e12..6b62f433a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -88,7 +88,7 @@ libqdp_a_SOURCES += qdp_scalarvecsite_sse.cc endif if BUILD_DEFAULT_ALLOCATOR -libqdp_a_SOURCES += qdp_default_allocator.cc +libqdp_a_SOURCES += qdp_default_allocator.cc qdp_pool_allocator.cc endif if BUILD_BGQ_THREADBIND diff --git a/lib/qdp_parscalar_init.cc b/lib/qdp_parscalar_init.cc index a351b1abe..bd4e7bce5 100644 --- a/lib/qdp_parscalar_init.cc +++ b/lib/qdp_parscalar_init.cc @@ -34,6 +34,8 @@ namespace QDP { static int n_cores = -1; static int n_threads_per_core = -1; + extern size_t pool_size_in_gb; + //! Turn on the machine void QDP_initialize(int *argc, char ***argv) { @@ -46,6 +48,8 @@ namespace QDP { // // Process command line // + // Default pool size + pool_size_in_gb = 8; // Look for help bool help_flag = false; @@ -57,10 +61,10 @@ namespace QDP { bool setGeomP = false; multi1d logical_geom(Nd); // apriori logical geometry of the machine + logical_geom = 0; - bool setIOGeomP = false; - multi1d logical_iogeom(Nd); // apriori logical + multi1d logical_iogeom(Nd); // apriori logical logical_iogeom = 0; #ifdef USE_REMOTE_QIO @@ -124,6 +128,11 @@ namespace QDP { setProgramProfileLevel(lev); } #endif + else if ( strcmp((*argv)[i],"-poolsize")==0) + { + sscanf((*argv)[++i], "%d", &pool_size_in_gb); + + } else if (strcmp((*argv)[i], "-geom")==0) { setGeomP = true; @@ -198,6 +207,8 @@ namespace QDP { QDP_info("Now initialize QMP"); #endif + + if (QMP_is_initialized() == QMP_FALSE) { QMP_thread_level_t prv; @@ -223,6 +234,7 @@ namespace QDP { QDP_info("Some layout init"); #endif + Layout::init(); // setup extremely basic functionality in Layout isInit = true; diff --git a/lib/qdp_parscalar_layout.cc b/lib/qdp_parscalar_layout.cc index b89efd099..9ea823335 100644 --- a/lib/qdp_parscalar_layout.cc +++ b/lib/qdp_parscalar_layout.cc @@ -15,7 +15,7 @@ #include "qdp.h" #include "qdp_util.h" - +#include "qdp_pool_allocator.h" #include "qmp.h" @@ -33,10 +33,13 @@ namespace QDP return s; } + size_t pool_size_in_gb = 8; + //----------------------------------------------------------------------------- namespace Layout { + //----------------------------------------------------- //! Local data specific to all architectures /*! @@ -363,9 +366,13 @@ namespace QDP QDP_error_exit("Layout::create - Layout problems, the layout functions do not work correctly with this lattice size"); } #endif + + Allocator::theQDPPoolAllocator::Instance().init(pool_size_in_gb); + // Initialize various defaults initDefaults(); + QDPIO::cout << "Finished lattice layout" << std::endl; #if QDP_DEBUG >= 2 diff --git a/lib/qdp_xmlio.cc b/lib/qdp_xmlio.cc index a7073c3c5..e010aec9b 100644 --- a/lib/qdp_xmlio.cc +++ b/lib/qdp_xmlio.cc @@ -349,7 +349,8 @@ namespace QDP for(int i=0; i < result.size(); i++) { // read the element. - list_stream2 >> result[i]; + list_stream2 >> dummy; + result[i]=dummy; } } From c9d60f1ac204dced30f1580a0e1a11036d8ff258 Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Sat, 3 Sep 2016 12:24:34 -0400 Subject: [PATCH 05/43] FIXED BUG: Nonreproducible Random numbers when more threads than sites in t_mesplq.cc --- include/qdp_dispatch.h | 35 +++++----- include/qdp_parscalar_specific.h | 108 ++++++++++++++++++++----------- 2 files changed, 90 insertions(+), 53 deletions(-) diff --git a/include/qdp_dispatch.h b/include/qdp_dispatch.h index 837f11793..dfdc10883 100644 --- a/include/qdp_dispatch.h +++ b/include/qdp_dispatch.h @@ -21,26 +21,27 @@ namespace QDP { template void dispatch_to_threads(int numSiteTable, Arg a, void (*func)(int,int,int, Arg*)){ - int threads_num; - int myId; - int low = 0; - int high = numSiteTable; - -#pragma omp parallel shared(numSiteTable, threads_num, a) private(myId, low, high) default(shared) + +#pragma omp parallel shared(numSiteTable, a) { - threads_num = omp_get_num_threads(); - myId = omp_get_thread_num(); - low = (numSiteTable*myId)/threads_num; - - // NB: high can never be too high since for the last thread - // myId + 1 = (threads_num - 1) + 1 = threads_num. - // So numSiteTable*(myId+1) will always be a strict multiple of threads_num - // and so truncation issues will not bite. - // I am addig in the parentheses tho to force the precedence - high =(numSiteTable*(myId+1))/threads_num; + int threads_num = omp_get_num_threads(); + int myId = omp_get_thread_num(); + + int active_threads_num = threads_num > numSiteTable ? numSiteTable : threads_num; + + if( myId < numSiteTable ) { + int low = (numSiteTable*myId)/active_threads_num; + + // NB: high can never be too high since for the last thread + // myId + 1 = (threads_num - 1) + 1 = threads_num. + // So numSiteTable*(myId+1) will always be a strict multiple of threads_num + // and so truncation issues will not bite. + // I am addig in the parentheses tho to force the precedence + int high =(numSiteTable*(myId+1))/active_threads_num; - func(low, high, myId, &a); + func(low, high, myId, &a); + } } } } diff --git a/include/qdp_parscalar_specific.h b/include/qdp_parscalar_specific.h index e5842f124..43adede2a 100644 --- a/include/qdp_parscalar_specific.h +++ b/include/qdp_parscalar_specific.h @@ -346,24 +346,25 @@ void evaluate(OLattice& dest, const Op& op, const QDPExpr >& prof.time -= getClockTime(); #endif +#if 0 int numSiteTable = s.numSiteTable(); u_arg a(dest, rhs, op, s.siteTable().slice()); dispatch_to_threads< u_arg >(numSiteTable, a, ev_userfunc); - +#else /////////////////// // Original code ////////////////// - - //const int *tab = s.siteTable().slice(); - //for(int j=0; j < s.numSiteTable(); ++j) - //{ - //int i = tab[j]; -// fprintf(stderr,"eval(olattice,oscalar): site %d\n",i); -// op(dest.elem(i), forEach(rhs, ElemLeaf(), OpCombine())); - //op(dest.elem(i), forEach(rhs, EvalLeaf1(0), OpCombine())); - //} + const int* tab = s.siteTable().slice(); + int numSiteTable = s.numSiteTable(); +#pragma omp parallel for + for(int j=0; j < numSiteTable; ++j) + { + int i = tab[j]; + op(dest.elem(i), forEach(rhs, EvalLeaf1(0), OpCombine())); + } +#endif #if defined(QDP_USE_PROFILING) prof.time += getClockTime(); @@ -390,25 +391,22 @@ void evaluate(OLattice& dest, const Op& op, const QDPExpr >& prof.time -= getClockTime(); #endif +#if 0 int numSiteTable = s.numSiteTable(); user_arg a(dest, rhs, op, s.siteTable().slice()); dispatch_to_threads< user_arg >(numSiteTable, a, evaluate_userfunc); - - //////////////////// - // Original code - /////////////////// - - // General form of loop structure - //const int *tab = s.siteTable().slice(); - //for(int j=0; j < s.numSiteTable(); ++j) - //{ - //int i = tab[j]; -// fprintf(stderr,"eval(olattice,olattice): site %d\n",i); - //op(dest.elem(i), forEach(rhs, EvalLeaf1(i), OpCombine())); - //} - +#else + const int *tab = s.siteTable().slice(); + const int numSiteTable = s.numSiteTable(); +#pragma omp parallel for + for(int j=0; j < numSiteTable; ++j) + { + int i = tab[j]; + op(dest.elem(i), forEach(rhs, EvalLeaf1(i), OpCombine())); + } +#endif #if defined(QDP_USE_PROFILING) prof.time += getClockTime(); prof.count++; @@ -467,8 +465,9 @@ void copymask(OSubLattice d, const OLattice& mask, const OLattice& s const Subset& s = d.subset(); const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); #pragma omp parallel for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; copymask(dest.elem(i), mask.elem(i), s1.elem(i)); @@ -519,13 +518,15 @@ void random(OLattice& d, const Subset& s) { const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); #pragma omp parallel { Seed seed; Seed skewed_seed; + #pragma omp for // need the barrier to avoid that RNG::ran_seed is changed too early! - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; seed = RNG::ran_seed; @@ -534,10 +535,13 @@ random(OLattice& d, const Subset& s) fill_random(d.elem(i), seed, skewed_seed, RNG::ran_mult_n); } + int myId = omp_get_thread_num(); + if( myId < nodeSites ) { #pragma omp critical (random) { RNG::ran_seed = seed; // The seed from any site is the same as the new global seed } + } } } @@ -572,8 +576,10 @@ void gaussian(OLattice& d, const Subset& s) random(r2,s); const int *tab = s.siteTable().slice(); -#pragma omp parallel for - for(int j=0; j < s.numSiteTable(); ++j) + const int nodeSites = s.numSiteTable(); + +// #pragma omp parallel for + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; fill_gaussian(d.elem(i), r1.elem(i), r2.elem(i)); @@ -610,9 +616,10 @@ inline void zero_rep(OLattice& dest, const Subset& s) { const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); #pragma omp parallel for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; zero_rep(dest.elem(i)); @@ -727,22 +734,27 @@ sum(const QDPExpr >& s1, const Subset& s) zero_rep(d.elem()); const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); #pragma omp parallel { typename UnaryReturn, FnSum>::Type_t dthread; zero_rep(dthread.elem()); -#pragma omp for nowait - for(int j=0; j < s.numSiteTable(); ++j) +#pragma omp for + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; dthread.elem() += forEach(s1, EvalLeaf1(i), OpCombine()); } + + int myId = omp_get_thread_num(); + if( myId < nodeSites ) { #pragma omp critical { d.elem() += dthread.elem(); } + } } // Do a global sum on the result @@ -787,10 +799,14 @@ sum(const QDPExpr >& s1) for(int i=0; i < nodeSites; ++i) dthread.elem() += forEach(s1, EvalLeaf1(i), OpCombine()); + + int myId = omp_get_thread_num(); + if( myId < nodeSites ) { #pragma omp critical { d.elem() += dthread.elem(); } + } } // Do a global sum on the result @@ -1046,6 +1062,7 @@ norm2(const multi1d< OLattice >& s1, const Subset& s) zero_rep(d.elem()); const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); for(int n=0; n < s1.size(); ++n) { @@ -1057,15 +1074,19 @@ norm2(const multi1d< OLattice >& s1, const Subset& s) zero_rep(dthread.elem()); #pragma omp for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; dthread.elem() += localNorm2(ss1.elem(i)); } + + int myId = omp_get_thread_num(); + if ( myId < nodeSites ) { #pragma omp critical { d.elem() += dthread.elem(); } + } } } @@ -1171,6 +1192,7 @@ innerProduct(const multi1d< OLattice >& s1, const multi1d< OLattice >& s zero_rep(d.elem()); const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); for(int n=0; n < s1.size(); ++n) { const OLattice& ss1 = s1[n]; @@ -1182,15 +1204,19 @@ innerProduct(const multi1d< OLattice >& s1, const multi1d< OLattice >& s zero_rep(dthread.elem()); #pragma omp for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; dthread.elem() += localInnerProduct(ss1.elem(i),ss2.elem(i)); } + + int myId = omp_get_thread_num(); + if( myId < nodeSites ) { #pragma omp critical { d.elem() += dthread.elem(); } + } } } @@ -1296,6 +1322,8 @@ innerProductReal(const multi1d< OLattice >& s1, const multi1d< OLattice zero_rep(d.elem()); const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); + for(int n=0; n < s1.size(); ++n) { const OLattice& ss1 = s1[n]; @@ -1307,15 +1335,19 @@ innerProductReal(const multi1d< OLattice >& s1, const multi1d< OLattice zero_rep(dthread.elem()); #pragma omp for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; dthread.elem() += localInnerProductReal(ss1.elem(i),ss2.elem(i)); } + + int myId = omp_get_thread_num(); + if( myId < nodeSites ) { #pragma omp critical { d.elem() += dthread.elem(); } + } } } @@ -1789,8 +1821,10 @@ inline void QDP_extract(multi1d >& dest, const OLattice& src, const Subset& s) { const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); + #pragma omp parallel for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; dest[i].elem() = src.elem(i); @@ -1809,8 +1843,10 @@ inline void QDP_insert(OLattice& dest, const multi1d >& src, const Subset& s) { const int *tab = s.siteTable().slice(); + const int nodeSites = s.numSiteTable(); + #pragma omp parallel for - for(int j=0; j < s.numSiteTable(); ++j) + for(int j=0; j < nodeSites; ++j) { int i = tab[j]; dest.elem(i) = src[i].elem(); From dd3b20b4b61a713ba5329849ec54fda61adbfe82 Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Sat, 3 Sep 2016 12:25:43 -0400 Subject: [PATCH 06/43] Reverted pool allocator to use tbb::fixed_pool for now Specify size of pool with -poolsize where poolsize is in GB E.g. -poolsize 12 means a pool of 12 GB --- include/qdp_pool_allocator.h | 7 +++--- lib/qdp_parscalar_init.cc | 1 + lib/qdp_pool_allocator.cc | 47 ++++++++++++++++++++---------------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/include/qdp_pool_allocator.h b/include/qdp_pool_allocator.h index ef4c44545..36dafaead 100644 --- a/include/qdp_pool_allocator.h +++ b/include/qdp_pool_allocator.h @@ -40,10 +40,9 @@ namespace QDP private: - -// size_t _PoolSize; - // unsigned char* _MyMem; - tbb::memory_pool< std::allocator > _LargePool; + size_t _PoolSize; + unsigned char* _MyMem; + tbb::fixed_pool* _LargePool; }; diff --git a/lib/qdp_parscalar_init.cc b/lib/qdp_parscalar_init.cc index bd4e7bce5..b36455e64 100644 --- a/lib/qdp_parscalar_init.cc +++ b/lib/qdp_parscalar_init.cc @@ -107,6 +107,7 @@ namespace QDP { rtinode); #endif + fprintf(stderr, " -poolsize Create a fixed pool of X GB for Pool Alloc\n"); fprintf(stderr, " -bind c:s Bind Threads -- BlueGene Q only, c cores per node and s SMT threads to run per core \n"); diff --git a/lib/qdp_pool_allocator.cc b/lib/qdp_pool_allocator.cc index 93673240e..8f83c26d8 100644 --- a/lib/qdp_pool_allocator.cc +++ b/lib/qdp_pool_allocator.cc @@ -8,6 +8,7 @@ #include "qdp_pool_allocator.h" #include #include +#include #include @@ -24,14 +25,11 @@ namespace Allocator { std::map theAllocMap; -#if 0 + QDPPoolAllocator::QDPPoolAllocator() : _PoolSize(0), _MyMem(nullptr), _LargePool(nullptr){} -#else - QDPPoolAllocator::QDPPoolAllocator() {} -#endif -#if 0 + QDPPoolAllocator::~QDPPoolAllocator() { if ( _LargePool ) delete _LargePool; if ( _MyMem ) { @@ -39,31 +37,38 @@ namespace Allocator { } _LargePool = nullptr; _MyMem = nullptr; - _PoolSize= 0; + _PoolSize = 0; } -#else - QDPPoolAllocator::~QDPPoolAllocator() {} -#endif - // Use extensible memory pool -- with large pages + void QDPPoolAllocator::init(size_t PoolSizeInGB) { -#if 0 - //QDPIO::cout << "Initializing TBB Pool Allocator" << std::endl; + + QDPIO::cout << "Initializing TBB Pool Allocator" << std::endl; if( _MyMem != nullptr ) { - //QDPIO::cout << "Allocator Already Inited. Aborting" << std::endl; + QDPIO::cout << "Allocator Already Inited. Aborting" << std::endl; QDP_abort(1); } theAllocMap.clear(); - ///QDPIO::cout << std::flush; + + QDPIO::cout << std::flush; _PoolSize = PoolSizeInGB*1024*1024*1024; - //QDPIO::cout << "Allocating " << PoolSizeInGB << " GB" << std::endl; - _MyMem = new unsigned char [ _PoolSize ]; - _LargePool = new tbb::fixed_pool((void *)_MyMem, - _PoolSize); -#endif + QDPIO::cout << "Allocating " << PoolSizeInGB << " GB" << std::endl; + + _MyMem = new (std::nothrow) unsigned char [ _PoolSize ]; + if ( _MyMem == nullptr) { + QDPIO::cout << "Unable to allocate " << _PoolSize <<" bytes" << std::endl; + QDPIO::cout << "Aborting" <malloc(BytesToAlloc)); unsigned char* Aligned = (unsigned char *) ( ( (unsigned long)Unaligned + (QDP_ALIGNMENT_SIZE-1) ) & ~(QDP_ALIGNMENT_SIZE - 1)); @@ -106,7 +111,7 @@ namespace Allocator { << " Unaligned =" << std::hex <<(unsigned long)d.Unaligned << std::endl; #endif - _LargePool.free(d.Unaligned); + _LargePool->free(d.Unaligned); #ifdef DEBUG_POOL_ALLOCATOR QDPIO::cout << "PoolAlloc::free: Erasing Addr from theAllocMap... "; From 73512acf720b60b35f45e26b48b9ffab297d7144 Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Thu, 8 Sep 2016 08:56:55 -0400 Subject: [PATCH 07/43] Threaded gaussian after fixing seed update for random and asked for THREAD_MULTIPLE from QMP. This may be overkill now as THREAD_FUNNELED may be enough --- include/qdp_parscalar_specific.h | 2 +- lib/qdp_parscalar_init.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qdp_parscalar_specific.h b/include/qdp_parscalar_specific.h index 43adede2a..2e6de9793 100644 --- a/include/qdp_parscalar_specific.h +++ b/include/qdp_parscalar_specific.h @@ -578,7 +578,7 @@ void gaussian(OLattice& d, const Subset& s) const int *tab = s.siteTable().slice(); const int nodeSites = s.numSiteTable(); -// #pragma omp parallel for +#pragma omp parallel for for(int j=0; j < nodeSites; ++j) { int i = tab[j]; diff --git a/lib/qdp_parscalar_init.cc b/lib/qdp_parscalar_init.cc index b36455e64..e75563209 100644 --- a/lib/qdp_parscalar_init.cc +++ b/lib/qdp_parscalar_init.cc @@ -213,7 +213,7 @@ namespace QDP { if (QMP_is_initialized() == QMP_FALSE) { QMP_thread_level_t prv; - if (QMP_init_msg_passing(argc, argv, QMP_THREAD_SINGLE, &prv) != QMP_SUCCESS) + if (QMP_init_msg_passing(argc, argv, QMP_THREAD_MULTIPLE, &prv) != QMP_SUCCESS) { QDPIO::cerr << __func__ << ": QMP_init_msg_passing failed" << std::endl; QDP_abort(1); From 851d3edb0d045ca11ebc8675552e7d9285b3a3eb Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Mon, 12 Sep 2016 16:24:39 -0400 Subject: [PATCH 08/43] Made Pool Allocator interface look and feel like the previous (default) allocator Can now switch between Pool/Default at configure time, by --enable-tbb-pool-allocator -poolsize argument can now take floating points e.g. 0.5 for 512M Ready for merge with devel --- configure.ac | 17 ++++++++++++++ include/Makefile.am | 7 ++++-- include/qdp_allocator.h | 24 ++++++++++++++++++++ include/qdp_config_internal.h.in | 6 +++++ include/qdp_default_allocator.h | 22 +++++------------- include/qdp_outer.h | 16 ++++++-------- include/qdp_outersubtype.h | 15 +++++-------- include/qdp_pool_allocator.h | 38 ++++++++++++++++++-------------- lib/Makefile.am | 8 +++++-- lib/qdp_default_allocator.cc | 6 ++++- lib/qdp_parscalar_init.cc | 4 ++-- lib/qdp_parscalar_layout.cc | 13 ++++++----- lib/qdp_pool_allocator.cc | 32 ++++++++++++++++++++++----- 13 files changed, 139 insertions(+), 69 deletions(-) diff --git a/configure.ac b/configure.ac index 249919ec5..503e63743 100755 --- a/configure.ac +++ b/configure.ac @@ -192,6 +192,12 @@ AC_ARG_ENABLE(bgq-thread-binding, [ ac_bgq_bind_enabled="no"] ) +AC_ARG_ENABLE(tbb-pool-allocator, + AC_HELP_STRING([--enable-tbb-pool-allocator], + [ Enable Threaded Building Blocks Fixed Pool Allocator]), + [ ac_enable_tbbpool=${enableval} ], + [ ac_enable_tbbpool="no" ] +) if test "X${ac_bgq_bind_enabled}X" = "XyesX"; then @@ -674,6 +680,14 @@ then AC_DEFINE([QDP_USE_OMP_THREADS], [1], [ Use OpenMP Threads ]) fi +dnl Threaded Building Blocks Pool Allocator +if test "X${ac_enable_tbbpool}X" == "XyesX"; +then + AC_MSG_NOTICE([Configuring to use TBB Fixed Pool. Please ensure CXXFLAGS and LDFLAGS are correctly set]) + AC_DEFINE([QDP_USE_TBBPOOL_ALLOCATOR],[1], [ Use TBB Fixed Pool Allocator ]) +fi + + dnl dnl dnl Now have all the options... Do some configuration @@ -703,6 +717,9 @@ AM_CONDITIONAL(BUILD_WILSON_EXAMPLES, AM_CONDITIONAL(BUILD_DEFAULT_ALLOCATOR, [test "X0X" = "X0X"]) +AM_CONDITIONAL(BUILD_QDPXX_TBB_ALLOCATOR, + [ test "X${ac_enable_tbbpool}X" == "XyesX" ]) + # # Conditional for use qmt # diff --git a/include/Makefile.am b/include/Makefile.am index a05ec4541..4be91cf93 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -129,8 +129,11 @@ BAGEL_HDRS = qdp_scalarsite_bagel_qdp.h \ # HEADERS for the memory allocator MEMORY_HDRS = qdp_allocator.h \ qdp_singleton.h \ - qdp_default_allocator.h \ - qdp_pool_allocator.h + qdp_default_allocator.h + +if BUILD_QDPXX_TBB_ALLOCATOR +MEMORY_HDRS += qdp_pool_allocator.h +endif # All the include files - avoid flattening of dirs by using nobase nobase_include_HEADERS = \ diff --git a/include/qdp_allocator.h b/include/qdp_allocator.h index 81c796c3e..67b4b9ea9 100644 --- a/include/qdp_allocator.h +++ b/include/qdp_allocator.h @@ -7,6 +7,8 @@ #ifndef QDP_ALLOCATOR #define QDP_ALLOCATOR +#include "qdp_config.h" +#include "qdp_singleton.h" /*! QDP Allocator * A raw memory allocator for QDP, for particular use * with OLattice Objects. The pointers returned by allocate @@ -64,8 +66,30 @@ namespace QDP } // namespace QDP + +// Now include the allocator.h-s and turn into singleton as approprite. +#ifdef QDP_USE_TBBPOOL_ALLOCATOR +#include "qdp_pool_allocator.h" +namespace QDP { + namespace Allocator { + using theQDPAllocator = SingletonHolder; + } +} +#else // Include the default specialisation #include "qdp_default_allocator.h" +namespace QDP { + namespace Allocator { + using theQDPAllocator = SingletonHolder; + } + } +#endif #endif diff --git a/include/qdp_config_internal.h.in b/include/qdp_config_internal.h.in index c88fc9c2e..c09d15746 100644 --- a/include/qdp_config_internal.h.in +++ b/include/qdp_config_internal.h.in @@ -48,6 +48,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION @@ -114,5 +117,8 @@ /* Enable SSE3 instructions */ #undef QDP_USE_SSE3 +/* Use TBB Fixed Pool Allocator */ +#undef QDP_USE_TBBPOOL_ALLOCATOR + /* Version number of package */ #undef VERSION diff --git a/include/qdp_default_allocator.h b/include/qdp_default_allocator.h index 0250961f7..f2666ffdb 100644 --- a/include/qdp_default_allocator.h +++ b/include/qdp_default_allocator.h @@ -10,7 +10,7 @@ #include "qdp_allocator.h" #include "qdp_stdio.h" -#include "qdp_singleton.h" + #include #include @@ -32,12 +32,14 @@ namespace QDP // the singleton CreateUsingNew policy which is a "friend" // I don't like friends but this follows Alexandrescu's advice // on p154 of Modern C++ Design (A. Alexandrescu) - QDPDefaultAllocator() {init();} + QDPDefaultAllocator() {} ~QDPDefaultAllocator() {} friend class QDP::CreateUsingNew; public: + void init(size_t PoolSizeinMB); + // Pusher void pushFunc(const char* func, int line); @@ -58,22 +60,10 @@ namespace QDP void dump(); - protected: - void init(); + + }; - // Turn into a Singleton. Create with CreateUsingNew - // Has NoDestroy lifetime, as it may be needed for - // the destruction policy is No Destroy, so the - // Singleton is not cleaned up on exit. This is so - // that static objects can refer to it with confidence - // in their own destruction, not having to worry that - // atexit() may have destroyed the allocator before - // the static objects need to feed memory. - typedef SingletonHolder theQDPAllocator; } // namespace Allocator } // namespace QDP diff --git a/include/qdp_outer.h b/include/qdp_outer.h index 3c0973bca..e9ad9fdea 100644 --- a/include/qdp_outer.h +++ b/include/qdp_outer.h @@ -5,7 +5,7 @@ #include "qdp_config.h" #include "qdp_allocator.h" -#include "qdp_pool_allocator.h" + /*! \file * \brief Outer grid classes */ @@ -416,13 +416,11 @@ class OLattice: public QDPType > size_t NSites = static_cast(Layout::sitesOnNode()); try { - //F=(T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*Layout::sitesOnNode(),QDP::Allocator::DEFAULT); - F=(T*)QDP::Allocator::theQDPPoolAllocator::Instance().alloc(sizeof(T)*NSites); + F=(T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*NSites,QDP::Allocator::DEFAULT); } - catch(std::bad_alloc) - { - QDPIO::cerr << "Allocation failed in OLattice alloc_mem" << std::endl; -// QDP::Allocator::theQDPAllocator::Instance().dump(); + catch(std::bad_alloc) { + QDPIO::cerr << "Allocation failed in OLattice alloc_mem" << std::endl; + QDP::Allocator::theQDPAllocator::Instance().dump(); QDP_abort(1); } @@ -443,8 +441,8 @@ class OLattice: public QDPType > if (!mem) return; if( F != nullptr ) { - // QDP::Allocator::theQDPAllocator::Instance().free(F); - QDP::Allocator::theQDPPoolAllocator::Instance().free(F); + QDP::Allocator::theQDPAllocator::Instance().free(F); + } mem = false; F = nullptr; diff --git a/include/qdp_outersubtype.h b/include/qdp_outersubtype.h index 45414e2b0..c3d5e6be0 100644 --- a/include/qdp_outersubtype.h +++ b/include/qdp_outersubtype.h @@ -7,7 +7,7 @@ #ifndef QDP_OUTERSUBTYPE_H #define QDP_OUTERSUBTYPE_H -#include "qdp_pool_allocator.h" +#include "qdp_allocator.h" namespace QDP { //! OScalar class narrowed to a subset @@ -143,15 +143,13 @@ class OSubLattice: public QDPSubType > //QDP_info("OSubLattice alloc for %d sites",s->numSiteTable()); try { - //F = (T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*s->numSiteTable(),QDP::Allocator::DEFAULT); - - F = (T*)QDP::Allocator::theQDPPoolAllocator::Instance().alloc(sizeof(T)*s->numSiteTable()); + F = (T*)QDP::Allocator::theQDPAllocator::Instance().allocate(sizeof(T)*s->numSiteTable(),QDP::Allocator::DEFAULT); } catch(std::bad_alloc) { - QDPIO::cerr << "Allocation failed in OSubLattice" << std::endl; - //QDP::Allocator::theQDPAllocator::Instance().dump(); - QDP_abort(1); + QDPIO::cerr << "Allocation failed in OSubLattice" << std::endl; + QDP::Allocator::theQDPAllocator::Instance().dump(); + QDP_abort(1); } } @@ -162,8 +160,7 @@ class OSubLattice: public QDPSubType > } void free_mem() { - // QDP::Allocator::theQDPAllocator::Instance().free(F); - QDP::Allocator::theQDPPoolAllocator::Instance().free(F); + QDP::Allocator::theQDPAllocator::Instance().free(F); } #endif diff --git a/include/qdp_pool_allocator.h b/include/qdp_pool_allocator.h index 36dafaead..3df00fefc 100644 --- a/include/qdp_pool_allocator.h +++ b/include/qdp_pool_allocator.h @@ -28,16 +28,32 @@ namespace QDP // Quick and Dirty Pool ALlocator class QDPPoolAllocator { - public: - QDPPoolAllocator(void); + private: + // Disallow Copies + QDPPoolAllocator(const QDPPoolAllocator& c) {} - ~QDPPoolAllocator(); + // Disallow assignments (copies by another name) + void operator=(const QDPPoolAllocator& c) {} - void init(size_t PoolSizeInGB); + // Disallow creation / destruction by anyone except + // the singleton CreateUsingNew policy which is a "friend" + // I don't like friends but this follows Alexandrescu's advice + // on p154 of Modern C++ Design (A. Alexandrescu) + QDPPoolAllocator(void); + ~QDPPoolAllocator(); + friend class QDP::CreateUsingNew; + public: + // Init -- has to + void init(size_t PoolSizeInMB); - void* alloc(size_t size); + void* allocate(size_t n_bytes, const MemoryPoolHint& mem_pool_hint); void free(void *mem); + // Memory debugging Interface + void pushFunc(const char *func, int line); + void popFunc(void); + void dump(); + private: size_t _PoolSize; @@ -48,18 +64,6 @@ namespace QDP - // Turn into a Singleton. Create with CreateUsingNew - // Has NoDestroy lifetime, as it may be needed for - // the destruction policy is No Destroy, so the - // Singleton is not cleaned up on exit. This is so - // that static objects can refer to it with confidence - // in their own destruction, not having to worry that - // atexit() may have destroyed the allocator before - // the static objects need to feed memory. - typedef SingletonHolder theQDPPoolAllocator; } // namespace Allocator } // namespace QDP diff --git a/lib/Makefile.am b/lib/Makefile.am index 6b62f433a..a30930d4f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -88,8 +88,12 @@ libqdp_a_SOURCES += qdp_scalarvecsite_sse.cc endif if BUILD_DEFAULT_ALLOCATOR -libqdp_a_SOURCES += qdp_default_allocator.cc qdp_pool_allocator.cc -endif +libqdp_a_SOURCES += qdp_default_allocator.cc +endif + +if BUILD_QDPXX_TBB_ALLOCATOR +libqdp_a_SOURCES += qdp_pool_allocator.h +endif if BUILD_BGQ_THREADBIND libqdp_a_SOURCES += qdp_bgq_threadbind.cc diff --git a/lib/qdp_default_allocator.cc b/lib/qdp_default_allocator.cc index 7b4fe470d..e5787e6b0 100644 --- a/lib/qdp_default_allocator.cc +++ b/lib/qdp_default_allocator.cc @@ -8,6 +8,7 @@ #include #endif +#include "qdp_default_allocator.h" namespace QDP { namespace Allocator { @@ -219,7 +220,10 @@ namespace Allocator { // Init void - QDPDefaultAllocator::init() {} + QDPDefaultAllocator::init(size_t PoolSizeInMB ) { + QDPIO::cout << "Initializing QDPDefaultAllocator." << std::endl; + + } #endif diff --git a/lib/qdp_parscalar_init.cc b/lib/qdp_parscalar_init.cc index e75563209..d8b520fd9 100644 --- a/lib/qdp_parscalar_init.cc +++ b/lib/qdp_parscalar_init.cc @@ -34,7 +34,7 @@ namespace QDP { static int n_cores = -1; static int n_threads_per_core = -1; - extern size_t pool_size_in_gb; + extern float pool_size_in_gb; //! Turn on the machine void QDP_initialize(int *argc, char ***argv) @@ -131,7 +131,7 @@ namespace QDP { #endif else if ( strcmp((*argv)[i],"-poolsize")==0) { - sscanf((*argv)[++i], "%d", &pool_size_in_gb); + sscanf((*argv)[++i], "%f", &pool_size_in_gb); } else if (strcmp((*argv)[i], "-geom")==0) diff --git a/lib/qdp_parscalar_layout.cc b/lib/qdp_parscalar_layout.cc index 9ea823335..169c1ba44 100644 --- a/lib/qdp_parscalar_layout.cc +++ b/lib/qdp_parscalar_layout.cc @@ -15,15 +15,14 @@ #include "qdp.h" #include "qdp_util.h" -#include "qdp_pool_allocator.h" +#include "qdp_allocator.h" #include "qmp.h" namespace QDP { - //----------------------------------------------------------------------------- - // IO routine solely for debugging. Only defined here + //----------------------------------Only defined here template std::ostream& operator<<(std::ostream& s, const multi1d& s1) { @@ -33,7 +32,8 @@ namespace QDP return s; } - size_t pool_size_in_gb = 8; + // Only relevant in case of pool allocator. + float pool_size_in_gb = 8.0; //----------------------------------------------------------------------------- @@ -367,7 +367,10 @@ namespace QDP } #endif - Allocator::theQDPPoolAllocator::Instance().init(pool_size_in_gb); + + size_t pool_size_in_MB = static_cast(floor(pool_size_in_gb*1024.0)); + + Allocator::theQDPAllocator::Instance().init(pool_size_in_MB); // Initialize various defaults initDefaults(); diff --git a/lib/qdp_pool_allocator.cc b/lib/qdp_pool_allocator.cc index 8f83c26d8..57071cde4 100644 --- a/lib/qdp_pool_allocator.cc +++ b/lib/qdp_pool_allocator.cc @@ -23,7 +23,9 @@ namespace Allocator { unsigned char* Unaligned; }; - std::map theAllocMap; + using MapT = std::map; + + MapT theAllocMap; QDPPoolAllocator::QDPPoolAllocator() : _PoolSize(0), @@ -41,7 +43,7 @@ namespace Allocator { } void - QDPPoolAllocator::init(size_t PoolSizeInGB) + QDPPoolAllocator::init(size_t PoolSizeInMB) { QDPIO::cout << "Initializing TBB Pool Allocator" << std::endl; @@ -52,9 +54,9 @@ namespace Allocator { theAllocMap.clear(); QDPIO::cout << std::flush; - _PoolSize = PoolSizeInGB*1024*1024*1024; + _PoolSize = PoolSizeInMB*1024*1024; - QDPIO::cout << "Allocating " << PoolSizeInGB << " GB" << std::endl; + QDPIO::cout << "Intializing TBB Fixed Pool Allocator: Allocating " << PoolSizeInMB << " MB" << std::endl; _MyMem = new (std::nothrow) unsigned char [ _PoolSize ]; if ( _MyMem == nullptr) { @@ -72,10 +74,11 @@ namespace Allocator { } void* - QDPPoolAllocator::alloc(size_t Size) + QDPPoolAllocator::allocate(size_t n_bytes, + const MemoryPoolHint& mem_pool_hint=DEFAULT) { size_t BytesToAlloc; - BytesToAlloc = Size; + BytesToAlloc = n_bytes; BytesToAlloc += QDP_ALIGNMENT_SIZE; @@ -129,5 +132,22 @@ namespace Allocator { QDP_abort(1); } } + + void QDPPoolAllocator::pushFunc(const char * func,int line) {} + void QDPPoolAllocator::popFunc(void) {} + void QDPPoolAllocator::dump(void) + { + if ( Layout::primaryNode() ) { + + QDPIO::cout << "Dumping memory map" << std::endl; + for( auto j = theAllocMap.begin(); j != theAllocMap.end(); j++) { + const unsigned long unaligned = (unsigned long)((*j).first); + const MemInfo& mem = (*j).second; + + printf("mem= 0x%lx unaligned= 0x%lx size=%d\n", (unsigned long)unaligned, + (unsigned long)mem.Unaligned, mem.Size); + } + } + } } // namespace Allocator } // namespace QDP From 177bbda68d49516f884eefbd6c044383b0704b9d Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Tue, 13 Sep 2016 12:18:07 -0400 Subject: [PATCH 09/43] FIxed a typo, which prevented the qdp_pool_allocator.o file to the AR --- lib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index a30930d4f..a95bca5a6 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -92,7 +92,7 @@ libqdp_a_SOURCES += qdp_default_allocator.cc endif if BUILD_QDPXX_TBB_ALLOCATOR -libqdp_a_SOURCES += qdp_pool_allocator.h +libqdp_a_SOURCES += qdp_pool_allocator.cc endif if BUILD_BGQ_THREADBIND From 4fe74edd788f9e78a5b2e15f6263f9daf9038b5c Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Wed, 14 Sep 2016 10:29:09 -0400 Subject: [PATCH 10/43] Addeed internal.h.in file with new options. Leaving Makefile.in and configure out of it --- include/qdp_config_internal.h.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/qdp_config_internal.h.in b/include/qdp_config_internal.h.in index c09d15746..c395b40db 100644 --- a/include/qdp_config_internal.h.in +++ b/include/qdp_config_internal.h.in @@ -48,9 +48,6 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME -/* Define to the home page for this package. */ -#undef PACKAGE_URL - /* Define to the version of this package. */ #undef PACKAGE_VERSION From 181206ae89d5278712cc4db8c429758e9c69f786 Mon Sep 17 00:00:00 2001 From: Balint Joo Date: Wed, 2 Nov 2016 11:51:02 -0400 Subject: [PATCH 11/43] Added NumSpins<> and NumColors templates to qdp_qdpio.h - this fixes Incorrect Ns when writing staggered types - also added USQCD_F/D3_ColorVector type string for staggered fermions Moved xmmintrin.h outside of the QDP namespace for a bunch of files (this should fix build issues with GCC-6 on my Mac) --- include/qdp_qdpio.h | 173 +++++++++++++++++- include/qdp_traits.h | 3 + .../sse_blas_local_sumsq_double.h | 2 - lib/qdp_qio_strings.cc | 6 + .../sse_blas_local_sumsq_double.cc | 4 +- .../sse_blas_local_vcdot_double.cc | 4 +- .../sse_blas_vaxmbyz4_double.cc | 4 +- lib/scalarsite_sse/sse_blas_vaxmyz4_double.cc | 4 +- .../sse_blas_vaxpbyz4_double.cc | 4 +- lib/scalarsite_sse/sse_blas_vaxpy4_double.cc | 4 +- lib/scalarsite_sse/sse_blas_vaypx4_double.cc | 2 +- lib/scalarsite_sse/sse_blas_vscal4_double.cc | 2 +- .../sse_linalg_m_eq_hh_double.cc | 2 +- .../sse_linalg_m_eq_hm_double.cc | 4 +- .../sse_linalg_m_eq_mh_double.cc | 4 +- .../sse_linalg_m_eq_mm_double.cc | 4 +- .../sse_linalg_m_eq_scal_m_double.cc | 4 +- .../sse_linalg_m_peq_m_double.cc | 2 +- 18 files changed, 198 insertions(+), 34 deletions(-) diff --git a/include/qdp_qdpio.h b/include/qdp_qdpio.h index 58f87cfcb..3a5eb4196 100644 --- a/include/qdp_qdpio.h +++ b/include/qdp_qdpio.h @@ -10,6 +10,7 @@ #include "qio.h" #include #include "qdp_defs.h" +#include "qdp_traits.h" #include namespace QDP @@ -144,8 +145,166 @@ namespace QDP template<> char* QIOStringTraits< multi1d >::tname; + template<> + char* QIOStringTraits< LatticeStaggeredFermionF3 >::tname; + + template<> + char *QIOStringTraits< LatticeStaggeredFermionD3 >::tname; + + + // Generic version of the template + // Declares a static value + template + struct NumSpins { + static int value; + }; + + // Not definint the static value + + // RScalar and RComplex are my 'base cases' + // Assuming they are nested within the Spin in terms of templates + template + struct NumSpins< RScalar > { + static int value; + }; + + template + int NumSpins >::value = 1; + + + template + struct NumSpins< RComplex > { + static int value; + }; + + template + int NumSpins >::value = 1; + + + // Things with spin structure cause early termination of the + // recursion + template + struct NumSpins< PSpinVector > { + static int value; + }; + + template + int NumSpins< PSpinVector >::value = N; + + template + struct NumSpins< PSpinMatrix > { + static int value; + }; + + template + int NumSpins< PSpinMatrix >::value = N; + + // PColor has the same template signature as PSpin + // So I have to specialize them too or we barf later on. + // with undefined symbols + template + struct NumSpins< PColorVector > { + static int value; + }; + + template + int NumSpins< PColorVector >::value = NumSpins::value; + + template + struct NumSpins< PColorMatrix > { + static int value; + }; + + template + int NumSpins< PColorMatrix >::value = NumSpins::value; + + // Generic recursion + template