54 #include <Teuchos_RCP.hpp>
58 #define MAX(a,b) ((a) > (b) ? (a) : (b))
60 #ifdef HAVE_ZOLTAN2_SCOTCH
64 #ifndef HAVE_ZOLTAN2_MPI
70 #endif // HAVE_ZOLTAN2_SCOTCH
72 #ifdef HAVE_ZOLTAN2_PARMETIS
78 #define PARMETIS_IS_OK 1
80 #endif // HAVE_ZOLTAN2_MPI
84 std::cout << (s) << " " << __FILE__ << ":" << __LINE__ << std::endl
86 int main(
int narg,
char *arg[])
88 Tpetra::ScopeGuard tscope(&narg, &arg);
102 catch (std::exception &e) {
108 unsigned int zgno = 123;
111 catch (std::exception &e) {
112 PRINTMSG(
"FAIL: unsigned int to int");
120 catch (std::exception &e) {
129 catch (std::exception &e) {
136 long long zgno = (
long long)1 << 40;
139 catch (std::exception &e) {
140 PRINTMSG(
"GOOD: big long long to int throws exception");
144 size_t zgno = (size_t)1 << 40;
147 catch (std::exception &e) {
148 PRINTMSG(
"GOOD: big size_t to int throws exception");
152 unsigned zgno = (1 << 31) + 1;
155 catch (std::exception &e) {
156 PRINTMSG(
"GOOD: huge unsigned to int throws exception");
166 long long zgno = (
long long)1 << 40;
169 catch (std::exception &e) {
170 PRINTMSG(
"FAIL: big long long to size_t");
175 size_t zgno = (size_t)1 << 40;
178 catch (std::exception &e) {
179 PRINTMSG(
"FAIL: big size_t to size_t");
190 long long zgno = (
long long)1 << 40;
193 catch (std::exception &e) {
194 PRINTMSG(
"FAIL: big long long to int64_t");
199 size_t zgno = (size_t)1 << 40;
202 catch (std::exception &e) {
203 PRINTMSG(
"FAIL: big size_t to int64_t");
209 size_t zgno = ((size_t)1 << 63) + 1 ;
212 catch (std::exception &e) {
213 PRINTMSG(
"GOOD: huge size_t to int64_t threw exception");
216 #ifdef HAVE_ZOLTAN2_SCOTCH
220 SCOTCH_Num scotchIdx;
228 catch (std::exception &e) {
229 PRINTMSG(
"FAIL: int to SCOTCH_Num");
234 unsigned int zgno = 123;
237 catch (std::exception &e) {
238 PRINTMSG(
"FAIL: unsigned int to SCOTCH_Num");
246 catch (std::exception &e) {
247 PRINTMSG(
"FAIL: long to SCOTCH_Num");
255 catch (std::exception &e) {
256 PRINTMSG(
"FAIL: size_t to SCOTCH_Num");
260 if (
sizeof(SCOTCH_Num) == 8) {
263 long long zgno = (
long long)1 << 40;
266 catch (std::exception &e) {
267 PRINTMSG(
"FAIL: big unsigned int to SCOTCH_Num");
272 size_t zgno = (size_t)1 << 40;
275 catch (std::exception &e) {
276 PRINTMSG(
"FAIL: big size_t to SCOTCH_Num");
282 if (
sizeof(SCOTCH_Num) == 4) {
284 long long zgno = (
long long)1 << 40;
287 catch (std::exception &e) {
288 PRINTMSG(
"GOOD: big long long to 4-byte SCOTCH_Num throws exception");
292 size_t zgno = (size_t)1 << 40;
295 catch (std::exception &e) {
296 PRINTMSG(
"GOOD: big size_t to 4-byte SCOTCH_Num throws exception");
300 #endif // HAVE_ZOLTAN2_SCOTCH
302 #ifdef PARMETIS_IS_OK
314 catch (std::exception &e) {
315 PRINTMSG(
"FAIL: int to ParMETIS' idx_t");
320 unsigned int zgno = 123;
323 catch (std::exception &e) {
324 PRINTMSG(
"FAIL: unsigned int to ParMETIS' idx_t");
332 catch (std::exception &e) {
333 PRINTMSG(
"FAIL: long to ParMETIS' idx_t");
341 catch (std::exception &e) {
342 PRINTMSG(
"FAIL: size_t to ParMETIS' idx_t");
346 if (
sizeof(idx_t) == 8) {
349 long long zgno = (
long long)1 << 40;
352 catch (std::exception &e) {
353 PRINTMSG(
"FAIL: big unsigned int to ParMETIS' idx_t");
358 size_t zgno = (size_t)1 << 40;
361 catch (std::exception &e) {
362 PRINTMSG(
"FAIL: big size_t to ParMETIS' idx_t");
368 if (
sizeof(idx_t) == 4) {
370 long long zgno = (
long long)1 << 40;
373 catch (std::exception &e) {
374 PRINTMSG(
"GOOD: big long long to 4-byte ParMETIS' idx_t throws exception");
378 size_t zgno = (size_t)1 << 40;
381 catch (std::exception &e) {
382 PRINTMSG(
"GOOD: big size_t to 4-byte ParMETIS' idx_t throws exception");
390 ZOLTAN_ID_PTR zoltanGID =
new ZOLTAN_ID_TYPE[4];
395 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
397 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
399 PRINTMSG(
"FAIL: NUM_ID wrong for char");
404 if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 ||
405 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
406 PRINTMSG(
"FAIL: char to ZOLTAN_ID_PTR");
413 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to char");
419 typedef short test_t;
421 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
423 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
425 PRINTMSG(
"FAIL: NUM_ID wrong for short");
430 if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 ||
431 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
432 PRINTMSG(
"FAIL: short to ZOLTAN_ID_PTR");
439 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to short");
447 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
449 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
451 PRINTMSG(
"FAIL: NUM_ID wrong for int");
456 if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 ||
457 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
458 PRINTMSG(
"FAIL: int to ZOLTAN_ID_PTR");
465 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to int");
471 typedef unsigned int test_t;
473 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
475 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
477 PRINTMSG(
"FAIL: NUM_ID wrong for unsigned int");
482 if (zoltanGID[0] != zgno || zoltanGID[1] != 0 ||
483 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
484 PRINTMSG(
"FAIL: unsigned int to ZOLTAN_ID_PTR");
491 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to unsigned int");
497 typedef long long test_t;
498 test_t zgno = ((test_t)1 << 34) + (test_t)17;
499 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
501 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
503 PRINTMSG(
"FAIL: NUM_ID wrong for long long");
508 if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned int)) {
509 if (zoltanGID[0] != 17 || zoltanGID[1] != 4 ||
510 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
511 PRINTMSG(
"FAIL: long long to ZOLTAN_ID_PTR");
515 else if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned long long)) {
516 if (test_t(zoltanGID[0]) != zgno || zoltanGID[1] != 0 ||
517 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
518 PRINTMSG(
"FAIL: long long to ZOLTAN_ID_PTR");
524 PRINTMSG(
"FAIL: unknown sizeof(ZOLTAN_ID_TYPE)");
532 std::cout <<
"back " << back <<
" != zgno " << zgno << std::endl;
533 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to long long");
539 typedef unsigned long long test_t;
540 test_t zgno = ((test_t)1 << 36) + (test_t)25;
541 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
543 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
545 PRINTMSG(
"FAIL: NUM_ID wrong for unsigned long long");
550 if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned int)) {
551 if (zoltanGID[0] != 25 || zoltanGID[1] != 16 ||
552 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
553 PRINTMSG(
"FAIL: unsigned long long to ZOLTAN_ID_PTR");
557 else if (
sizeof(ZOLTAN_ID_TYPE) ==
sizeof(
unsigned long long)) {
558 if (zoltanGID[0] != zgno || zoltanGID[1] != 0 ||
559 zoltanGID[2] != 0 || zoltanGID[3] != 0) {
560 PRINTMSG(
"FAIL: long long to ZOLTAN_ID_PTR");
566 PRINTMSG(
"FAIL: unknown sizeof(ZOLTAN_ID_TYPE)");
575 std::cout <<
"back " << back <<
" != zgno " << zgno << std::endl;
576 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to unsigned long long");
582 typedef size_t test_t;
584 for (
size_t i = 0; i < 8*
sizeof(test_t); i++) zgno += (test_t)1<<i;
585 zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0;
587 int num_gid =
MAX(1,
sizeof(test_t) /
sizeof(ZOLTAN_ID_TYPE));
589 PRINTMSG(
"FAIL: NUM_ID wrong for size_t");
594 for (
int i = 0; i < num_gid; i++)
595 if (zoltanGID[i] != std::numeric_limits<ZOLTAN_ID_TYPE>::max()) {
596 PRINTMSG(
"FAIL: size_t to ZOLTAN_ID_PTR");
599 for (
int i = num_gid; i < 4; i++)
600 if (zoltanGID[i] != 0) {
601 PRINTMSG(
"FAIL: size_t to ZOLTAN_ID_PTR");
608 std::cout <<
"back " << back <<
" != zgno " << zgno << std::endl;
609 PRINTMSG(
"FAIL: ZOLTAN_ID_PTR to size_t");
618 std::cout <<
"PASS" << std::endl;
620 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.