include/ff/taskf.hpp
// NOTE: by default the scheduling is round-robin (pseudo round-robin indeed).
//       In order to select the ondemand scheduling policy, set the ondemand_buffer to a 
//       value grather than 1.
by default the scheduling is round-robin (pseudo round-robin indeed).
In order to select the ondemand scheduling policy, set the ondemand_buffer to a
value grather than 1.
by default the scheduling is round - robin ( pseudo round - robin indeed ) . In order to select the ondemand scheduling policy set the ondemand_buffer to a value grather than 1 .
ff_taskf(int maxnw=ff_realNumCores(), 
             const size_t maxTasks=DEFAULT_OUTSTANDING_TASKS, 
             const int ondemand_buffer=0):
        ff_farm(true, 
                  (std::max)(maxTasks, (size_t)(MAX_NUM_THREADS*8)),
                  (std::max)(maxTasks, (size_t)(MAX_NUM_THREADS*8)),
                  true, maxnw, true),
        farmworkers(maxnw),ntasks(0),
        outstandingTasks((std::max)(maxTasks, (size_t)(MAX_NUM_THREADS*8))),taskscounter(0) {
        TASKS.resize(outstandingTasks); 
        std::vector<ff_node *> w;
        for(int i=0;i<maxnw;++i) w.push_back(new Worker);
        ff_farm::add_workers(w);
        ff_farm::add_emitter(sched = new Scheduler(ff_farm::getlb(), maxnw));
        ff_farm::wrap_around();
        ff_farm::set_scheduling_ondemand(ondemand_buffer);
        if (ff_farm::prepare() < 0) 
            error("ff_taskf: running farm (1)\n");
        auto r=-1;
        getlb()->freeze();
        ff_farm::offload(GO_OUT);
        if (getlb()->run() != -1) {
            getlb()->broadcast_task(GO_OUT);
            r = getlb()->wait_freezing();   
        }
        if (r<0) error("ff_taskf: running farm (2)\n");
    }
ff_taskf ( int maxnw = ff_realNumCores ( ) , const size_t maxTasks = DEFAULT_OUTSTANDING_TASKS , const int ondemand_buffer = 0 ) : ff_farm ( true , ( std :: max ) ( maxTasks , ( size_t ) ( MAX_NUM_THREADS * 8 ) ) , ( std :: max ) ( maxTasks , ( size_t ) ( MAX_NUM_THREADS * 8 ) ) , true , maxnw , true ) , farmworkers ( maxnw ) , ntasks ( 0 ) , outstandingTasks ( ( std :: max ) ( maxTasks , ( size_t ) ( MAX_NUM_THREADS * 8 ) ) ) , taskscounter ( 0 ) { TASKS . resize ( outstandingTasks ) ; std :: vector < ff_node * > w ; for ( int i = 0 ; i < maxnw ; ++ i ) w . push_back ( new Worker ) ; ff_farm :: add_workers ( w ) ; ff_farm :: add_emitter ( sched = new Scheduler ( ff_farm :: getlb ( ) , maxnw ) ) ; ff_farm :: wrap_around ( ) ; ff_farm :: set_scheduling_ondemand ( ondemand_buffer ) ; if ( ff_farm :: prepare ( ) < 0 ) error ( " \n " ) ; auto r = -1 ; getlb ( ) -> freeze ( ) ; ff_farm :: offload ( GO_OUT ) ; if ( getlb ( ) -> run ( ) != -1 ) { getlb ( ) -> broadcast_task ( GO_OUT ) ; r = getlb ( ) -> wait_freezing ( ) ; } if ( r < 0 ) error ( " \n " ) ; }
NOTE: by default the scheduling is round-robin (pseudo round-robin indeed).
NOTE : by default the scheduling is round - robin ( pseudo round - robin indeed ) .
// NOTE: Worker objects are going to be destroyed by the farm destructor // needed to avoid the initial barrier