Ver código fonte

Increase parallelization

Jean Fromentin 1 ano atrás
pai
commit
41e7572844
5 arquivos alterados com 27 adições e 20 exclusões
  1. 3 3
      c++/src/config.hpp
  2. 1 1
      c++/src/main-alone.cpp
  3. 19 9
      c++/src/main-server.cpp
  4. 3 6
      c++/src/results.hpp
  5. 1 1
      c++/src/treat.hpp

+ 3 - 3
c++/src/config.hpp

@@ -4,12 +4,12 @@
 
 using namespace std;
 //#define DATA_DIR string("/home/fromentin/data/") //string("/workdir/lmpa/jfromentin/")
-#define SERVER_IP "10.1.0.104" //"192.168.1.3" //Orval 04
-#define SERVER_PORT 55556
+#define SERVER_IP "127.0.0.1" //"10.1.0.104" //"192.168.1.3" //Orval 04
+#define SERVER_PORT 55555
 #define MAX_MSG_SIZE 65536
 #define MAX_CLIENTS 2048
 #define MAX_WORKERS 2048
 
-#define MAX_GENUS 60
+#define MAX_GENUS 50
 
 #endif

+ 1 - 1
c++/src/main-alone.cpp

@@ -16,6 +16,6 @@ int main(int argc,char** argv){
     print_Semigroup_gen(res.S_counter_example);
   }
   for(size_t g=0;g<=MAX_GENUS;++g){
-    cout<<g<<","<<res.n1[g]<<","<<res.n2[g]<<endl;
+    cout<<g<<","<<res.n[g]<<endl;
   }
 }

+ 19 - 9
c++/src/main-server.cpp

@@ -8,13 +8,7 @@
 
 using namespace std;
 
-
-
-int main(int argc,char** argv){
-  Results res;
-  clear_results(res);
-  // Compute the Forest
-  list<Semigroup> forest;
+void  init_parallelize(list<Semigroup>& forest,Results& res){
   Semigroup O;
   init_full_N(O);
   for(size_t g=0;g<MAX_GENUS;++g){
@@ -26,11 +20,27 @@ int main(int argc,char** argv){
       it.move_next();
       Semigroup Onext=remove_generator(O,it.get_gen(),pos++);
       while(it.move_next()){
-	forest.push_back(remove_generator(O,it.get_gen(),pos++));
+	Semigroup son=remove_generator(O,it.get_gen(),pos++);
+	if(not cut(son)){
+	  treat(son,res);
+	  auto it2=generator_iter<CHILDREN>(son);
+	  ind_t pos2=0;
+	  while(it2.move_next()){
+	    forest.push_back(remove_generator(son,it2.get_gen(),pos2++));
+	  }
+	}
       }
       O=Onext;
     }
   }
+  if(not cut(O)) treat(O,res);
+}
+
+int main(int argc,char** argv){
+  Results res;
+  clear_results(res);
+  list<Semigroup> forest;
+  init_parallelize(forest,res);
   // Set tasks
   size_t nb_tasks=forest.size();
   Task* tasks=new Task[nb_tasks];
@@ -84,6 +94,6 @@ int main(int argc,char** argv){
     }
   }
   for(size_t g=0;g<=MAX_GENUS;++g){
-    cout<<g<<","<<res.n1[g]<<","<<res.n2[g]<<endl;
+    cout<<g<<","<<res.n[g]<<endl;
   }
 }

+ 3 - 6
c++/src/results.hpp

@@ -4,8 +4,7 @@
 #include "semigroup.hpp"
 
 struct Results{
-  size_t n1[MAX_GENUS+1];
-  size_t n2[MAX_GENUS+1];
+  size_t n[MAX_GENUS+1];
   bool has_counter_example;
   Semigroup S_counter_example;
 };
@@ -16,8 +15,7 @@ void add_results(Results& Rdest,const Results& Rsrc);
 inline void clear_results(Results& R){
   R.has_counter_example=false;
   for(size_t g=0;g<=MAX_GENUS;++g){
-    R.n1[g]=0;
-    R.n2[g]=0;
+    R.n[g]=0;
   }
 }
 
@@ -26,8 +24,7 @@ inline void add_results(Results& Rdest,const Results& Rsrc){
     Rdest.S_counter_example=Rsrc.S_counter_example;
   }
   for(size_t g=0;g<=MAX_GENUS;++g){
-    Rdest.n1[g]+=Rsrc.n1[g];
-    Rdest.n2[g]+=Rsrc.n2[g];
+    Rdest.n[g]+=Rsrc.n[g];
   }
 }
 #endif

+ 1 - 1
c++/src/treat.hpp

@@ -6,7 +6,7 @@
 void treat(const Semigroup& S,Results& res);
   
 inline void treat(const Semigroup& S,Results& res){
-  res.n1[S.genus]++;
+  res.n[S.genus]++;
 }
 
 #endif