main.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include <unordered_set>
  2. #include <cilk/cilk.h>
  3. #include <cilk/cilk_api.h>
  4. #include "config.hpp"
  5. #include "init.hpp"
  6. #include "work.hpp"
  7. #include "signature.hpp"
  8. #include "results.hpp"
  9. using namespace std;
  10. ResultsReducer cilk_result;
  11. template<Gen G> void treat(int l,const Signature<G>& s){
  12. size_t n=work(s);
  13. int rank=s.rank();
  14. // if(ns!=0) file<<s.csv()<<","<<rank<<","<<ns<<","<<ng<<endl;
  15. cilk_result.n(l)+=(rank*n);
  16. }
  17. template<Gen G> void run(){
  18. if(G==Artin){
  19. cout<<"*******************"<<endl;
  20. cout<<"* Gbraids - Artin *"<<endl;
  21. cout<<"*******************"<<endl;
  22. }
  23. else{
  24. cout<<"******************"<<endl;
  25. cout<<"* Gbraids - dual *"<<endl;
  26. cout<<"******************"<<endl;
  27. }
  28. cout<<"Number of strands : "<<STRANDS<<endl;
  29. cout<<"Combinatorics type : ";
  30. #ifdef SPHERICAL
  31. cout<<"spherical";
  32. #else
  33. cout<<"geodesic";
  34. #endif
  35. cout<<"."<<endl;
  36. cout<<"-> Init ";
  37. init<G,STRANDS>();
  38. cout<<"... done."<<endl;
  39. set<Signature<G>> prec,cur;
  40. load(1,prec);
  41. cout<<" Workers number is "<<__cilkrts_get_nworkers()<<endl;
  42. next_signatures(prec,cur);
  43. //cout<<"prec = "<<prec<<endl;
  44. //cout<<" cur = "<<cur<<endl;
  45. for(char l=2;l<=20;++l){
  46. cur.clear();
  47. cout<<"------------------------"<<endl;
  48. cout<<"Length : "<<(int)l<<endl;
  49. next_signatures(prec,cur);
  50. fstream file;
  51. file.open(DATA_DIR+to_string((int)l)+".csv",ios::out);
  52. size_t n_sph=0;
  53. size_t n_geo=0;
  54. for(auto it=cur.begin();it!=cur.end();++it){
  55. cilk_spawn treat(l,*it);
  56. //treat(l,*it);
  57. }
  58. cilk_sync;
  59. cout<<"-> "<<cilk_result.n(l)<<endl;
  60. swap(cur,prec);
  61. }
  62. }
  63. int main(int argc,char** argv){
  64. run<GEN>();
  65. }