Dear List,
         indeed the compilation problem was my bad, as Hartmut suggested a
wrong mixing between int and future<void>

corrected code goes at the end.

one strange thing is that i had to use
        //this does compile
        work_items[i] = hpx::dataflow(hpx::launch::async, &do_work, i,
item_dependencies);

because the version, from the tutorial, DOES NOT COMPILE:
//        auto Op = hpx::util::unwrapped(&do_work);
//        work_items[i] = hpx::dataflow(hpx::launch::async, Op, i,
item_dependencies);

my current problem is that the code delivers unexpected results:
rrossi@Latitude-E5450:~/scratch$ ./coloring.exe
i am 0
i am 8

i never call do work with a value of 8!! and it should print all of the
colors from 0 to 5!!

regards (and thank you for the help)
Riccardo


//[hello_world_client_getting_started
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>
#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/parallel_numeric.hpp>
#include <hpx/include/threads.hpp>
#include <hpx/include/threadmanager.hpp>
#include <hpx/include/lcos.hpp>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <functional>

//compile with
//g++ -std=c++14 -fPIC coloring.cpp -o coloring.exe
-I/home/rrossi/scratch/hpx/build -I/home/rrossi/scratch/hpx/hpx
-I/home/rrossi/compiled_libraries/boost/include/
-L/home/rrossi/scratch/hpx/build/lib -lhpx
-L/home/rrossi/compiled_libraries/boost/lib/ -lboost_program_options
-lboost_system -lboost_thread


//this one would be the function to process a color, that is, a collection
of columns
hpx::lcos::shared_future<void> do_work(const unsigned int color, const
std::vector<hpx::lcos::shared_future<void> >& dependencies)
{
    std::cout << "i am " << color << std::endl;
    return  hpx::lcos::shared_future<void>(
hpx::when_all(dependencies.begin(), dependencies.end()) );
}




int hpx_main(boost::program_options::variables_map&)
{
    int ncolors = 6;
    std::vector< std::unordered_set<unsigned int> > dependencies(ncolors);
    dependencies[0]; //first has no dependencies
    dependencies[1].insert({0});
    dependencies[2].insert({0,1});
    dependencies[3].insert({0,2});
    dependencies[4].insert({1});
    dependencies[5].insert({0});


    //this is a set with all of the tasks i am spawning
    std::unordered_map< unsigned int, hpx::lcos::shared_future<void> >
work_items;

    //here i actually spawn the threads
    for(unsigned int i=0; i<ncolors; i++)
    {
        std::vector< hpx::lcos::shared_future<void> > item_dependencies;

        for(unsigned int k=0; k<dependencies[i].size();i++)
        {
            item_dependencies.push_back(work_items[k]); //fill the
item_dependencies on the base of the already constructed shared_futures
        }


        //this does compile
        work_items[i] = hpx::dataflow(hpx::launch::async, &do_work, i,
item_dependencies);

        //this version, from the tutorial, DOES
//        auto Op = hpx::util::unwrapped(&do_work);
//        work_items[i] = hpx::dataflow(hpx::launch::async, Op, i,
item_dependencies);
    }
    return hpx::finalize(); // Initiate shutdown of the runtime system.
}

int main(int argc, char* argv[])
{
    return hpx::init(argc, argv); // Initialize and run HPX.
}

-- 


*Riccardo Rossi*

PhD, Civil Engineer


member of the Kratos Team: www.cimne.com/kratos

Tenure Track Lecturer at Universitat Politècnica de Catalunya,
BarcelonaTech (UPC)

Full Research Professor at International Center for Numerical Methods in
Engineering (CIMNE)


C/ Gran Capità, s/n, Campus Nord UPC, Ed. B0, Despatx 102

(please deliver post to the porters of building C1)

08034 – Barcelona – Spain – www.cimne.com  -

T.(+34) 93 401 56 96 skype: *rougered4*



<http://www.cimne.com/>

<https://www.facebook.com/cimne> <http://blog.cimne.com/>
<http://vimeo.com/cimne> <http://www.youtube.com/user/CIMNEvideos>
<http://www.linkedin.com/company/cimne> <https://twitter.com/cimne>

Les dades personals contingudes en aquest missatge són tractades amb la
finalitat de mantenir el contacte professional entre CIMNE i voste. Podra
exercir els drets d'accés, rectificació, cancel·lació i oposició,
dirigint-se a [email protected]. La utilització de la seva adreça de
correu electronic per part de CIMNE queda subjecte a les disposicions de la
Llei 34/2002, de Serveis de la Societat de la Informació i el Comerç
Electronic.

 Imprimiu aquest missatge, només si és estrictament necessari.
<http://www.cimne.com/>
_______________________________________________
hpx-users mailing list
[email protected]
https://mail.cct.lsu.edu/mailman/listinfo/hpx-users

Reply via email to