Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <ff/farm.hpp>
- #include "structs.hpp"
- #include "emitter.hpp"
- #include "worker.hpp"
- using namespace std;
- using namespace ff;
- int vals[N][N];
- bool chk[N][N];
- bool path[N][N];
- int nworkers;
- pair_t ** boundary;
- int64_t * bsizes;
- int64_t * bsizesmax;
- int slices;
- extern int totinsert;
- extern int totiter;
- int main(int argc, char * argv[]) {
- nworkers = atoi(argv[1]);
- slices = atoi(argv[2]);
- char* fname = argv[3];
- ifstream is;
- is.open(fname);
- if (is.fail()) {
- cerr << "Error opening " << fname << endl;
- return 1;
- }
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- path[i][j] = false;
- chk[i][j] = false;
- is >> vals[i][j];
- }
- }
- // cout << "Letto" << endl;
- // boundary = new vector<pair_t *>[SLICES];
- bsizes = (int64_t*)malloc(slices*sizeof(int64_t));
- bsizesmax = (int64_t*)malloc(slices*sizeof(int64_t));
- boundary = (pair_t**)malloc(slices*sizeof(pair_t*));
- for (int i = 0 ; i < slices; i++) {
- boundary[i] = (pair_t*)malloc(N*sizeof(pair_t));
- bsizes[i] = 0;
- bsizesmax[i] = N;
- }
- // expanded.x = expanded.y = N/2;
- boundary[0][0].x = N/2; boundary[0][0].y = N/2;
- bsizes[0] = 1;
- chk[N/2][N/2] = true;
- // toadd = new int64_t[SLICES];
- ff_farm<> farm;
- vector<ff_node *> workers;
- for (int i = 0; i < nworkers; i++) workers.push_back(new Worker);
- Emitter e;
- farm.add_emitter(&e);
- farm.add_workers(workers);
- //farm.add_collector(new Collector);
- farm.wrap_around();
- ffTime(START_TIME);
- farm.run_and_wait_end();
- ffTime(STOP_TIME);
- // cout << "uins: " << (float)(totinsert)/(float)(totiter) << endl;
- // cout << "iter: " << totiter << endl;
- // cerr << "total time: " << ffTime(GET_TIME) << " (ms)" << endl;
- // cerr << "total time: " << farm.ffwTime() << " (ms)" << endl;
- cout << farm.ffwTime() << endl;
- // farm.ffStats(cout);
- // cout << farm.ffwTime();
- /* stringstream ss;
- ss << "output" << nworkers;
- string q; ss >> q;
- ofstream os;
- os.open(q.c_str());
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- os << path[i][j] << " ";
- }
- os << endl;
- }
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement