12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include <cilk/cilk.h>
- #include <cilk/reducer.h>
- #include <cilk/reducer_list.h>
- #include "monoid.hpp"
- typedef unsigned long int results_type[MAX_GENUS];
- void walk_children_stack(monoid m, results_type res,results_type resq);
- void walk_children_stack(monoid m, ind_t bound, results_type res,results_type resq);
- struct Results
- {
- results_type values;
- inline Results() {reset();};
- inline void reset() {for(int i=0; i<MAX_GENUS; i++) values[i] = 0;};
- };
- class ResultsReducer
- {
- struct Monoid: cilk::monoid_base<Results>
- {
- inline static void reduce (Results *left, Results *right){
- for(auto i=0; i<MAX_GENUS; i++) left->values[i] += right->values[i];
- }
- };
- private:
- cilk::reducer<Monoid> imp_;
- public:
- ResultsReducer() : imp_() {};
- inline unsigned long int & operator[](ind_t i) {
- return imp_.view().values[i];
- };
- inline results_type &get_array() {return imp_.view().values;}
- inline void reset() {imp_.view().reset();}
- };
- extern ResultsReducer cilk_results;
- extern ResultsReducer cilk_results_quotient;
- #ifdef TBB
- #include <tbb/scalable_allocator.h>
- extern cilk::reducer_list_append<monoid, tbb::scalable_allocator<monoid>> cilk_list_results;
- #else
- extern cilk::reducer_list_append<monoid> cilk_list_results;
- #endif
- void walk_children(const monoid m);
- void walk_children(const monoid &m, ind_t bound);
- void list_children(const monoid &m, ind_t bound);
- void treat(const monoid &m,results_type res,results_type res_quotient);
- void treat(const monoid &m,ResultsReducer& res,ResultsReducer& res_quotient);
|