// --------------------------------------------------------------------- // // Copyright (c) 2017-2022 The Regents of the University of Michigan and DFT-FE // authors. // // This file is part of the DFT-FE code. // // The DFT-FE code is free software; you can use it, redistribute // it, and/or modify it under the terms of the GNU Lesser General // Public License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // The full text of the license can be found in the file LICENSE at // the top level of the DFT-FE distribution. // // --------------------------------------------------------------------- // /* * @author Sambit Das */ #ifndef dftfeMPICommunicatorP2PKernels_h #define dftfeMPICommunicatorP2PKernels_h #include #include #include #include #ifdef DFTFE_WITH_DEVICE # include #endif namespace dftfe { namespace utils { template class MPICommunicatorP2PKernels { public: using SizeTypeVector = utils::MemoryStorage; /** * @brief Function template for architecture adaptable gather kernel to send buffer * @tparam ValueType the type of the number * @tparam memorySpace * @param[in] dataArray data array with locally owned entries * @param[in] ownedLocalIndicesForTargetProcs * @param[in] blockSize * @param[out] sendBuffer */ template static void gatherLocallyOwnedEntriesSendBufferToTargetProcs( const MemoryStorage &dataArray, const SizeTypeVector &ownedLocalIndicesForTargetProcs, const size_type blockSize, MemoryStorage &sendBuffer); /** * @brief Function template for architecture adaptable accumlate kernel from recv buffer * @tparam ValueType the type of the number * @tparam memorySpace * @param[in] recvBuffer * @param[in] ownedLocalIndicesForTargetProcs * @param[in] blockSize * @param[out] dataArray */ template static void accumAddLocallyOwnedContrRecvBufferFromTargetProcs( const MemoryStorage &recvBuffer, const SizeTypeVector & ownedLocalIndicesForTargetProcs, const size_type blockSize, const size_type locallyOwnedSize, const size_type ghostSize, MemoryStorage &dataArray); /** * @brief Function template for copying type1 to type2 * @param[in] blockSize * @param[in] type1Array * @param[out] type2Array */ template static void copyValueType1ArrToValueType2Arr(const size_type blockSize, const ValueType1 *type1Array, ValueType2 * type2Array); }; #ifdef DFTFE_WITH_DEVICE template class MPICommunicatorP2PKernels { public: template static void gatherLocallyOwnedEntriesSendBufferToTargetProcs( const MemoryStorage &dataArray, const MemoryStorage & ownedLocalIndicesForTargetProcs, const size_type blockSize, MemoryStorage & sendBuffer, dftfe::utils::deviceStream_t deviceCommStream); template static void accumAddLocallyOwnedContrRecvBufferFromTargetProcs( const MemoryStorage &recvBuffer, const MemoryStorage & ownedLocalIndicesForTargetProcs, const size_type blockSize, const size_type locallyOwnedSize, const size_type ghostSize, MemoryStorage &dataArray, dftfe::utils::deviceStream_t deviceCommStream); /** * @brief Function template for copying type1 to type2 * @param[in] blockSize * @param[in] type1Array * @param[out] type2Array */ template static void copyValueType1ArrToValueType2Arr( const size_type blockSize, const ValueType1 * type1Array, ValueType2 * type2Array, dftfe::utils::deviceStream_t deviceCommStream); }; #endif } // namespace utils } // namespace dftfe #endif