Browse Source

Add SCTL submodule.

Dhairya Malhotra 6 years ago
parent
commit
b45125b97f
4 changed files with 24 additions and 8 deletions
  1. 3 0
      .gitmodules
  2. 1 1
      Makefile
  3. 1 0
      SCTL
  4. 19 7
      src/nearinterac.cpp

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "SCTL"]
+	path = SCTL
+	url = http://git.dhairyamalhotra.com/dmalhotra/SCTL.git

+ 1 - 1
Makefile

@@ -12,7 +12,7 @@ else
 	CXXFLAGS += -g -rdynamic # for stack trace
 	CXXFLAGS += -g -rdynamic # for stack trace
 endif
 endif
 
 
-SCTL_INCDIR = ./sctl/include
+SCTL_INCDIR = ./SCTL/include
 
 
 #CXXFLAGS += -DSCTL_MEMDEBUG # Enable memory checks
 #CXXFLAGS += -DSCTL_MEMDEBUG # Enable memory checks
 #CXXFLAGS += -DSCTL_GLOBAL_MEM_BUFF=0 # Global memory buffer size in MB
 #CXXFLAGS += -DSCTL_GLOBAL_MEM_BUFF=0 # Global memory buffer size in MB

+ 1 - 0
SCTL

@@ -0,0 +1 @@
+Subproject commit 833d8798394530f9645f63ffe2407e53d726f9e4

+ 19 - 7
src/nearinterac.cpp

@@ -6,6 +6,7 @@ template <class Real, int DIM> class MyObject {
     MyObject() {
     MyObject() {
       for (int i = 0; i < DIM; i++) coord[i] = drand48() * 3;
       for (int i = 0; i < DIM; i++) coord[i] = drand48() * 3;
       rad = drand48() * 0.01;
       rad = drand48() * 0.01;
+      some_data = 0;
     }
     }
 
 
     const Real* Coord() const { return coord; }
     const Real* Coord() const { return coord; }
@@ -23,6 +24,8 @@ template <class Real, int DIM> class MyObject {
       memcpy(this, buff.data(), count);
       memcpy(this, buff.data(), count);
     }
     }
 
 
+    long some_data;
+
   private:
   private:
     Real coord[DIM];
     Real coord[DIM];
     Real rad;
     Real rad;
@@ -56,7 +59,11 @@ int main(int argc, char **argv) {
 
 
     NearInteraction<Real,DIM> near_interac(comm);
     NearInteraction<Real,DIM> near_interac(comm);
     sctl::Profile::Enable(true);
     sctl::Profile::Enable(true);
-    { // Repartition data
+    { // Repartition data across MPI processes (optional)
+      // so that nearby objects are on the same MPI process.
+      // This reduces interprocess communication during
+      // subsequent computations
+
       // Setup for repartition
       // Setup for repartition
       sctl::Profile::Tic("RepartSetup", &comm, true);
       sctl::Profile::Tic("RepartSetup", &comm, true);
       near_interac.SetupRepartition(src_vec, trg_vec);
       near_interac.SetupRepartition(src_vec, trg_vec);
@@ -73,6 +80,11 @@ int main(int argc, char **argv) {
       sctl::Profile::Toc();
       sctl::Profile::Toc();
     }
     }
     { // Compute near interactions
     { // Compute near interactions
+      // 1) Rearrange src_vec and trg_vec so that near pairs are on same MPI process.
+      // 2) Find pairs (s,t) in (src_vec x trg_vec); such that: distance(s,t) <= s.Rad() + t.Rad();
+      // 3) Then, compute something on (s,t) and store the result in t.
+      // 4) Finally, send t back to trg_vec.
+
       // Setup for near interaction
       // Setup for near interaction
       sctl::Profile::Tic("NearSetup", &comm, true);
       sctl::Profile::Tic("NearSetup", &comm, true);
       near_interac.SetupNearInterac(src_vec, trg_vec);
       near_interac.SetupNearInterac(src_vec, trg_vec);
@@ -90,9 +102,9 @@ int main(int argc, char **argv) {
 
 
       const auto& trg_src_interac = near_interac.GetInteractionList(); // Get interaction list
       const auto& trg_src_interac = near_interac.GetInteractionList(); // Get interaction list
       //for (auto interac : trg_src_interac) { // compute near interactions (single thread)
       //for (auto interac : trg_src_interac) { // compute near interactions (single thread)
-      //  SrcObj& t = trg_near[interac.first];
-      //  TrgObj& s = src_near[interac.second];
-      //  // ( compute interaction between t and s )
+      //  TrgObj& t = trg_near[interac.first];
+      //  const SrcObj& s = src_near[interac.second];
+      //  t.some_data += 1; // ( compute some interaction between t and s )
       //}
       //}
       #pragma omp parallel
       #pragma omp parallel
       { // compute near interactions (multiple threads)
       { // compute near interactions (multiple threads)
@@ -107,9 +119,9 @@ int main(int argc, char **argv) {
         while (b + 1 < N && trg_src_interac[b].first == trg_src_interac[b + 1].first) b++;
         while (b + 1 < N && trg_src_interac[b].first == trg_src_interac[b + 1].first) b++;
 
 
         for (long i = a; i < b; i++) {
         for (long i = a; i < b; i++) {
-          SrcObj& t = trg_near[trg_src_interac[i].first];
-          TrgObj& s = src_near[trg_src_interac[i].second];
-          // ( compute interaction between t and s )
+          TrgObj& t = trg_near[trg_src_interac[i].first];
+          const SrcObj& s = src_near[trg_src_interac[i].second];
+          t.some_data += 1; // ( compute some interaction between t and s )
         }
         }
       }
       }