59 #include <Teuchos_RCP.hpp> 60 #include <Teuchos_ArrayRCP.hpp> 61 #include <Teuchos_Comm.hpp> 62 #include <Teuchos_DefaultComm.hpp> 66 int main(
int argc,
char *argv[])
68 Teuchos::GlobalMPISession session(&argc, &argv);
69 Teuchos::RCP<const Teuchos::Comm<int> > comm =
70 Teuchos::DefaultComm<int>::getComm();
72 int rank = comm->getRank();
73 int nprocs = comm->getSize();
75 Teuchos::RCP<const Zoltan2::Environment> envPtr =
84 int myMsgSizeBase=rank*nprocs + 1;
85 Array<int> sendCount(nprocs, 0);
86 Array<int> recvCount(nprocs, 0);
89 for (
int p=0; p < nprocs; p++){
90 sendCount[p] = myMsgSizeBase + p;
91 totalOut += sendCount[p];
94 Array<int> sendBuf(totalOut, 0);
96 int *out = &(sendBuf[0]);
97 for (
int p=0; p < nprocs; p++){
98 for (
int i=0; i < sendCount[p]; i++){
103 Teuchos::ArrayRCP<int> recvBuf;
105 Zoltan2::AlltoAllv<int>(*comm, *envPtr,
111 int *inBuf = recvBuf.get();
113 for (
int p=0; p < nprocs; p++){
114 for (
int i=0; i < recvCount[p]; i++){
115 if (*inBuf++ != rank+p){
131 int nstrings = nprocs * rank;
132 string *sendStrings = NULL;
135 sendStrings =
new string [nstrings];
137 ostringstream myMessage;
138 myMessage <<
"message from process " << rank;
140 for (
int i=0; i < nstrings; i++)
141 sendStrings[i] = myMessage.str();
143 int *counts =
new int [nprocs];
144 for (
int i=0; i < nprocs ; i++)
147 Teuchos::ArrayView<const string> sendBuf(sendStrings, nstrings);
148 Teuchos::ArrayView<const int> sendCount(counts, nprocs);
149 Teuchos::Array<int> recvCounts(nprocs, 0);
151 Teuchos::ArrayRCP<string> recvBuf;
153 Zoltan2::AlltoAllv<string>(*comm, *envPtr,
159 delete [] sendStrings;
163 for (
int i=0; i < nprocs; i++){
164 if (recvCounts[i] != i){
169 msg <<
"message from process " << i;
170 for (
int j=0; j < recvCounts[i]; j++){
171 if (recvBuf[next++] != msg.str()){
183 std::cout <<
"FAIL" << std::endl;
185 std::cout <<
"PASS" << std::endl;
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
common code used by tests
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
Defines the Environment class.
int main(int argc, char *argv[])
AlltoAll communication methods.