17 #include <Teuchos_RCP.hpp>
21 #define MAX(a,b) ((a) > (b) ? (a) : (b))
23 #ifdef HAVE_ZOLTAN2_SCOTCH
27 #ifndef HAVE_ZOLTAN2_MPI
33 #endif // HAVE_ZOLTAN2_SCOTCH
35 #ifdef HAVE_ZOLTAN2_PARMETIS
41 #define PARMETIS_IS_OK 1
43 #endif // HAVE_ZOLTAN2_MPI
47 std::cout << (s) << " " << __FILE__ << ":" << __LINE__ << std::endl
49 int main(
int narg,
char *arg[])
51 Tpetra::ScopeGuard tscope(&narg, &arg);
65 catch (std::exception &e) {
71 unsigned int zgno = 123;
74 catch (std::exception &e) {
75 PRINTMSG(
"FAIL: unsigned int to int");
83 catch (std::exception &e) {
92 catch (std::exception &e) {
99 long long zgno = (
long long)1 << 40;
102 catch (std::exception &e) {
103 PRINTMSG(
"GOOD: big long long to int throws exception");
107 size_t zgno = (size_t)1 << 40;
110 catch (std::exception &e) {
111 PRINTMSG(
"GOOD: big size_t to int throws exception");
115 unsigned zgno = (1 << 31) + 1;
118 catch (std::exception &e) {
119 PRINTMSG(
"GOOD: huge unsigned to int throws exception");
129 long long zgno = (
long long)1 << 40;
132 catch (std::exception &e) {
133 PRINTMSG(
"FAIL: big long long to size_t");
138 size_t zgno = (size_t)1 << 40;
141 catch (std::exception &e) {
142 PRINTMSG(
"FAIL: big size_t to size_t");
153 long long zgno = (
long long)1 << 40;
156 catch (std::exception &e) {
157 PRINTMSG(
"FAIL: big long long to int64_t");
162 size_t zgno = (size_t)1 << 40;
165 catch (std::exception &e) {
166 PRINTMSG(
"FAIL: big size_t to int64_t");
172 size_t zgno = ((size_t)1 << 63) + 1 ;
175 catch (std::exception &e) {
176 PRINTMSG(
"GOOD: huge size_t to int64_t threw exception");
179 #ifdef HAVE_ZOLTAN2_SCOTCH
183 SCOTCH_Num scotchIdx;
191 catch (std::exception &e) {
192 PRINTMSG(
"FAIL: int to SCOTCH_Num");
197 unsigned int zgno = 123;
200 catch (std::exception &e) {
201 PRINTMSG(
"FAIL: unsigned int to SCOTCH_Num");
209 catch (std::exception &e) {
210 PRINTMSG(
"FAIL: long to SCOTCH_Num");
218 catch (std::exception &e) {
219 PRINTMSG(
"FAIL: size_t to SCOTCH_Num");
223 if (
sizeof(SCOTCH_Num) == 8) {
226 long long zgno = (
long long)1 << 40;
229 catch (std::exception &e) {
230 PRINTMSG(
"FAIL: big unsigned int to SCOTCH_Num");
235 size_t zgno = (size_t)1 << 40;
238 catch (std::exception &e) {
239 PRINTMSG(
"FAIL: big size_t to SCOTCH_Num");
245 if (
sizeof(SCOTCH_Num) == 4) {
247 long long zgno = (
long long)1 << 40;
250 catch (std::exception &e) {
251 PRINTMSG(
"GOOD: big long long to 4-byte SCOTCH_Num throws exception");
255 size_t zgno = (size_t)1 << 40;
258 catch (std::exception &e) {
259 PRINTMSG(
"GOOD: big size_t to 4-byte SCOTCH_Num throws exception");
263 #endif // HAVE_ZOLTAN2_SCOTCH
265 #ifdef PARMETIS_IS_OK
277 catch (std::exception &e) {
278 PRINTMSG(
"FAIL: int to ParMETIS' idx_t");
283 unsigned int zgno = 123;
286 catch (std::exception &e) {
287 PRINTMSG(
"FAIL: unsigned int to ParMETIS' idx_t");
295 catch (std::exception &e) {
296 PRINTMSG(
"FAIL: long to ParMETIS' idx_t");
304 catch (std::exception &e) {
305 PRINTMSG(
"FAIL: size_t to ParMETIS' idx_t");
309 if (
sizeof(idx_t) == 8) {
312 long long zgno = (
long long)1 << 40;
315 catch (std::exception &e) {
316 PRINTMSG(
"FAIL: big unsigned int to ParMETIS' idx_t");
321 size_t zgno = (size_t)1 << 40;
324 catch (std::exception &e) {
325 PRINTMSG(
"FAIL: big size_t to ParMETIS' idx_t");
331 if (
sizeof(idx_t) == 4) {
333 long long zgno = (
long long)1 << 40;
336 catch (std::exception &e) {
337 PRINTMSG(
"GOOD: big long long to 4-byte ParMETIS' idx_t throws exception");
341 size_t zgno = (size_t)1 << 40;
344 catch (std::exception &e) {
345 PRINTMSG(
"GOOD: big size_t to 4-byte ParMETIS' idx_t throws exception");
353 ZOLTAN_ID_PTR zoltanGID =
new ZOLTAN_ID_TYPE[4];
358 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
360 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
362 PRINTMSG(
"FAIL: NUM_ID wrong for char");
367 if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 ||
368 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
369 PRINTMSG(
"FAIL: char to ZOLTAN_ID_PTR");
376 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to char");
382 typedef short test_t;
384 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
386 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
388 PRINTMSG(
"FAIL: NUM_ID wrong for short");
393 if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 ||
394 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
395 PRINTMSG(
"FAIL: short to ZOLTAN_ID_PTR");
402 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to short");
410 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
412 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
414 PRINTMSG(
"FAIL: NUM_ID wrong for int");
419 if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 ||
420 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
421 PRINTMSG(
"FAIL: int to ZOLTAN_ID_PTR");
428 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to int");
434 typedef unsigned int test_t;
436 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
438 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
440 PRINTMSG(
"FAIL: NUM_ID wrong for unsigned int");
445 if (zoltanGID[0] != zgno || zoltanGID[1] != 0 ||
446 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
447 PRINTMSG(
"FAIL: unsigned int to ZOLTAN_ID_PTR");
454 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to unsigned int");
460 typedef long long test_t;
461 test_t zgno = ((test_t)1 << 34) + (test_t)17;
462 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
464 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
466 PRINTMSG(
"FAIL: NUM_ID wrong for long long");
471 if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned int)) {
472 if (zoltanGID[0] != 17 || zoltanGID[1] != 4 ||
473 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
474 PRINTMSG(
"FAIL: long long to ZOLTAN_ID_PTR");
478 else if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned long long)) {
479 if (test_t(zoltanGID[0]) != zgno || zoltanGID[1] != 0 ||
480 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
481 PRINTMSG(
"FAIL: long long to ZOLTAN_ID_PTR");
487 PRINTMSG(
"FAIL: unknown sizeof(ZOLTAN_ID_TYPE)");
495 std::cout <<
"back " << back <<
" != zgno " << zgno << std::endl;
496 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to long long");
502 typedef unsigned long long test_t;
503 test_t zgno = ((test_t)1 << 36) + (test_t)25;
504 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
506 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
508 PRINTMSG(
"FAIL: NUM_ID wrong for unsigned long long");
513 if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned int)) {
514 if (zoltanGID[0] != 25 || zoltanGID[1] != 16 ||
515 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
516 PRINTMSG(
"FAIL: unsigned long long to ZOLTAN_ID_PTR");
520 else if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned long long)) {
521 if (zoltanGID[0] != zgno || zoltanGID[1] != 0 ||
522 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
523 PRINTMSG(
"FAIL: long long to ZOLTAN_ID_PTR");
529 PRINTMSG(
"FAIL: unknown sizeof(ZOLTAN_ID_TYPE)");
538 std::cout <<
"back " << back <<
" != zgno " << zgno << std::endl;
539 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to unsigned long long");
545 typedef size_t test_t;
547 for (
size_t i = 0; i < 8*
sizeof(test_t); i++) zgno += (test_t)1<<i;
548 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
550 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
552 PRINTMSG(
"FAIL: NUM_ID wrong for size_t");
557 for (
int i = 0; i < num_gid; i++)
558 if (zoltanGID[i] != std::numeric_limits<ZOLTAN_ID_TYPE>::max()) {
559 PRINTMSG(
"FAIL: size_t to ZOLTAN_ID_PTR");
562 for (
int i = num_gid; i < 4; i++)
563 if (zoltanGID[i] != 0) {
564 PRINTMSG(
"FAIL: size_t to ZOLTAN_ID_PTR");
571 std::cout <<
"back " << back <<
" != zgno " << zgno << std::endl;
572 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to size_t");
581 std::cout <<
"PASS" << std::endl;
583 std::cout <<
"FAIL" << std::endl;
int main(int narg, char **arg)
static void ASSIGN(first_t &a, second_t b)
Traits class to handle conversions between gno_t/lno_t and TPL data types (e.g., ParMETIS's idx_t...
Defines the Environment class.