int main(int argc, char **argv) { int nerrors=0, i; int rank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); #define NR_TYPES 3 MPI_Offset expected_sizes[NR_TYPES] = {1024UL*1024UL*2400UL, 2346319872, 2346319872}; MPI_Datatype types[NR_TYPES]; /* a contig type, itself large, but does not need 8 byte aints */ types[0] = make_largexfer_type_struct(expected_sizes[0]); /* struct with addresses out past 2 GiB */ types[1] = make_largexfer_type_struct(expected_sizes[1]); /* similar, but with hindexed type */ types[2] = make_largexfer_type_hindexed(expected_sizes[2]); for (i=0; i<NR_TYPES; i++) { if (types[i] != MPI_DATATYPE_NULL) { nerrors += testtype(types[i], expected_sizes[i]); MPI_Type_free(&(types[i])); } } MPI_Finalize(); if (rank == 0) { if (nerrors) { printf("found %d errors\n", nerrors); } else { printf(" No errors\n"); } } return 0; }
static void setoption(char *opt) { if (strncasecmp(opt, "all", 3) == 0) { show_settings(ISC_TRUE, ISC_FALSE); } else if (strncasecmp(opt, "class=", 6) == 0) { if (testclass(&opt[6])) strlcpy(defclass, &opt[6], sizeof(defclass)); } else if (strncasecmp(opt, "cl=", 3) == 0) { if (testclass(&opt[3])) strlcpy(defclass, &opt[3], sizeof(defclass)); } else if (strncasecmp(opt, "type=", 5) == 0) { if (testtype(&opt[5])) strlcpy(deftype, &opt[5], sizeof(deftype)); } else if (strncasecmp(opt, "ty=", 3) == 0) { if (testtype(&opt[3])) strlcpy(deftype, &opt[3], sizeof(deftype)); } else if (strncasecmp(opt, "querytype=", 10) == 0) { if (testtype(&opt[10])) strlcpy(deftype, &opt[10], sizeof(deftype)); } else if (strncasecmp(opt, "query=", 6) == 0) { if (testtype(&opt[6])) strlcpy(deftype, &opt[6], sizeof(deftype)); } else if (strncasecmp(opt, "qu=", 3) == 0) { if (testtype(&opt[3])) strlcpy(deftype, &opt[3], sizeof(deftype)); } else if (strncasecmp(opt, "q=", 2) == 0) { if (testtype(&opt[2])) strlcpy(deftype, &opt[2], sizeof(deftype)); } else if (strncasecmp(opt, "domain=", 7) == 0) { strlcpy(domainopt, &opt[7], sizeof(domainopt)); set_search_domain(domainopt); usesearch = ISC_TRUE; } else if (strncasecmp(opt, "do=", 3) == 0) { strlcpy(domainopt, &opt[3], sizeof(domainopt)); set_search_domain(domainopt); usesearch = ISC_TRUE; } else if (strncasecmp(opt, "port=", 5) == 0) { set_port(&opt[5]); } else if (strncasecmp(opt, "po=", 3) == 0) { set_port(&opt[3]); } else if (strncasecmp(opt, "timeout=", 8) == 0) { set_timeout(&opt[8]); } else if (strncasecmp(opt, "t=", 2) == 0) { set_timeout(&opt[2]); } else if (strncasecmp(opt, "rec", 3) == 0) { recurse = ISC_TRUE; } else if (strncasecmp(opt, "norec", 5) == 0) { recurse = ISC_FALSE; } else if (strncasecmp(opt, "retry=", 6) == 0) { set_tries(&opt[6]); } else if (strncasecmp(opt, "ret=", 4) == 0) { set_tries(&opt[4]); } else if (strncasecmp(opt, "def", 3) == 0) { usesearch = ISC_TRUE; } else if (strncasecmp(opt, "nodef", 5) == 0) { usesearch = ISC_FALSE; } else if (strncasecmp(opt, "vc", 3) == 0) { tcpmode = ISC_TRUE; } else if (strncasecmp(opt, "novc", 5) == 0) { tcpmode = ISC_FALSE; } else if (strncasecmp(opt, "deb", 3) == 0) { short_form = ISC_FALSE; showsearch = ISC_TRUE; } else if (strncasecmp(opt, "nodeb", 5) == 0) { short_form = ISC_TRUE; showsearch = ISC_FALSE; } else if (strncasecmp(opt, "d2", 2) == 0) { debugging = ISC_TRUE; } else if (strncasecmp(opt, "nod2", 4) == 0) { debugging = ISC_FALSE; } else if (strncasecmp(opt, "search", 3) == 0) { usesearch = ISC_TRUE; } else if (strncasecmp(opt, "nosearch", 5) == 0) { usesearch = ISC_FALSE; } else if (strncasecmp(opt, "sil", 3) == 0) { /* deprecation_msg = ISC_FALSE; */ } else if (strncasecmp(opt, "fail", 3) == 0) { nofail=ISC_FALSE; } else if (strncasecmp(opt, "nofail", 3) == 0) { nofail=ISC_TRUE; } else if (strncasecmp(opt, "ndots=", 6) == 0) { set_ndots(&opt[6]); } else { printf("*** Invalid option: %s\n", opt); } }
void test() { testtype::verbose = false; printf("sizeof(int) %lu, sizeof(void *) %lu, sizeof list<int> %lu, sizeof(iterator) %lu, sizeof(*iterator) %lu\n", (unsigned long)sizeof(int), (unsigned long)sizeof(void *), (unsigned long)sizeof(ttl::list<int>), (unsigned long)sizeof(ttl::list<int>().begin()), (unsigned long)sizeof(*ttl::list<int>().begin())); const testtype nine(9); ttl::list<testtype> dl(10, nine); assert(dl.size() < dl.max_size()); assert(dl.front() == constify(dl).front() && dl.front() == nine); assert(dl.back() == constify(dl).back() && dl.back() == nine); assert(ttl::count(dl.begin(), dl.end(), dl.front()) == 10 && ttl::count(dl.begin(), dl.end(), dl.back()) == 10 && ttl::count(dl.begin(), dl.end(), nine) == 10 && ttl::count(dl.begin(), dl.end(), nine) == (int)dl.size()); assert(ttl::count(dl.cbegin(), dl.cend(), nine) == 10); assert(ttl::count(constify(dl).begin(), constify(dl).end(), nine) == 10); { ttl::list<testtype> dl1 = dl; ttl::list<testtype> dl2 = dl; assert(dl1 == dl); assert(!(dl2 != dl1)); dl1.clear(); assert(dl1.empty()); dl1.swap(dl2); // case 1 assert(dl2.empty()); assert(ttl::count(dl1.cbegin(), dl1.cend(), nine) == 10); dl1.swap(dl2); // case 2 assert(dl1.empty()); assert(ttl::count(dl2.cbegin(), dl2.cend(), nine) == 10); dl1.push_back(testtype(0xfeed)); dl1.swap(dl2); // case 3 assert(ttl::count(dl1.cbegin(), dl1.cend(), nine) == 10); assert(dl2.front() == testtype(0xfeed) && dl2.front() == dl2.back() && ++dl2.begin() == dl2.end()); } int c = 0; for (ttl::list<testtype>::iterator i = dl.begin(); i != dl.end(); ++i) { assert(*i == nine); i->value = c++; } for (ttl::list<testtype>::iterator i = dl.end(); i-- != dl.begin();) { assert(i->value == --c); *i = testtype(c); } dl.erase(++dl.begin(), advanceIt(dl.begin(), 9)); // dl = [0, 8, 9] print_iter("after erase(from, to), dl:", dl.cbegin(), dl.cend()); assert(dl.front() == testtype(0)); assert(*++dl.cbegin() == testtype(8)); assert(dl.back() == testtype(9)); assert(dl.size() == 3); dl.push_front(testtype(999)); // dl = [999, 0, 8, 9] assert(dl.front() == testtype(999)); assert(*++dl.cbegin() == testtype(0)); assert(dl.back() == testtype(9)); assert(dl.size() == 4); dl.push_front(testtype(1000)); // dl = [1000, 999, 0, 8, 9] assert(dl.front() == testtype(1000)); assert(dl.size() == 5); dl.pop_front(); // dl = [999, 0, 9] assert(dl.front() == testtype(999)); assert(dl.size() == 4); dl.push_back(testtype(1000)); // dl = [999, 0, 8, 9, 1000] assert(dl.back() == testtype(1000)); assert(dl.size() == 5); dl.pop_front(); // dl = [0, 8, 9, 1000] assert(dl.front() == testtype(0)); assert(dl.size() == 4); dl.pop_back(); // dl = [0, 8, 9] assert(dl.back() == testtype(9)); dl.pop_back(); // dl = [0, 8] assert(dl.back() == testtype(8)); assert(dl.size() == 2); dl.insert(dl.begin(), testtype(1001)); // dl = [1001, 0, 8] assert(dl.front() == testtype(1001)); assert(dl.size() == 3); dl.insert(++dl.begin(), testtype(1002)); // dl = [1001, 1002, 0, 8] dl.insert(++ ++dl.begin(), testtype(1003)); // dl = [1001, 1002, 1003, 0, 8] assert(dl.size() == 5); dl.erase(dl.cbegin()); // dl = [1002, 1003, 0, 8] assert(dl.front() == testtype(1002)); assert(dl.size() == 4); print_iter("after erase(at):", dl.cbegin(), dl.cend()); static const int data[] = {'0','1','2','3'}; static const int ascii[] = {'A','B','C','D'}; dl.insert(dl.begin(), data, data + countof(data)); print_iter("after insert<>(at, from, to):", dl.cbegin(), dl.cend()); assert(dl.size() == 8); { ttl::list<testtype> dl1, dl2; dl1.assign(data, data + countof(data)); dl2.assign(data, data + countof(data)); print_iter("after assign dl1:", dl1.cbegin(), dl1.cend()); print_iter("after assign dl2:", dl2.cbegin(), dl2.cend()); assert(ttl::equal(dl1.cbegin(), dl1.cend(), data)); assert(ttl::equal(dl1.cbegin(), dl1.cend(), dl2.begin())); assert(dl1.size() == dl2.size()); } { ttl::list<testtype> dl1, dl2; dl1.assign(data, data + countof(data)); dl2.assign(data, data + countof(data)); dl1.splice(dl1.begin(), dl2); print_iter("after splice dl1:", dl1.cbegin(), dl1.cend()); dl2.assign(ascii, ascii + countof(ascii)); dl1.splice(dl1.begin(), dl2, dl2.begin()); print_iter("after splice(from) dl1:", dl1.cbegin(), dl1.cend()); print_iter(" dl2:", dl2.cbegin(), dl2.cend()); dl1.splice(dl1.begin(), dl2, dl2.begin(), ++ ++dl2.begin()); print_iter("after splice(from,to) dl1:", dl1.cbegin(), dl1.cend()); print_iter(" dl2:", dl2.cbegin(), dl2.cend()); } print_iter("before reverse, dl:", dl.cbegin(), dl.cend()); dl.reverse(); print_iter("after reverse, dl :", dl.cbegin(), dl.cend()); dl.remove(testtype(1003)); print_iter("after remove, dl :", dl.cbegin(), dl.cend()); assert(ttl::count_if(dl.begin(), dl.end(), t::equal_to<testtype>(1003)) == 0); dl.remove_if(t::equal_to<testtype>(testtype(1002))); print_iter("after remove, dl :", dl.cbegin(), dl.cend()); assert(ttl::count_if(dl.begin(), dl.end(), t::equal_to<testtype>(1002)) == 0); dl.insert(dl.end(), 10, nine); print_iter_ptr("before unique, dl :", dl.cbegin(), dl.cend()); dl.unique(); print_iter_ptr("after unique, dl :", dl.cbegin(), dl.cend()); assert(ttl::count_if(dl.begin(), dl.end(), t::equal_to<testtype>(nine)) == 1); dl.insert(dl.end(), 10, nine); print_iter_ptr("before unique(pred), dl :", dl.cbegin(), dl.cend()); dl.unique(ttl::equal_to<testtype>()); // binary predicate print_iter_ptr("after unique(pred), dl :", dl.cbegin(), dl.cend()); assert(ttl::count_if(dl.begin(), dl.end(), t::equal_to<testtype>(nine)) == 1); { ttl::list<testtype> dl1, dl2; dl1.assign(data, data + countof(data)); dl1.push_back(testtype('a')); dl2.assign(ascii, ascii + countof(ascii)); dl2.push_back(testtype('b')); print_iter("dl1:", dl1.cbegin(), dl1.cend()); print_iter("dl2:", dl2.cbegin(), dl2.cend()); ttl::list<testtype> dl1copy = dl1; ttl::list<testtype> dl2copy = dl2; dl1.merge(dl2copy); print_iter("after merge, dl1:", dl1.cbegin(), dl1.cend()); dl2.merge(dl1copy, ttl::less<testtype>()); print_iter("after merge, dl2:", dl1.cbegin(), dl1.cend()); assert(dl1copy.empty()); assert(dl2copy.empty()); assert(ttl::equal(dl1.cbegin(), dl1.cend(), dl2.cbegin())); dl2copy.merge(dl2); // merge into empty list assert(ttl::equal(dl1.cbegin(), dl1.cend(), dl2copy.cbegin())); dl2copy.merge(dl1copy); // merge an empty list assert(ttl::equal(dl1.cbegin(), dl1.cend(), dl2copy.cbegin())); } dl.resize(40); assert(dl.size() == 40); dl.resize(4); assert(dl.size() == 4); dl.resize(30, nine); assert(dl.size() == 30); assert(ttl::count(dl.begin(), dl.end(), nine) == 26); printf("dtors\n"); }
int main(int argc, char **argv) { int count=2; int blocks[2]; int disps[2]; int ndims=2; int sizes[2]; int subs[2]; int starts[2]; MPI_Datatype baseindex, indexed1G, indexed3G, indexed6G; MPI_Datatype subarray1G, subarray3G, subarray6G; int ret, rank; MPI_Init(&argc, &argv); if (argc != 2) { fprintf(stderr, "usage: %s <filename>\n", argv[0]); MPI_Abort(MPI_COMM_WORLD, 1); } MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* base type: 1MB indexed type of ints*/ count = 2; blocks[0] = 1; disps[0] = 0; blocks[1] = 1; disps[1] = 1024*256-1; MPI_Type_indexed(count, blocks, disps, MPI_INT, &baseindex); /* simple case: 1GB extent */ MPI_Type_contiguous(1024, baseindex, &indexed1G); MPI_Type_commit(&indexed1G); /* a little trickier: 3Gb extent */ MPI_Type_contiguous(3072, baseindex, &indexed3G); MPI_Type_commit(&indexed3G); /* and finally 6GB extent */ MPI_Type_contiguous(6144, baseindex, &indexed6G); MPI_Type_commit(&indexed6G); /* TODO: * - add a darray test * - add a test with crazy extents */ sizes[0] = 1024*16; sizes[1] = 1024*16; subs[0] = subs[1] = 256; starts[0] = starts[1] = 0; MPI_Type_create_subarray(ndims, sizes, subs, starts, MPI_ORDER_C, MPI_INT, &subarray1G); MPI_Type_commit(&subarray1G); sizes[1] = 1024*16*3; MPI_Type_create_subarray(ndims, sizes, subs, starts, MPI_ORDER_C, MPI_INT, &subarray3G); MPI_Type_commit(&subarray3G); sizes[1] = 1024*16*6; MPI_Type_create_subarray(ndims, sizes, subs, starts, MPI_ORDER_C, MPI_INT, &subarray6G); MPI_Type_commit(&subarray6G); /* assume command line arguments make it out to all processes */ ret = testtype(argv[1], indexed1G, (int64_t)1024*1024*1024); ret = testtype(argv[1], indexed3G, (int64_t)1024*1024*1024*3); ret = testtype(argv[1], indexed6G, (int64_t)1024*1024*1024*6); ret = testtype(argv[1], subarray1G, (int64_t)1024*1024*1024); ret = testtype(argv[1], subarray3G, (int64_t)1024*1024*1024*3); ret = testtype(argv[1], subarray6G, (int64_t)1024*1024*1024*6); if(!ret && !rank) fprintf(stderr, " No Errors\n"); MPI_Finalize(); return (-ret); }