37template <
class Impl,
int Ndim>
47 const unsigned int N = Impl::Group::Dimension;
49 typedef typename Field::vector_object
vobj;
60 for (
int mu = 0; mu < Ndim; mu++)
71 std::stringstream sstream;
84 assert(p.Grid()->Nd() == Ndim);
87 Field action(p.Grid()), pshift(p.Grid()), phisquared(p.Grid());
89 action = (2.0 * Ndim +
mass_square) * phisquared -
lambda * phisquared * phisquared;
94 for (
int mu = 0; mu < Ndim; mu++)
102 const vobj *temp, *t_p;
104 SE = phiStencil.GetEntry(permute_type, mu, i);
108 temp = &p_v[SE->_offset];
110 permute(temp2, *temp, permute_type);
111 action_v[i] -= temp2 * (*t_p) + (*t_p) * temp2;
113 action_v[i] -= (*temp) * (*t_p) + (*t_p) * (*temp);
118 action_v[i] -= phiStencil.CommBuf()[SE->_offset] * (*t_p) + (*t_p) * phiStencil.CommBuf()[SE->_offset];
128 virtual void deriv(
const Field &p, Field &force)
131 assert(p.Grid()->Nd() == Ndim);
146 for (
int point = 0; point <
npoint; point++)
158 SE = phiStencil.GetEntry(permute_type, point, i);
162 temp = &p_v[SE->_offset];
166 permute(temp2, *temp, permute_type);
172 force_v[i] -= phiStencil.CommBuf()[SE->_offset];
179 double total_time = (t1 - t0) / 1e6;
180 double interm_time = (interm_t - t0) / 1e6;
181 double halo_time = (halo_t - interm_t) / 1e6;
182 double stencil_time = (t1 - halo_t) / 1e6;
183 std::cout <<
GridLogIntegrator <<
"Total time for force computation (s) : " << total_time << std::endl;
184 std::cout <<
GridLogIntegrator <<
"Intermediate time for force computation (s): " << interm_time << std::endl;
185 std::cout <<
GridLogIntegrator <<
"Halo time in force computation (s) : " << halo_time << std::endl;
186 std::cout <<
GridLogIntegrator <<
"Stencil time in force computation (s) : " << stencil_time << std::endl;
187 double flops = p.Grid()->gSites() * (14 * N * N * N + 18 * N * N + 2);
188 double flops_no_stencil = p.Grid()->gSites() * (14 * N * N * N + 6 * N * N + 2);
189 double Gflops = flops / (total_time * 1e9);
190 double Gflops_no_stencil = flops_no_stencil / (interm_time * 1e9);
191 std::cout <<
GridLogIntegrator <<
"Flops: " << flops <<
" - Gflop/s : " << Gflops << std::endl;
192 std::cout <<
GridLogIntegrator <<
"Flops NS: " << flops_no_stencil <<
" - Gflop/s NS: " << Gflops_no_stencil << std::endl;
accelerator_inline Grid_simd2< S, V > trace(const Grid_simd2< S, V > &arg)
Lattice< vobj > real(const Lattice< vobj > &lhs)
vobj::scalar_object sum(const vobj *arg, Integer osites)
#define autoView(l_v, l, mode)
GridLogger GridLogIntegrator(1, "Integrator", GridLogColours, "BLUE")
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
SimpleCompressorGather< vobj, FaceGatherSimple > SimpleCompressor
accelerator_inline std::enable_if<!isGridTensor< T >::value, T >::type TensorRemove(T arg)
#define thread_for(i, num,...)
static INTERNAL_PRECISION U
Base class for all actions.
void HaloExchange(const Lattice< vobj > &source, compressor &compress)
ScalarInteractionAction(RealD ms, RealD l, RealD gval)
SimpleCompressor< vobj > compressor
CartesianStencil< vobj, vobj, DefaultImplParams > Stencil
std::vector< int > displacements
virtual std::string LogParameters()
Print the parameters of the action.
virtual void refresh(const Field &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
Field::vector_object vobj
virtual void deriv(const Field &p, Field &force)
std::vector< int > directions
virtual RealD S(const Field &p)
INHERIT_FIELD_TYPES(Impl)
virtual std::string action_name()
Report the name of the action.