59 #include <Teuchos_RCP.hpp>
60 #include <Teuchos_ArrayRCP.hpp>
61 #include <Teuchos_Comm.hpp>
62 #include <Teuchos_DefaultComm.hpp>
65 int main(
int narg,
char *arg[])
67 Tpetra::ScopeGuard tscope(&narg, &arg);
68 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
70 int rank = comm->getRank();
71 int nprocs = comm->getSize();
73 Teuchos::RCP<const Zoltan2::Environment> envPtr =
82 int myMsgSizeBase=rank*nprocs + 1;
83 Array<int> sendCount(nprocs, 0);
84 Array<int> recvCount(nprocs, 0);
87 for (
int p=0; p < nprocs; p++){
88 sendCount[p] = myMsgSizeBase + p;
89 totalOut += sendCount[p];
92 Array<int> sendBuf(totalOut, 0);
94 int *out = &(sendBuf[0]);
95 for (
int p=0; p < nprocs; p++){
96 for (
int i=0; i < sendCount[p]; i++){
101 Teuchos::ArrayRCP<int> recvBuf;
103 Zoltan2::AlltoAllv<int>(*comm, *envPtr,
109 int *inBuf = recvBuf.get();
111 for (
int p=0; p < nprocs; p++){
112 for (
int i=0; i < recvCount[p]; i++){
113 if (*inBuf++ != rank+p){
129 int nstrings = nprocs * rank;
130 string *sendStrings = NULL;
133 sendStrings =
new string [nstrings];
135 std::ostringstream myMessage;
136 myMessage <<
"message from process " << rank;
138 for (
int i=0; i < nstrings; i++)
139 sendStrings[i] = myMessage.str();
141 int *counts =
new int [nprocs];
142 for (
int i=0; i < nprocs ; i++)
145 Teuchos::ArrayView<const string> sendBuf(sendStrings, nstrings);
146 Teuchos::ArrayView<const int> sendCount(counts, nprocs);
147 Teuchos::Array<int> recvCounts(nprocs, 0);
149 Teuchos::ArrayRCP<string> recvBuf;
151 Zoltan2::AlltoAllv<string>(*comm, *envPtr,
157 delete [] sendStrings;
161 for (
int i=0; i < nprocs; i++){
162 if (recvCounts[i] != i){
166 std::ostringstream msg;
167 msg <<
"message from process " << i;
168 for (
int j=0; j < recvCounts[i]; j++){
169 if (recvBuf[next++] != msg.str()){
181 std::cout <<
"FAIL" << std::endl;
183 std::cout <<
"PASS" << std::endl;
int main(int narg, char *arg[])
#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.
AlltoAll communication methods.