membrane compiles

This commit is contained in:
James McClure
2021-12-28 16:59:44 -05:00
parent 6d82dc83a2
commit 74bf7dbec4
3 changed files with 43 additions and 19 deletions

View File

@@ -3,9 +3,9 @@
#include "analysis/Membrane.h"
#include "analysis/distance.h"
Membrane::Membrane(std::shared_ptr <Domain> Dm, int *initialNeighborList) {
Membrane::Membrane(std::shared_ptr <Domain> Dm, int *initialNeighborList, int Nsites) {
Np = Dm->Np;
Np = Nsites;
neighborList = new int[18*Np];
/* Copy neighborList */
for (int idx=0; idx<Np; idx++){
@@ -343,9 +343,10 @@ Membrane::~Membrane() {
ScaLBL_FreeDeviceMemory( dvcRecvDist_YZ );
}
int Membrane::D3Q19_MapSendRecv(const int Cqx, const int Cqy, const int Cqz, int rank_q, int rank_Q,
const int shift_x, const int shift_y, const int shift_z,
const int *originalSendList, const int sendCount, const int recvCount,
int Membrane::D3Q19_MapSendRecv(const int Cqx, const int Cqy, const int Cqz,
int rank_q, int rank_Q, const int shift_x, const int shift_y, const int shift_z,
std::shared_ptr <Domain> Dm, const int *originalSendList, const int sendCount, const int recvCount,
int startSend, int startRecv,
const DoubleArray &Distance, int *membraneSendList, int *membraneRecvList){
int sendtag = 2389;
@@ -398,11 +399,11 @@ int Membrane::D3Q19_MapSendRecv(const int Cqx, const int Cqy, const int Cqz, int
// send the recv list to the neighbor process
req1[0] = Dm->Comm.Isend(RecvList_q, sendCount, rank_q, sendtag);
req2[0] = Dm->Comm.Irecv(RecvList, recvCount, rank_Q, recvtag);
Dm->Barrier();
Dm->Comm.barrier();
// Return updated version to the device
ScaLBL_CopyToDevice(&membraneSendList[start], SendList, sendCount*sizeof(int));
ScaLBL_CopyToDevice(&membraneRecvList[start], RecvList, recvCount*sizeof(int));
ScaLBL_CopyToDevice(&membraneSendList[startSend], SendList, sendCount*sizeof(int));
ScaLBL_CopyToDevice(&membraneRecvList[startRecv], RecvList, recvCount*sizeof(int));
// clean up the work arrays
delete [] SendList;
@@ -413,6 +414,7 @@ int Membrane::D3Q19_MapSendRecv(const int Cqx, const int Cqy, const int Cqz, int
int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArray &Map){
int mlink = 0;
int i,j,k;
int n, idx, neighbor;
double dist, locdist;
/* go through the neighborlist structure */
@@ -424,7 +426,7 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
idx=Map(i,j,k);
locdist=Distance(i,j,k);
else if (!(idx<0)){
if (!(idx<0)){
neighbor=Map(i-1,j,k);
dist=Distance(i-1,j,k);
@@ -560,7 +562,7 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
idx=Map(i,j,k);
locdist=Distance(i,j,k);
else if (!(idx<0)){
if (!(idx<0)){
neighbor=Map(i+1,j,k);
dist=Distance(i+1,j,k);
@@ -657,7 +659,7 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
}
/* Re-organize communication based on membrane structure*/
membraneCount_x = D3Q19_MapSendRecv(Cx, Cy, Cz, Dm->sendList("x"), Distance, );
//membraneCount_x = D3Q19_MapSendRecv(Cx, Cy, Cz, Dm->sendList("x"), Distance, );
// MPI_COMM_SCALBL.barrier();
@@ -665,7 +667,7 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
// Set up the recieve distribution lists
//...................................................................................
//...Map recieve list for the X face: q=2,8,10,12,14 .................................
D3Q19_MapRecv(-1,0,0, Dm->recvList("X"),0,recvCount_X,dvcRecvDist_X);
/* D3Q19_MapRecv(-1,0,0, Dm->recvList("X"),0,recvCount_X,dvcRecvDist_X);
D3Q19_MapRecv(-1,-1,0,Dm->recvList("X"),recvCount_X,recvCount_X,dvcRecvDist_X);
D3Q19_MapRecv(-1,1,0, Dm->recvList("X"),2*recvCount_X,recvCount_X,dvcRecvDist_X);
D3Q19_MapRecv(-1,0,-1,Dm->recvList("X"),3*recvCount_X,recvCount_X,dvcRecvDist_X);
@@ -747,6 +749,6 @@ int Membrane::Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArra
CommunicationCount = SendCount+RecvCount;
//......................................................................................
*/
return mlink;
}

View File

@@ -21,6 +21,9 @@
class Membrane {
public:
int Np;
int Nx,Ny,Nz,N;
int *neighborList; // modified neighborlist
int *membraneLinks; // D3Q19 links that cross membrane
double *membraneDist; // distance to membrane for each linked site
@@ -30,7 +33,7 @@ public:
* @param ScaLBL - originating data structures
* @param neighborList - list of neighbors for each site
*/
Membrane(ScaLBL_Communicator &ScaLBL, int *initialNeighborList);
Membrane(std::shared_ptr <Domain> Dm, int *initialNeighborList, int Nsites);
/**
* \brief Destructor
@@ -46,8 +49,23 @@ public:
*/
int Create(std::shared_ptr <Domain> Dm, DoubleArray &Distance, IntArray &Map);
//......................................................................................
// Buffers to store data sent and recieved by this MPI process
double *sendbuf_x, *sendbuf_y, *sendbuf_z, *sendbuf_X, *sendbuf_Y, *sendbuf_Z;
double *sendbuf_xy, *sendbuf_yz, *sendbuf_xz, *sendbuf_Xy, *sendbuf_Yz, *sendbuf_xZ;
double *sendbuf_xY, *sendbuf_yZ, *sendbuf_Xz, *sendbuf_XY, *sendbuf_YZ, *sendbuf_XZ;
double *recvbuf_x, *recvbuf_y, *recvbuf_z, *recvbuf_X, *recvbuf_Y, *recvbuf_Z;
double *recvbuf_xy, *recvbuf_yz, *recvbuf_xz, *recvbuf_Xy, *recvbuf_Yz, *recvbuf_xZ;
double *recvbuf_xY, *recvbuf_yZ, *recvbuf_Xz, *recvbuf_XY, *recvbuf_YZ, *recvbuf_XZ;
//......................................................................................
private:
int Np;
int iproc,jproc,kproc;
int nprocx,nprocy,nprocz;
// Give the object it's own MPI communicator
RankInfoStruct rank_info;
Utilities::MPI MPI_COMM_SCALBL; // MPI Communicator for this domain
MPI_Request req1[18],req2[18];
/**
* \brief Set up membrane communication
* \details associate p2p communication links to membrane where necessary
@@ -63,9 +81,10 @@ private:
* @param recvDistance - distance values from neighboring processor
* @param d3q19_recvlist - device array with the saved list
* */
int D3Q19_MapSendRecv(const int Cqx, const int Cqy, const int Cqz, int rank_q, int rank_Q,
const int shift_x, const int shift_y, const int shift_z,
const int *originalSendList, const int sendCount, const int recvCount,
int D3Q19_MapSendRecv(const int Cqx, const int Cqy, const int Cqz,
int rank_q, int rank_Q, const int shift_x, const int shift_y, const int shift_z,
std::shared_ptr <Domain> Dm, const int *originalSendList, const int sendCount, const int recvCount,
int startSend, int startRecv,
const DoubleArray &Distance, int *membraneSendList, int *membraneRecvList);
//......................................................................................
// MPI ranks for all 18 neighbors

View File

@@ -6,8 +6,8 @@
#include <stdio.h>
#include <iostream>
#include <fstream>
#include "common/ScaLBL.h"
#include "common/MPI.h"
#include "analysis/Membrane.h"
using namespace std;
@@ -107,6 +107,9 @@ int main(int argc, char **argv)
}
}
/* create a membrane data structure */
Membrane M(Dm, neighborList, Np);
//......................device distributions.................................
int *NeighborList;