diff --git a/cmake/Modules/Packages/INTEL.cmake b/cmake/Modules/Packages/INTEL.cmake index ce8455e542..006a23e7ac 100644 --- a/cmake/Modules/Packages/INTEL.cmake +++ b/cmake/Modules/Packages/INTEL.cmake @@ -112,9 +112,5 @@ if(PKG_KSPACE) RegisterIntegrateStyle(${INTEL_SOURCES_DIR}/verlet_lrt_intel.h) endif() -if(PKG_ELECTRODE) - list(APPEND INTEL_SOURCES ${INTEL_SOURCES_DIR}/electrode_accel_intel.cpp) -endif() - target_sources(lammps PRIVATE ${INTEL_SOURCES}) target_include_directories(lammps PRIVATE ${INTEL_SOURCES_DIR}) diff --git a/src/ELECTRODE/electrode_accel_interface.h b/src/ELECTRODE/electrode_accel_interface.h deleted file mode 100644 index bec4e0ed1f..0000000000 --- a/src/ELECTRODE/electrode_accel_interface.h +++ /dev/null @@ -1,33 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH) -------------------------------------------------------------------------- */ - -#ifndef LMP_ELECTRODE_ACCEL_INTERFACE_H -#define LMP_ELECTRODE_ACCEL_INTERFACE_H - -#include "pointers.h" - -namespace LAMMPS_NS { - -class ElectrodeAccelInterface : protected Pointers { - public: - ElectrodeAccelInterface(class LAMMPS *lmp) : Pointers(lmp) {} - virtual void intel_find_fix() {} - virtual void intel_pack_buffers() {} -}; - -} // namespace LAMMPS_NS -#endif diff --git a/src/ELECTRODE/fix_electrode_conp.cpp b/src/ELECTRODE/fix_electrode_conp.cpp index 2c39a57532..dbb508a033 100644 --- a/src/ELECTRODE/fix_electrode_conp.cpp +++ b/src/ELECTRODE/fix_electrode_conp.cpp @@ -21,7 +21,6 @@ #include "citeme.h" #include "comm.h" #include "domain.h" -#include "electrode_accel_interface.h" #include "electrode_math.h" #include "electrode_matrix.h" #include "electrode_vector.h" @@ -272,8 +271,6 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : groupbit = group->bitmask[igroup]; ngroup = group->count(igroup); - accel_interface = std::unique_ptr(new ElectrodeAccelInterface(lmp)); - if (matrix_algo) { memory->create(iele_gathered, ngroup, "FixElectrode:iele_gathered"); memory->create(buf_gathered, ngroup, "FixElectrode:buf_gathered"); @@ -381,7 +378,6 @@ void FixElectrodeConp::init() if (count > 1) error->all(FLERR, "More than one fix electrode"); // check for package intel - accel_interface->intel_find_fix(); if (etypes_neighlists) request_etypes_neighlists(); else { @@ -795,7 +791,6 @@ void FixElectrodeConp::update_charges() double *q = atom->q; gather_list_iele(); pre_update(); - accel_interface->intel_pack_buffers(); // update buffers for pppmintel to compute potential auto q_local = std::vector(nlocalele, 0.); if (algo == Algo::MATRIX_INV) { std::fill(sb_charges.begin(), sb_charges.end(), 0.); @@ -866,7 +861,6 @@ void FixElectrodeConp::update_charges() } set_charges(q_local); update_time += MPI_Wtime() - start; - accel_interface->intel_pack_buffers(); } std::vector FixElectrodeConp::ele_ele_interaction(const std::vector& q_local) @@ -889,7 +883,7 @@ void FixElectrodeConp::set_charges(std::vector q_local) double *q = atom->q; for (int i = 0; i < nlocalele; i++) q[atom->map(taglist_local[i])] = q_local[i]; comm->forward_comm(this); - accel_interface->intel_pack_buffers(); + intel_pack_buffers(); } /* ---------------------------------------------------------------------- */ diff --git a/src/ELECTRODE/fix_electrode_conp.h b/src/ELECTRODE/fix_electrode_conp.h index 5d3131bcce..1289d96281 100644 --- a/src/ELECTRODE/fix_electrode_conp.h +++ b/src/ELECTRODE/fix_electrode_conp.h @@ -35,7 +35,6 @@ FixStyle(electrode/conp, FixElectrodeConp); namespace LAMMPS_NS { // forward decls -class ElectrodeAccelInterface; class ElectrodeVector; class NeighList; class Pair; @@ -56,7 +55,7 @@ class FixElectrodeConp : public Fix { double compute_array(int, int) override; int modify_param(int, char **) override; int modify_param(const std::string &); - void init() override; + virtual void init() override; void init_list(int, NeighList *) override; void post_constructor() override; // used by ffield to set up fix efield double memory_usage() override; @@ -101,7 +100,7 @@ class FixElectrodeConp : public Fix { bool ffield; // possibly tweak electrode/conq's version std::string fixname; // used by electrode/ffield to set up internal efield bool intelflag; - std::unique_ptr accel_interface; // used by /intel + inline virtual void intel_pack_buffers() {} private: std::string output_file_inv, output_file_mat, output_file_vec; diff --git a/src/INTEL/electrode_accel_intel.cpp b/src/INTEL/electrode_accel_intel.cpp deleted file mode 100644 index 3b7da17b7c..0000000000 --- a/src/INTEL/electrode_accel_intel.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/ Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include "electrode_accel_intel.h" - -#include "comm.h" -#include "fix_intel.h" -#include "intel_buffers.h" -#include "modify.h" - -using namespace LAMMPS_NS; - -ElectrodeAccelIntel::ElectrodeAccelIntel(class LAMMPS *lmp) : ElectrodeAccelInterface(lmp) {} - -void ElectrodeAccelIntel::intel_find_fix() -{ - int ifix = modify->find_fix("package_intel"); - if (ifix < 0) error->all(FLERR, "The 'package intel' command is required for /intel styles"); - fix = static_cast(modify->fix[ifix]); -} - -void ElectrodeAccelIntel::intel_pack_buffers() -{ - switch (fix->precision()) { - case FixIntel::PREC_MODE_MIXED: - intel_pack_buffers_prec(fix->get_mixed_buffers()); - break; - case FixIntel::PREC_MODE_DOUBLE: - intel_pack_buffers_prec(fix->get_double_buffers()); - break; - default: // FixIntel::PREC_MODE_SINGLE - intel_pack_buffers_prec(fix->get_single_buffers()); - } -} - -template -void ElectrodeAccelIntel::intel_pack_buffers_prec(IntelBuffers *buffers) -{ - fix->start_watch(TIME_PACK); - int packthreads; - if (comm->nthreads > INTEL_HTHREADS) - packthreads = comm->nthreads; - else - packthreads = 1; -#if defined(_OPENMP) -#pragma omp parallel if (packthreads > 1) -#endif - { - int ifrom, ito, tid; - IP_PRE_omp_range_id_align(ifrom, ito, tid, atom->nlocal + atom->nghost, packthreads, - sizeof(ATOM_T)); - buffers->thr_pack(ifrom, ito, 0); - } - fix->stop_watch(TIME_PACK); -} diff --git a/src/INTEL/electrode_accel_intel.h b/src/INTEL/electrode_accel_intel.h deleted file mode 100644 index eba6bc0157..0000000000 --- a/src/INTEL/electrode_accel_intel.h +++ /dev/null @@ -1,37 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/ Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifndef LMP_ELECTRODE_ACCEL_INTEL_H -#define LMP_ELECTRODE_ACCEL_INTEL_H - -#include "electrode_accel_interface.h" -#include "fix_intel.h" -#include "intel_buffers.h" - -namespace LAMMPS_NS { - -class ElectrodeAccelIntel : public ElectrodeAccelInterface { - public: - ElectrodeAccelIntel(class LAMMPS *lmp); - void intel_find_fix() override; - void intel_pack_buffers() override; - - private: - class FixIntel *fix; - template - void intel_pack_buffers_prec(IntelBuffers *buffers); -}; - -} // namespace LAMMPS_NS - -#endif diff --git a/src/INTEL/fix_electrode_conp_intel.h b/src/INTEL/fix_electrode_conp_intel.h index 920cdcb89a..293b26ba18 100644 --- a/src/INTEL/fix_electrode_conp_intel.h +++ b/src/INTEL/fix_electrode_conp_intel.h @@ -26,18 +26,27 @@ FixStyle(electrode/conp/intel, FixElectrodeConpIntel) #ifndef LMP_FIX_ELECTRODE_CONP_INTEL_H #define LMP_FIX_ELECTRODE_CONP_INTEL_H -#include "electrode_accel_intel.h" #include "fix_electrode_conp.h" +#include "pppm_intel.h" namespace LAMMPS_NS { class FixElectrodeConpIntel : public FixElectrodeConp { public: - FixElectrodeConpIntel(class LAMMPS *lmp, int narg, char **arg) : FixElectrodeConp(lmp, narg, arg) - { + FixElectrodeConpIntel(class LAMMPS *lmp, int narg, char **arg) : FixElectrodeConp(lmp, narg, arg) {} + inline void init() final override { + _intel_kspace = dynamic_cast(force->kspace_match("pppm/electrode/intel", 0)); + if (_intel_kspace == nullptr) error->all(FLERR, "pppm/electrode/intel is required by fix electrode/conp/intel"); + intelflag = true; - accel_interface = std::unique_ptr(new ElectrodeAccelIntel(lmp)); + FixElectrodeConp::init(); } + inline void intel_pack_buffers() final override { + _intel_kspace->pack_buffers(0); + } + + private: + PPPMIntel * _intel_kspace; }; } // namespace LAMMPS_NS diff --git a/src/INTEL/fix_electrode_conq_intel.h b/src/INTEL/fix_electrode_conq_intel.h index 2bc04a72fc..fe67b9477e 100644 --- a/src/INTEL/fix_electrode_conq_intel.h +++ b/src/INTEL/fix_electrode_conq_intel.h @@ -26,20 +26,30 @@ FixStyle(electrode/conq/intel, FixElectrodeConqIntel) #ifndef LMP_FIX_ELECTRODE_CONQ_INTEL_H #define LMP_FIX_ELECTRODE_CONQ_INTEL_H -#include "electrode_accel_intel.h" #include "fix_electrode_conq.h" +#include "pppm_intel.h" namespace LAMMPS_NS { class FixElectrodeConqIntel : public FixElectrodeConq { public: - FixElectrodeConqIntel(class LAMMPS *lmp, int narg, char **arg) : FixElectrodeConq(lmp, narg, arg) - { + FixElectrodeConqIntel(class LAMMPS *lmp, int narg, char **arg) : FixElectrodeConq(lmp, narg, arg) {} + inline void init() final override { + _intel_kspace = dynamic_cast(force->kspace_match("pppm/electrode/intel", 0)); + if (_intel_kspace == nullptr) error->all(FLERR, "pppm/electrode/intel is required by fix electrode/conq/intel"); + intelflag = true; - accel_interface = std::unique_ptr(new ElectrodeAccelIntel(lmp)); + FixElectrodeConq::init(); } + inline void intel_pack_buffers() final override { + _intel_kspace->pack_buffers(0); + } + + private: + PPPMIntel * _intel_kspace; }; + } // namespace LAMMPS_NS #endif diff --git a/src/INTEL/fix_electrode_thermo_intel.h b/src/INTEL/fix_electrode_thermo_intel.h index de6d5fa29c..25418ffe03 100644 --- a/src/INTEL/fix_electrode_thermo_intel.h +++ b/src/INTEL/fix_electrode_thermo_intel.h @@ -26,19 +26,27 @@ FixStyle(electrode/thermo/intel, FixElectrodeThermoIntel) #ifndef LMP_FIX_ELECTRODE_THERMO_INTEL_H #define LMP_FIX_ELECTRODE_THERMO_INTEL_H -#include "electrode_accel_intel.h" #include "fix_electrode_thermo.h" +#include "pppm_intel.h" namespace LAMMPS_NS { class FixElectrodeThermoIntel : public FixElectrodeThermo { public: - FixElectrodeThermoIntel(class LAMMPS *lmp, int narg, char **arg) : - FixElectrodeThermo(lmp, narg, arg) - { + FixElectrodeThermoIntel(class LAMMPS *lmp, int narg, char **arg) : FixElectrodeThermo(lmp, narg, arg) {} + inline void init() final override { + _intel_kspace = dynamic_cast(force->kspace_match("pppm/electrode/intel", 0)); + if (_intel_kspace == nullptr) error->all(FLERR, "pppm/electrode/intel is required by fix electrode/thermo/intel"); + intelflag = true; - accel_interface = std::unique_ptr(new ElectrodeAccelIntel(lmp)); + FixElectrodeThermo::init(); } + inline void intel_pack_buffers() final override { + _intel_kspace->pack_buffers(0); + } + + private: + PPPMIntel * _intel_kspace; }; } // namespace LAMMPS_NS diff --git a/src/INTEL/pppm_electrode_intel.cpp b/src/INTEL/pppm_electrode_intel.cpp index 7a15f1d8a6..419d03cfcf 100644 --- a/src/INTEL/pppm_electrode_intel.cpp +++ b/src/INTEL/pppm_electrode_intel.cpp @@ -338,6 +338,7 @@ void PPPMElectrodeIntel::compute_vector(double *vec, int sensor_grpbit, int sour // electrolyte density (without writing an additional function) FFT_SCALAR ***density_brick_real = density_brick; FFT_SCALAR *density_fft_real = density_fft; + pack_buffers(1); // update positions if called before pair_compute switch (fix->precision()) { case FixIntel::PREC_MODE_MIXED: make_rho_in_brick(fix->get_mixed_buffers(), source_grpbit, diff --git a/src/INTEL/pppm_intel.cpp b/src/INTEL/pppm_intel.cpp index 2ceca54d29..bde9b70000 100644 --- a/src/INTEL/pppm_intel.cpp +++ b/src/INTEL/pppm_intel.cpp @@ -1052,7 +1052,8 @@ double PPPMIntel::memory_usage() Pack data into intel package buffers if using LRT mode ------------------------------------------------------------------------- */ -void PPPMIntel::pack_buffers() +void PPPMIntel::pack_buffers(int ago) + // VerletLRTIntel uses ago 1, fix electrode/*/intel uses ago 0 { fix->start_watch(TIME_PACK); int packthreads; @@ -1067,11 +1068,11 @@ void PPPMIntel::pack_buffers() packthreads, sizeof(IntelBuffers::atom_t)); if (fix->precision() == FixIntel::PREC_MODE_MIXED) - fix->get_mixed_buffers()->thr_pack(ifrom,ito,1); + fix->get_mixed_buffers()->thr_pack(ifrom,ito,ago); else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) - fix->get_double_buffers()->thr_pack(ifrom,ito,1); + fix->get_double_buffers()->thr_pack(ifrom,ito,ago); else - fix->get_single_buffers()->thr_pack(ifrom,ito,1); + fix->get_single_buffers()->thr_pack(ifrom,ito,ago); } fix->stop_watch(TIME_PACK); } diff --git a/src/INTEL/pppm_intel.h b/src/INTEL/pppm_intel.h index a016cfd4fa..80b499c107 100644 --- a/src/INTEL/pppm_intel.h +++ b/src/INTEL/pppm_intel.h @@ -42,7 +42,7 @@ class PPPMIntel : public PPPM { double memory_usage() override; void compute_first(int, int); void compute_second(int, int); - void pack_buffers(); + void pack_buffers(int); #ifdef _LMP_INTEL_OFFLOAD int use_base(); diff --git a/src/INTEL/verlet_lrt_intel.cpp b/src/INTEL/verlet_lrt_intel.cpp index 4459d69c8d..5eaa0e5896 100644 --- a/src/INTEL/verlet_lrt_intel.cpp +++ b/src/INTEL/verlet_lrt_intel.cpp @@ -67,7 +67,8 @@ void VerletLRTIntel::init() { Verlet::init(); - _intel_kspace = dynamic_cast(force->kspace_match("^pppm/intel", 0)); + _intel_kspace = dynamic_cast(force->kspace_match("^pppm\..*intel$", 0)); + // include pppm/electrode/intel #ifndef LMP_INTEL_USELRT error->all(FLERR, @@ -252,7 +253,7 @@ void VerletLRTIntel::run(int n) timer->stamp(); comm->forward_comm(); timer->stamp(Timer::COMM); - _intel_kspace->pack_buffers(); + _intel_kspace->pack_buffers(1); } else { if (n_pre_exchange) { timer->stamp();