Skip to content

Commit

Permalink
temp fix of potential deadlock when scheduling work items, added stub…
Browse files Browse the repository at this point in the history
…s for distributed fine_grained test
  • Loading branch information
hendrx committed Mar 2, 2017
1 parent a036bca commit e9097a1
Show file tree
Hide file tree
Showing 8 changed files with 852 additions and 13 deletions.
439 changes: 439 additions & 0 deletions @

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion allscale/data_item_manager_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ namespace allscale
}
*/

//TODO: function returning mask to data_item usw
// get_access(data_item_id, region r)
//
// data item selber liegt in der closure
template <typename DataItemDescription>
void destroy (data_item<DataItemDescription> item)
{
Expand Down
2 changes: 1 addition & 1 deletion allscale/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ template<typename MainWorkItem, typename ... Args>
int main_wrapper(const Args& ... args) {
// include monitoring support
allscale::components::monitor_component_init();

std::cout<<"wrapper started" << std::endl;
// start allscale scheduler ...
allscale::scheduler::run(hpx::get_locality_id());

Expand Down
7 changes: 7 additions & 0 deletions examples/pfor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ add_hpx_executable(
fine_grained.cpp
COMPONENT_DEPENDENCIES allscale
)

add_hpx_executable(
fine_grained_with_data_items
SOURCES
fine_grained_with_data_items.cpp
COMPONENT_DEPENDENCIES allscale
)
6 changes: 2 additions & 4 deletions examples/pfor/fine_grained.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ struct simple_stencil_body {

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

// start allscale scheduler ...
allscale::scheduler::run(hpx::get_locality_id());

std::int64_t n = argc >= 2 ? std::stoi(std::string(argv[1])) : DEFAULT_SIZE;
std::int64_t steps = argc >= 3 ? std::stoi(std::string(argv[2])) : 1000;
std::int64_t iters = argc >= 4 ? std::stoi(std::string(argv[2])) : 1;

std::int64_t iters = argc >= 4 ? std::stoi(std::string(argv[3])) : 1;
// initialize the data array
dataA.resize(n, 0);
dataB.resize(n, 0);
Expand All @@ -84,7 +82,7 @@ int hpx_main(int argc, char **argv)
}
allscale::scheduler::stop();
}

return hpx::finalize();
}

Expand Down
95 changes: 95 additions & 0 deletions examples/pfor/fine_grained_with_data_items.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

#include <allscale/no_split.hpp>
#include <allscale/no_serialization.hpp>
#include <allscale/do_serialization.hpp>
#include <allscale/treeture.hpp>
#include <allscale/spawn.hpp>
#include <allscale/scheduler.hpp>
#include <allscale/work_item_description.hpp>

#include <allscale/runtime.hpp>

#include <hpx/include/unordered_map.hpp>
#include <hpx/include/performance_counters.hpp>

#include <unistd.h>

#include "pfor_with_data_items.hpp"


static const int DEFAULT_SIZE = 128 * 1024 * 1024;

static std::vector<int> dataA;
static std::vector<int> dataB;

struct simple_stencil_body {
void operator()(std::int64_t i, const hpx::util::tuple<std::int64_t,std::int64_t>& params) const {
// extract parameters
auto t = hpx::util::get<0>(params);
auto n = hpx::util::get<1>(params);

HPX_ASSERT(i < n);
HPX_ASSERT(i < dataA.size());
HPX_ASSERT(i < dataB.size());

// figure out in which way to move the data
int* A = (t%2) ? dataA.data() : dataB.data();
int* B = (t%2) ? dataB.data() : dataA.data();

// check current state
if ((i > 0 && A[i-1] != A[i]) || (i < n-1 && A[i] != A[i+1])) {
std::cout << "Error in synchronization!\n";
std::cout << " for i=" << i << "\n";
std::cout << " A[i-1]=" << A[i-1] << "\n";
std::cout << " A[ i ]=" << A[ i ] << "\n";
std::cout << " A[i+1]=" << A[i+1] << "\n";
exit(42);
}

// update B
B[i] = A[i] + 1;
}
};


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

// start allscale scheduler ...
allscale::scheduler::run(hpx::get_locality_id());

std::int64_t n = argc >= 2 ? std::stoi(std::string(argv[1])) : DEFAULT_SIZE;
std::int64_t steps = argc >= 3 ? std::stoi(std::string(argv[2])) : 1000;
std::int64_t iters = argc >= 4 ? std::stoi(std::string(argv[2])) : 1;

// initialize the data array
dataA.resize(n, 0);
dataB.resize(n, 0);

if(hpx::get_locality_id() == 0)
{
for(int i=0; i<iters; i++) {
std::cout << "Starting " << steps << "x pfor(0.." << n << "), " << "Iter: " << i << "\n";
hpx::util::high_resolution_timer t;

{
pfor_loop_handle last;
for(int t=0; t<steps; t++) {
last = pfor_neighbor_sync<simple_stencil_body>(last,0,n,t,n);
}
}

auto elapsed = t.elapsed_microseconds();
std::cout << "pfor(0.." << n << ") taking " << elapsed << " microseconds. Iter: " << i << "\n";
}
allscale::scheduler::stop();
}

return hpx::finalize();
}

int main(int argc, char **argv)
{
return hpx::init(argc, argv);
}

Loading

0 comments on commit e9097a1

Please sign in to comment.