[MOAB-dev] commit/MOAB: danwu: Updated parallel unit test mpastrvpart for testing gather set.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Aug 29 10:19:17 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/ceaaadd761a5/
Changeset:   ceaaadd761a5
Branch:      master
User:        danwu
Date:        2013-08-29 17:18:57
Summary:     Updated parallel unit test mpastrvpart for testing gather set.

Affected #:  1 file

diff --git a/test/parallel/mpastrvpart.cpp b/test/parallel/mpastrvpart.cpp
index 0999aa0..5cacd2c 100644
--- a/test/parallel/mpastrvpart.cpp
+++ b/test/parallel/mpastrvpart.cpp
@@ -3,7 +3,7 @@
 #include "moab/ParallelComm.hpp"
 #include "moab/ProgOptions.hpp"
 #include "MBParallelConventions.h"
-#include "moab/Util.hpp"
+#include "moab/ReadUtilIface.hpp"
 
 using namespace moab;
 
@@ -33,7 +33,6 @@ int main(int argc, char* argv[])
 void test_read_parallel_mpas_trivial()
 {
   partition_method = std::string(";PARTITION_METHOD=TRIVIAL;PARALLEL_RESOLVE_SHARED_ENTS");
-
   test_read_parallel(1280, true, 1920, true);
 }
   
@@ -46,12 +45,15 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
   rval = mb.create_meshset(MESHSET_SET, file_set);
   CHECK_ERR(rval);
 
-  std::string opt = std::string("PARALLEL=READ_PART") +
-      partition_method;
+  std::string opt = std::string("PARALLEL=READ_PART") + partition_method;
+  // Create gather set in processor 0
+  opt += std::string(";GATHER_SET=0");
   rval = mb.load_file(example, &file_set, opt.c_str());
   CHECK_ERR(rval);
 
   ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  int procs = pcomm->proc_config().proc_size();
+  int rank = pcomm->proc_config().proc_rank();
 
   rval = pcomm->check_all_shared_handles();
   CHECK_ERR(rval);
@@ -60,14 +62,57 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
   Range verts;
   rval = mb.get_entities_by_type(0, MBVERTEX, verts);
   CHECK_ERR(rval);
+
+  int my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(2400, my_verts_num); // Gather set vertices included
+    else if (1 == rank)
+      CHECK_EQUAL(1122, my_verts_num); // Not owned vertices included
+  }
+
   rval = pcomm->filter_pstatus(verts, PSTATUS_NOT_OWNED, PSTATUS_NOT);
   CHECK_ERR(rval);
 
-  int my_verts_num = verts.size(), total_verts;
-  std::cout << "proc: " << pcomm->proc_config().proc_rank() << " verts:" << my_verts_num << "\n";
-  MPI_Reduce(&my_verts_num, &total_verts, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(2400, my_verts_num); // Gather set vertices included
+    else if (1 == rank)
+      CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
+  }
 
-  if (0 == pcomm->proc_config().proc_rank())
+  if (0 == rank) {
+    // Get gather set
+    EntityHandle gather_set;
+    ReadUtilIface* readUtilIface;
+    rval = mb.query_interface(readUtilIface);
+    CHECK_ERR(rval);
+    rval = readUtilIface->get_gather_set(gather_set);
+    CHECK_ERR(rval);
+
+    // Get gather set entities
+    Range gather_ents;
+    rval = mb.get_entities_by_handle(gather_set, gather_ents);
+    CHECK_ERR(rval);
+
+    // Remove gather set vertices in processor 0
+    verts = subtract(verts, gather_ents);
+  }
+
+  my_verts_num = verts.size();
+  if (test_nb_nodes && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num); // Gather set vertices excluded
+    else if (1 == rank)
+      CHECK_EQUAL(160, my_verts_num); // Not owned vertices excluded
+  }
+
+  std::cout << "proc: " << rank << " verts:" << my_verts_num << "\n";
+
+  int total_verts;
+  MPI_Reduce(&my_verts_num, &total_verts, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  if (0 == rank)
   {
     std::cout << "total vertices: " << total_verts << "\n";
     if (test_nb_nodes)
@@ -78,14 +123,57 @@ void test_read_parallel(int num_verts, bool test_nb_nodes, int num_edges, bool t
   Range edges;
   rval = mb.get_entities_by_type(0, MBEDGE, edges);
   CHECK_ERR(rval);
+
+  int my_edges_num = edges.size();
+  if (test_nb_edges && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(3358, my_edges_num); // Gather set edges included
+    else if (1 == rank)
+      CHECK_EQUAL(1444, my_edges_num); // Not owned edges included
+  }
+
   rval = pcomm->filter_pstatus(edges, PSTATUS_NOT_OWNED, PSTATUS_NOT);
   CHECK_ERR(rval);
 
-  int my_edges_num = edges.size(), total_edges;
-  std::cout << "proc: " << pcomm->proc_config().proc_rank() << " edges:" << my_edges_num << "\n";
-  MPI_Reduce(&my_edges_num, &total_edges, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  my_edges_num = edges.size();
+  if (test_nb_edges && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(3358, my_edges_num); // Gather set edges included
+    else if (1 == rank)
+      CHECK_EQUAL(482, my_edges_num); // Not owned edges excluded
+  }
 
-  if (0 == pcomm->proc_config().proc_rank())
+  if (0 == rank) {
+    // Get gather set
+    EntityHandle gather_set;
+    ReadUtilIface* readUtilIface;
+    rval = mb.query_interface(readUtilIface);
+    CHECK_ERR(rval);
+    rval = readUtilIface->get_gather_set(gather_set);
+    CHECK_ERR(rval);
+
+    // Get gather set entities
+    Range gather_ents;
+    rval = mb.get_entities_by_handle(gather_set, gather_ents);
+    CHECK_ERR(rval);
+
+    // Remove gather set edges in processor 0
+    edges = subtract(edges, gather_ents);
+  }
+
+  my_edges_num = edges.size();
+  if (test_nb_edges && 2 == procs) {
+    if (0 == rank)
+      CHECK_EQUAL(1438, my_edges_num); // Gather set edges excluded
+    else if (1 == rank)
+      CHECK_EQUAL(482, my_edges_num); // Not owned edges excluded
+  }
+
+  std::cout << "proc: " << rank << " edges:" << my_edges_num << "\n";
+
+  int total_edges;
+  MPI_Reduce(&my_edges_num, &total_edges, 1, MPI_INTEGER, MPI_SUM, 0, pcomm->proc_config().proc_comm());
+  if (0 == rank)
   {
     std::cout << "total edges: " << total_edges << "\n";
     if (test_nb_edges)
@@ -112,6 +200,8 @@ void test_multiple_loads_of_same_file()
 
   // Create mesh, no variable
   opts="PARALLEL=READ_PART;PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION_METHOD=TRIVIAL;VARIABLE=";
+  // Create gather set in processor 1
+  opts += std::string(";GATHER_SET=1");
   rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
 
@@ -119,4 +209,45 @@ void test_multiple_loads_of_same_file()
   opts = "PARALLEL=READ_PART;PARTITION;PARTITION_METHOD=TRIVIAL;NOMESH;VARIABLE=ke;TIMESTEP=0";
   rval = mb.load_file(example, &file_set, opts.c_str());
   CHECK_ERR(rval);
+
+  ParallelComm* pcomm = ParallelComm::get_pcomm(&mb, 0);
+  int procs = pcomm->proc_config().proc_size();
+  int rank = pcomm->proc_config().proc_rank();
+
+  // Make check runs this test in two processors
+  if (2 == procs) {
+    Range verts;
+    rval = mb.get_entities_by_type(0, MBVERTEX, verts);
+    CHECK_ERR(rval);
+
+    int my_verts_num = verts.size();
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num);
+    else if (1 == rank)
+      CHECK_EQUAL(2402, my_verts_num); // Gather set vertices included; Not owned vertices included
+
+    if (1 == rank) {
+      // Get gather set
+      EntityHandle gather_set;
+      ReadUtilIface* readUtilIface;
+      rval = mb.query_interface(readUtilIface);
+      CHECK_ERR(rval);
+      rval = readUtilIface->get_gather_set(gather_set);
+      CHECK_ERR(rval);
+
+      // Get gather set entities
+      Range gather_ents;
+      rval = mb.get_entities_by_handle(gather_set, gather_ents);
+      CHECK_ERR(rval);
+
+      // Remove gather set vertices in processor 1
+      verts = subtract(verts, gather_ents);
+    }
+
+    my_verts_num = verts.size();
+    if (0 == rank)
+      CHECK_EQUAL(1120, my_verts_num);
+    else if (1 == rank)
+      CHECK_EQUAL(1122, my_verts_num); // Gather set vertices excluded; Not owned vertices included
+  }
 }

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list