60int main(
int argc,
char *argv[]) {
66 MPI_Init(&argc,&argv);
75 bool veryVerbose =
false;
78 if (argc>1)
if (argv[1][0]==
'-' && argv[1][1]==
'v') verbose =
true;
81 if (argc>2)
if (argv[2][0]==
'-' && argv[2][1]==
'v') veryVerbose =
true;
83 if (verbose && Comm.
MyPID()==0)
88 if (verbose) std::cout << Comm << std::endl << std::flush;
90 bool verbose1 = verbose;
91 if (verbose) verbose = (Comm.
MyPID()==0);
93 bool veryVerbose1 = veryVerbose;
94 if (veryVerbose) veryVerbose = (Comm.
MyPID()==0);
96 int NumMyElements = 100;
97 if (veryVerbose1) NumMyElements = 10;
98 NumMyElements += Comm.
MyPID();
99 int MaxNumMyElements = NumMyElements+Comm.
NumProc()-1;
100 int * ElementSizeList =
new int[NumMyElements];
101 long long * MyGlobalElements =
new long long[NumMyElements];
103 for (i = 0; i<NumMyElements; i++) {
104 MyGlobalElements[i] = (
long long)(Comm.
MyPID()*MaxNumMyElements+i)*2;
105 ElementSizeList[i] = i%6 + 2;
109 -1LL, NumMyElements, MyGlobalElements, ElementSizeList,
113 delete [] ElementSizeList;
114 delete [] MyGlobalElements;
118 int * elementColors =
new int[NumMyElements];
121 int * colorCount =
new int[maxcolor];
122 int ** colorLIDs =
new int*[maxcolor];
123 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
124 for (i=0; i<maxcolor; i++) colorLIDs[i] = 0;
129 if (i%2==0) C0[i] = i%6+5+i%14;
130 else C0(Map.
GID64(i)) = i%5+1;
131 elementColors[i] = C0[i];
136 std::cout <<
"Original Map Coloring using element-by-element definitions" << std::endl;
138 std::cout << C0 << std::endl;
141 for (i=0; i<maxcolor; i++)
142 if (colorCount[i]>0) {
144 colorLIDs[i] =
new int[colorCount[i]];
146 for (i=0; i<maxcolor; i++) colorCount[i] = 0;
147 for (i=0; i<Map.
NumMyElements(); i++) colorLIDs[C0[i]][colorCount[C0[i]]++] = i;
151 int newDefaultColor = -1;
154 std::cout <<
"Same Map Coloring using one-time construction" << std::endl;
156 std::cout << C1 << std::endl;
162 std::cout <<
"Same Map Coloring using copy constructor" << std::endl;
164 std::cout << C1 << std::endl;
170 for (i=0; i<maxcolor; i++) {
172 assert(colorCount[i]==curNumElementsWithColor);
173 if (curNumElementsWithColor==0) {
177 for (
int j=0; j<curNumElementsWithColor; j++) assert(C2.
ColorLIDList(i)[j]==colorLIDs[i][j]);
187 assert(Map1->
GID64(i)==Map.
GID64(colorLIDs[curColor][i]));
188 assert(Map2->
GID64(i)==Map.
GID64(colorLIDs[curColor][i]));
202 long long NumMyElements0 = 0;
211 elementColorValues0.
Import(elementColorValues, importer,
Insert);
214 -1LL,NumMyElements0, elementIDs0.
Values(),
223 assert(ColoringOnPE0[i]==elementColorValues0[i]);
226 std::cout <<
"Same Map Coloring on PE 0 only" << std::endl;
228 std::cout << ColoringOnPE0 << std::endl;
233 std::cout <<
"Same Map Coloring after Import/Export exercise" << std::endl;
235 std::cout << ColoringOnPE0 << std::endl;
238 if (verbose) std::cout <<
"Checked OK\n\n" << std::endl;
241 if (verbose) std::cout <<
"Test ostream << operator" << std::endl << std::flush;
242 std::cout << C0 << std::endl;
246 delete [] elementColors;
247 for (i=0; i<maxcolor; i++)
if (colorLIDs[i]!=0)
delete [] colorLIDs[i];
249 delete [] colorCount;
int main(int argc, char *argv[])