|
@@ -1,30 +1,13 @@
|
|
|
#include <iomanip>
|
|
|
+#include <cilk/cilk.h>
|
|
|
+#include <cilk/cilk_api.h>
|
|
|
#include "config.hpp"
|
|
|
#include "coeffs.hpp"
|
|
|
#include "polygon_generator.hpp"
|
|
|
#include "avx_matrix.hpp"
|
|
|
+#include "results.hpp"
|
|
|
|
|
|
-static const size_t numbers[]=
|
|
|
- {
|
|
|
- 1,
|
|
|
- 2,
|
|
|
- 7,
|
|
|
- 28,
|
|
|
- 124,
|
|
|
- 588,
|
|
|
- 2938,
|
|
|
- 15268,
|
|
|
- 81826,
|
|
|
- 449572,
|
|
|
- 2521270,
|
|
|
- 14385376,
|
|
|
- 83290424,
|
|
|
- 488384528,
|
|
|
- 2895432660,
|
|
|
- 17332874364,
|
|
|
- 104653427012,
|
|
|
- 636737003384
|
|
|
- };
|
|
|
+ResultsReducer cilk_result;
|
|
|
|
|
|
void box(string str){
|
|
|
size_t w=str.size();
|
|
@@ -41,8 +24,17 @@ void disp_info(){
|
|
|
box("Compute Fp's series of Self Avoiding Polygon");
|
|
|
cout<<endl;
|
|
|
cout<<" Maximal length is "<<max_len<<endl;
|
|
|
+ cout<<" Workers number is "<<__cilkrts_get_nworkers()<<endl;
|
|
|
}
|
|
|
|
|
|
+void treat(Polygon* P){
|
|
|
+ size_t l=P->length;
|
|
|
+ size_t i=l/2-1;
|
|
|
+ ++cilk_result.numbers(i);
|
|
|
+ Reel fp=P->fp();
|
|
|
+ cilk_result.sum_fp(i)+=fp;
|
|
|
+ delete P;
|
|
|
+}
|
|
|
int main(){
|
|
|
cout<<std::setprecision(20);
|
|
|
disp_info();
|
|
@@ -56,23 +48,22 @@ int main(){
|
|
|
}
|
|
|
PolygonGenerator gen;
|
|
|
size_t total=0;
|
|
|
- Polygon P;
|
|
|
+ Polygon* P;
|
|
|
while(gen.next()){
|
|
|
- P=gen.get();
|
|
|
- size_t l=P.length;
|
|
|
- ++nb[l/2-1];
|
|
|
+ P=new Polygon;
|
|
|
+ gen.set(*P);
|
|
|
+ cilk_spawn treat(P);
|
|
|
++total;
|
|
|
- Reel fp=P.fp();
|
|
|
- res[l/2-1]+=fp;
|
|
|
}
|
|
|
+ cilk_sync;
|
|
|
Reel d=256;
|
|
|
for(size_t i=1;2*i<max_len;++i){
|
|
|
Reel l=2*i+2;
|
|
|
cout<<endl<<"=== Length "<<l<<" ==="<<endl;
|
|
|
- Reel r=res[i];
|
|
|
+ Reel r=cilk_result.sum_fp(i);
|
|
|
Reel n=2*l;
|
|
|
coeff[i]=(n*r)/d;
|
|
|
- cout<<" > number : "<<nb[i]<<endl;
|
|
|
+ cout<<" > number : "<<cilk_result.numbers(i)<<endl;
|
|
|
cout<<" > value : "<<coeff[i]<<endl;
|
|
|
d*=16;
|
|
|
}
|