main-cilk.cpp 843 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <cilk/cilk.h>
  2. #include <cilk/cilk_api.h>
  3. #include <iostream>
  4. #include "work.hpp"
  5. #include "results_cilk.hpp"
  6. using namespace std;
  7. void cilk_walk(Semigroup S){
  8. Semigroup temp;
  9. if(S.genus<MAX_GENUS-STACK_BOUND){
  10. treat(S,cilk_results.get_results());
  11. auto it = generator_iter<CHILDREN>(S);
  12. ind_t pos=0;
  13. while (it.move_next()){
  14. remove_generator(temp,S, it.get_gen(),pos++);
  15. if(not cut(temp)){
  16. cilk_spawn cilk_walk(temp);
  17. }
  18. }
  19. //cilk_sync;
  20. }
  21. else
  22. work_on(S,cilk_results.get_results());
  23. }
  24. int main(){
  25. __cilkrts_set_param("nworkers", CILK_WORKERS);
  26. cout<<"Cilk workers : "<<__cilkrts_get_nworkers()<<endl;
  27. Semigroup N;
  28. init_full_N(N);
  29. cilk_walk(N);
  30. for (size_t g=0; g<=MAX_GENUS; g++){
  31. cout << g << " : " <<cilk_results.get_results().n[g] << endl;
  32. }
  33. return 0;
  34. };