1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

Begginings of slice summation and subblocking

This commit is contained in:
Peter Boyle 2015-04-23 11:04:59 +01:00
parent 7007d6a176
commit 4d2198ea56
6 changed files with 88 additions and 43 deletions

4
TODO
View File

@ -10,7 +10,7 @@ FUNCTIONALITY:
* How to do U[mu] ... lorentz part of type structure or not. more like chroma if not. -- DONE * How to do U[mu] ... lorentz part of type structure or not. more like chroma if not. -- DONE
* subdirs lib, tests ?? ----- DONE * subdirs lib, tests ?? ----- DONE
- lib/math - lib/math
- lib/cartesian - lib/cartesian
- lib/cshift - lib/cshift
- lib/stencil - lib/stencil
@ -26,7 +26,7 @@ FUNCTIONALITY:
Not done, or just incomplete Not done, or just incomplete
* random number generation * random number generation
* Consider switch std::vector to boost arrays. * Consider switch std::vector to boost arrays or something lighter weight
boost::multi_array<type, 3> A()... to replace multi1d, multi2d etc.. boost::multi_array<type, 3> A()... to replace multi1d, multi2d etc..
* How to define simple matrix operations, such as flavour matrices? * How to define simple matrix operations, such as flavour matrices?

46
configure vendored
View File

@ -1365,8 +1365,9 @@ Optional Features:
--disable-dependency-tracking --disable-dependency-tracking
speeds up one-time build speeds up one-time build
--disable-openmp do not use OpenMP --disable-openmp do not use OpenMP
--enable-simd=SSE|AVX|AVX2|AVX512 --enable-simd=SSE|AVX|AVX2|AVX512|MIC
Select instructions Select instructions to be SSE4.0, AVX 1.0, AVX
2.0+FMA, AVX 512, MIC
--enable-comms=none|mpi Select communications --enable-comms=none|mpi Select communications
Some influential environment variables: Some influential environment variables:
@ -4945,6 +4946,18 @@ fi
done done
for ac_header in endian.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "endian.h" "ac_cv_header_endian_h" "$ac_includes_default"
if test "x$ac_cv_header_endian_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_ENDIAN_H 1
_ACEOF
fi
done
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
@ -4999,32 +5012,11 @@ _ACEOF
fi fi
done done
for ac_func in ntohll
do :
ac_fn_c_check_func "$LINENO" "ntohll" "ac_cv_func_ntohll"
if test "x$ac_cv_func_ntohll" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NTOHLL 1
_ACEOF
fi
done
for ac_func in be64toh
do :
ac_fn_c_check_func "$LINENO" "be64toh" "ac_cv_func_be64toh"
if test "x$ac_cv_func_be64toh" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_BE64TOH 1
_ACEOF
fi
done
# Check whether --enable-simd was given. # Check whether --enable-simd was given.
if test "${enable_simd+set}" = set; then : if test "${enable_simd+set}" = set; then :
enableval=$enable_simd; ac_SIMD=${enable_simd} enableval=$enable_simd; \
ac_SIMD=${enable_simd}
else else
ac_SIMD=AVX2 ac_SIMD=AVX2
fi fi
@ -5049,8 +5041,8 @@ $as_echo "#define AVX1 1" >>confdefs.h
$as_echo "#define AVX2 1" >>confdefs.h $as_echo "#define AVX2 1" >>confdefs.h
;; ;;
AVX512) AVX512|MIC)
echo Configuring for AVX512 echo Configuring for AVX512 and MIC
$as_echo "#define AVX512 1" >>confdefs.h $as_echo "#define AVX512 1" >>confdefs.h

View File

@ -16,8 +16,8 @@
/* GRID_COMMS_NONE */ /* GRID_COMMS_NONE */
/* #undef GRID_COMMS_NONE */ /* #undef GRID_COMMS_NONE */
/* Define to 1 if you have the `be64toh' function. */ /* Define to 1 if you have the <endian.h> header file. */
/* #undef HAVE_BE64TOH */ /* #undef HAVE_ENDIAN_H */
/* Define to 1 if you have the `gettimeofday' function. */ /* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1 #define HAVE_GETTIMEOFDAY 1
@ -34,9 +34,6 @@
/* Define to 1 if you have the <memory.h> header file. */ /* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1 #define HAVE_MEMORY_H 1
/* Define to 1 if you have the `ntohll' function. */
/* #undef HAVE_NTOHLL */
/* Define to 1 if you have the <stdint.h> header file. */ /* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1

View File

@ -15,8 +15,8 @@
/* GRID_COMMS_NONE */ /* GRID_COMMS_NONE */
#undef GRID_COMMS_NONE #undef GRID_COMMS_NONE
/* Define to 1 if you have the `be64toh' function. */ /* Define to 1 if you have the <endian.h> header file. */
#undef HAVE_BE64TOH #undef HAVE_ENDIAN_H
/* Define to 1 if you have the `gettimeofday' function. */ /* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY #undef HAVE_GETTIMEOFDAY
@ -33,9 +33,6 @@
/* Define to 1 if you have the <memory.h> header file. */ /* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H #undef HAVE_MEMORY_H
/* Define to 1 if you have the `ntohll' function. */
#undef HAVE_NTOHLL
/* Define to 1 if you have the <stdint.h> header file. */ /* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H #undef HAVE_STDINT_H

View File

@ -283,7 +283,7 @@ namespace Grid {
if ( comm_any ) { if ( comm_any ) {
for(int i=0;i<Nsimd;i++){ for(int i=0;i<Nsimd;i++){
pointers[i] = (scalar_type *)&send_buf_extract[i][0]; pointers[Nsimd-1-i] = (scalar_type *)&send_buf_extract[i][0];
} }
Gather_plane_extract(rhs,pointers,dimension,sx,cbmask); Gather_plane_extract(rhs,pointers,dimension,sx,cbmask);
@ -332,9 +332,9 @@ namespace Grid {
for(int i=0;i<Nsimd;i++){ for(int i=0;i<Nsimd;i++){
if ( permute_slice ) { if ( permute_slice ) {
PermuteMap=i^toggle_bit; PermuteMap=i^toggle_bit;
pointers[i] = rpointers[PermuteMap]; pointers[Nsimd-1-i] = rpointers[PermuteMap];
} else { } else {
pointers[i] = rpointers[i]; pointers[Nsimd-1-i] = rpointers[i];
} }
} }

View File

@ -1,12 +1,71 @@
#ifndef GRID_SUMMATION_H #ifndef GRID_SUMMATION_H
#define GRID_SUMMATION_H #define GRID_SUMMATION_H
void subdivides(GridBase *coarse,GridBase *fine)
{
assert(coarse->_ndimension == fine->_ndimension);
int _ndimension = coarse->_ndimension;
// local and global volumes subdivide cleanly after SIMDization
for(int d=0;d<_ndimension;d++){
assert((fine->_rdimensions[d] / coarse->_rdimensions[d])* coarse->_rdimensions[d]==fine->_rdimensions[d]);
assert((fine->_ldimensions[d] / coarse->_ldimensions[d])* coarse->_ldimensions[d]==fine->_ldimensions[d]);
assert((fine->_gdimensions[d] / coarse->_gdimensions[d])* coarse->_gdimensions[d]==fine->_gdimensions[d]);
assert((fine->_fdimensions[d] / coarse->_fdimensions[d])* coarse->_fdimensions[d]==fine->_fdimensions[d]);
}
}
// Generic name : Coarsen?
// : SubMeshSum?
//
template<class vobj> template<class vobj>
inline void sumBlocks(Lattice<vobj> &coarseData,const Lattice<vobj &fineData) inline void sumBlocks(Lattice<vobj> &coarseData,const Lattice<vobj> &fineData)
{ {
GridBase * fine = findData._grid; GridBase * fine = findData._grid;
GridBase * coarse= findData._grid; GridBase * coarse= findData._grid;
subdivides(coars,fine); // require they map
int _ndimension = coarse->_ndimension;
std::vector<bool> replicated(_ndimension,false);
std::vector<int> block_r (_dimension);
std::vector<int> block_f (_dimension);
///////////////////////////////////////////////////////////
// Detect whether the result is replicated in dimension d
///////////////////////////////////////////////////////////
for(int d=0 ; d<_ndimension;d++){
if ( (_fdimensions[d] == 1) && (coarse->_processors[d]>1) ) {
replicated[d]=true;
}
block_r[d] = fine->_rdimensions[d] / coarse->_rdimensions[d];
block_l[d] = fine->_ldimensions[d] / coarse->_ldimensions[d];
block_f[d] = fine->_fdimensions[d] / coarse->_fdimensions[d];
}
coaseData=zero;
//FIXME Bagel's strategy: loop over fine sites
// identify corresponding coarse site, but coarse sites are
// divided across threads. Not so easy to do in openmp but
// there must be a way
for(int sf=0;sf<fine->oSites();sf++){
int sc;
vobj sum=zero;
std::vector<int> coor_c(_ndimension);
std::vector<int> coor_f(_ndimension);
GridBase::CoorFromIndex(coor_f,sf,fine->_rdimensions);
for(int d=0;d<_ndimension;d++) coor_c[d]=coor_f[d]/fine->_rdimensions;
GridBase::IndexFromCoor(coor_c,sc,coarse->_rdimensions);
coarseData._odata[sc]=coarseData._odata[sc]+fineData._odata[sf];
}
return; return;
} }
#endif #endif