23 #include <Teuchos_RCP.hpp>
24 #include <Teuchos_ArrayRCP.hpp>
25 #include <Teuchos_Comm.hpp>
26 #include <Teuchos_DefaultComm.hpp>
29 int main(
int narg,
char *arg[])
31 Tpetra::ScopeGuard tscope(&narg, &arg);
32 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
34 int rank = comm->getRank();
35 int nprocs = comm->getSize();
37 Teuchos::RCP<const Zoltan2::Environment> envPtr =
46 int myMsgSizeBase=rank*nprocs + 1;
47 Array<int> sendCount(nprocs, 0);
48 Array<int> recvCount(nprocs, 0);
51 for (
int p=0; p < nprocs; p++){
52 sendCount[p] = myMsgSizeBase + p;
53 totalOut += sendCount[p];
56 Array<int> sendBuf(totalOut, 0);
58 int *out = &(sendBuf[0]);
59 for (
int p=0; p < nprocs; p++){
60 for (
int i=0; i < sendCount[p]; i++){
65 Teuchos::ArrayRCP<int> recvBuf;
67 Zoltan2::AlltoAllv<int>(*comm, *envPtr,
73 int *inBuf = recvBuf.get();
75 for (
int p=0; p < nprocs; p++){
76 for (
int i=0; i < recvCount[p]; i++){
77 if (*inBuf++ != rank+p){
93 int nstrings = nprocs * rank;
94 string *sendStrings = NULL;
97 sendStrings =
new string [nstrings];
99 std::ostringstream myMessage;
100 myMessage <<
"message from process " << rank;
102 for (
int i=0; i < nstrings; i++)
103 sendStrings[i] = myMessage.str();
105 int *counts =
new int [nprocs];
106 for (
int i=0; i < nprocs ; i++)
109 Teuchos::ArrayView<const string> sendBuf(sendStrings, nstrings);
110 Teuchos::ArrayView<const int> sendCount(counts, nprocs);
111 Teuchos::Array<int> recvCounts(nprocs, 0);
113 Teuchos::ArrayRCP<string> recvBuf;
115 Zoltan2::AlltoAllv<string>(*comm, *envPtr,
121 delete [] sendStrings;
125 for (
int i=0; i < nprocs; i++){
126 if (recvCounts[i] != i){
130 std::ostringstream msg;
131 msg <<
"message from process " << i;
132 for (
int j=0; j < recvCounts[i]; j++){
133 if (recvBuf[next++] != msg.str()){
145 std::cout <<
"FAIL" << std::endl;
147 std::cout <<
"PASS" << std::endl;
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
int main(int narg, char **arg)
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.