/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020 by the GROMACS development team.
+ * Copyright (c) 2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/stringutil.h"
+#include "gromacs/ewald/pme_coordinate_receiver_gpu.h"
#include "testutils/test_hardware_environment.h"
#include "testutils/testasserts.h"
namespace test
{
+//! A couple of valid inputs for boxes.
+const std::map<std::string, Matrix3x3> c_inputBoxes = {
+ { "rect", { { 8.0F, 0.0F, 0.0F, 0.0F, 3.4F, 0.0F, 0.0F, 0.0F, 2.0F } } },
+ { "tric", { { 7.0F, 0.0F, 0.0F, 0.0F, 4.1F, 0.0F, 3.5F, 2.0F, 12.2F } } },
+};
+
+//! Valid PME orders for testing
+std::vector<int> c_inputPmeOrders{ 3, 4, 5 };
+
bool pmeSupportsInputForMode(const gmx_hw_info_t& hwinfo, const t_inputrec* inputRec, CodePath mode)
{
bool implemented;
const ChargesVector& charges)
{
const index atomCount = coordinates.size();
- GMX_RELEASE_ASSERT(atomCount == charges.ssize(), "Mismatch in atom data");
+ GMX_RELEASE_ASSERT(atomCount == gmx::ssize(charges), "Mismatch in atom data");
PmeAtomComm* atc = nullptr;
switch (mode)
stateGpu->reinit(atomCount, atomCount);
stateGpu->copyCoordinatesToGpu(arrayRefFromArray(coordinates.data(), coordinates.size()),
- gmx::AtomLocality::All);
+ gmx::AtomLocality::Local);
pme_gpu_set_kernelparam_coordinates(pme->gpu, stateGpu->getCoordinates());
break;
const real lambdaQ = 1.0;
// no synchronization needed as x is transferred in the PME stream
GpuEventSynchronizer* xReadyOnDevice = nullptr;
- pme_gpu_spread(pme->gpu, xReadyOnDevice, fftgrid, computeSplines, spreadCharges, lambdaQ);
+
+ bool useGpuDirectComm = false;
+ gmx::PmeCoordinateReceiverGpu* pmeCoordinateReceiverGpu = nullptr;
+
+ pme_gpu_spread(pme->gpu,
+ xReadyOnDevice,
+ fftgrid,
+ computeSplines,
+ spreadCharges,
+ lambdaQ,
+ useGpuDirectComm,
+ pmeCoordinateReceiverGpu);
}
break;
#endif
{
PmeAtomComm* atc = &(pme->atc[0]);
const index atomCount = atc->numAtoms();
- GMX_RELEASE_ASSERT(atomCount == gridLineIndices.ssize(), "Mismatch in gridline indices size");
+ GMX_RELEASE_ASSERT(atomCount == ssize(gridLineIndices), "Mismatch in gridline indices size");
IVec paddedGridSizeUnused, gridSize(0, 0, 0);
pmeGetRealGridSizesInternal(pme, mode, gridSize, paddedGridSizeUnused);
switch (mode)
{
case CodePath::GPU:
- gridLineIndices = arrayRefFromArray(
- reinterpret_cast<IVec*>(pme_gpu_staging(pme->gpu).h_gridlineIndices), atomCount);
- break;
+ {
+ auto* gridlineIndicesAsIVec =
+ reinterpret_cast<IVec*>(pme_gpu_staging(pme->gpu).h_gridlineIndices);
+ ArrayRef<IVec> gridlineIndicesArrayRef = arrayRefFromArray(gridlineIndicesAsIVec, atomCount);
+ gridLineIndices = { gridlineIndicesArrayRef.begin(), gridlineIndicesArrayRef.end() };
+ }
+ break;
- case CodePath::CPU: gridLineIndices = atc->idx; break;
+ case CodePath::CPU: gridLineIndices = { atc->idx.begin(), atc->idx.end() }; break;
default: GMX_THROW(InternalError("Test not implemented for this mode"));
}
return output;
}
-const char* codePathToString(CodePath codePath)
-{
- switch (codePath)
- {
- case CodePath::CPU: return "CPU";
- case CodePath::GPU: return "GPU";
- default: GMX_THROW(NotImplementedError("This CodePath should support codePathToString"));
- }
-}
-
PmeTestHardwareContext::PmeTestHardwareContext() : codePath_(CodePath::CPU) {}
PmeTestHardwareContext::PmeTestHardwareContext(TestDevice* testDevice) :
- codePath_(CodePath::CPU), testDevice_(testDevice)
+ codePath_(CodePath::GPU), testDevice_(testDevice)
{
setActiveDevice(testDevice_->deviceInfo());
pmeGpuProgram_ = buildPmeGpuProgram(testDevice_->deviceContext());