#include #include #include #include using namespace ff; using namespace std; typedef struct __task { int id; int start; int end; } TASK; typedef union __res { float x; float pad[16]; } RES; int n; float ** mat; RES * vec; class Emitter : public ff_node { private: int chunk; public: Emitter(int chunk):chunk(chunk) { } void * svc(void * t) { int given = 0; int id = 0; while(given < n) { TASK * otask = new TASK(); otask->start = given; otask->end = (given+chunk >= n ? n : given+chunk); otask->id = id++; given = otask->end; // cout << "Emitting task " << otask->start << " to " << otask->end << endl; ff_send_out((void*) otask); } return(EOS); } }; class Worker : public ff_node { private: int wid; public: Worker(int i):wid(i) {} void * svc(void * t) { TASK * task = (TASK *) t; // cout << "Computing " << task->start << " to " << task->end << endl; struct timespec t0, t1; clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t0); for(int i=task->start; iend; i++) { for(int j=0; j farm; vector w; for(int i=0; i