main.cpp 913 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <thallium.hpp>

namespace tl = thallium;

void hello() {
    tl::xstream es = tl::xstream::self();
    std::cout << "Hello World from ES " 
        << es.get_rank() << ", TASK " 
        << tl::task::self_id() << std::endl;
}

int main(int argc, char** argv) {

    tl::engine myEngine("tcp", THALLIUM_CLIENT_MODE);

    std::vector<tl::managed<tl::xstream>> ess;

    tl::xstream primary = tl::xstream::self();

    for(int i=0; i < 4; i++) {
        tl::managed<tl::xstream> es = tl::xstream::create();
        ess.push_back(std::move(es));
    }

    std::vector<tl::managed<tl::task>> tsks;
    for(int i=0; i < 16; i++) {
        tl::managed<tl::task> tsk = ess[i % ess.size()]->make_task(hello);
        tsks.push_back(std::move(tsk));
    }

    for(auto& mtsk : tsks) {
        mtsk->join();
    }

    for(int i=0; i < 4; i++) {
        ess[i]->join();
    }
    return 0;
}