/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: Hadrons/A2AMatrix.hpp Copyright (C) 2015-2018 Author: Antonin Portelli Author: Peter Boyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #ifndef A2A_Matrix_hpp_ #define A2A_Matrix_hpp_ #include #include #include #ifdef USE_MKL #include "mkl.h" #include "mkl_cblas.h" #endif #ifndef HADRONS_A2AM_NAME #define HADRONS_A2AM_NAME "a2aMatrix" #endif #ifndef HADRONS_A2AM_IO_TYPE #define HADRONS_A2AM_IO_TYPE ComplexF #endif #define HADRONS_A2AM_PARALLEL_IO BEGIN_HADRONS_NAMESPACE // general A2A matrix set based on Eigen tensors and Grid-allocated memory // Dimensions: // 0 - ext - external field (momentum, EM field, ...) // 1 - str - spin-color structure // 2 - t - timeslice // 3 - i - left A2A mode index // 4 - j - right A2A mode index template using A2AMatrixSet = Eigen::TensorMap>; template using A2AMatrix = Eigen::Matrix; template using A2AMatrixTr = Eigen::Matrix; /****************************************************************************** * Abstract class for A2A kernels * ******************************************************************************/ template class A2AKernel { public: A2AKernel(void) = default; virtual ~A2AKernel(void) = default; virtual void operator()(A2AMatrixSet &m, const Field *left, const Field *right, const unsigned int orthogDim, double &time) = 0; virtual double flops(const unsigned int blockSizei, const unsigned int blockSizej) = 0; virtual double bytes(const unsigned int blockSizei, const unsigned int blockSizej) = 0; }; /****************************************************************************** * Class to handle A2A matrix block HDF5 I/O * ******************************************************************************/ template class A2AMatrixIo { public: // constructors A2AMatrixIo(void) = default; A2AMatrixIo(std::string filename, std::string dataname, const unsigned int nt, const unsigned int ni = 0, const unsigned int nj = 0); // destructor ~A2AMatrixIo(void) = default; // access unsigned int getNi(void) const; unsigned int getNj(void) const; unsigned int getNt(void) const; size_t getSize(void) const; // file allocation template void initFile(const MetadataType &d, const unsigned int chunkSize); // block I/O void saveBlock(const T *data, const unsigned int i, const unsigned int j, const unsigned int blockSizei, const unsigned int blockSizej); void saveBlock(const A2AMatrixSet &m, const unsigned int ext, const unsigned int str, const unsigned int i, const unsigned int j); template