// -*- C++ -*- // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // // // CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy. // Copyright (C) 2002-2005, California Institute of Technology. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // #include #include #include "journal/diagnostics.h" #include "Exchanger/Array2D.h" using namespace std; using namespace Exchanger; int main(int argc, char** argv) { const string name = "Array2DTest"; journal::info_t info(name); info.activate(); const int dim = 3; MPI_Init(&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank; MPI_Comm_rank(comm, &rank); Array2D d1(2); Array2D i1(5); if (rank == 0) { // testing vector-like behaviors info << "c'tor" << journal::endl; d1.print(name); i1.print(name); info << "copy c'tor" << journal::endl; d1[0][0] = 1; Array2D d2(d1); d2.print(name); info << "op'tor [][]" << journal::endl; for (int i=0; i(dim, 5)); d1.print(name); info << "reserve shrink capacity" << journal::endl; i1.reserve(1000); info << "capacity = " << i1.capacity() << journal::endl; i1.shrink(); info << "capacity = " << i1.capacity() << journal::endl; } // testing send/receive ... if (rank == 0) { d1.sendSize(comm, 1); } else if(rank == 1) { info << "sendSize/receiveSize" << journal::endl; Array2D d3; info << "received size = " << d3.recvSize(comm, 0) << journal::endl; } if (rank == 0) { d1.send(comm, 1); } else if(rank == 1) { info << "blocking send -> blocking receive" << journal::endl; Array2D d3; d3.recv(comm, 0); d3.print(name); } if (rank == 0) { MPI_Request request; MPI_Status status; d1.send(comm, 1, request); MPI_Wait(&request, &status); } else if(rank == 1) { info << "non-blocking send -> non-blocking receive" << journal::endl; Array2D d3; MPI_Request request; MPI_Status status; d3.recv(comm, 0, request); MPI_Wait(&request, &status); d3.print(name); } if (rank == 0) { Array2D d3(dim*dim); for(int i=0; i request(dim); vector status(dim); for(int i=0; i non-blocking partial receive" << journal::endl; Array2D d3(dim*dim); vector request(dim); vector status(dim); for(int i=0; i