diff --git a/src/dist_objects_2/src/dist_objects_2.cpp b/src/dist_objects_2/src/dist_objects_2.cpp index 14dbf86..93f0910 100644 --- a/src/dist_objects_2/src/dist_objects_2.cpp +++ b/src/dist_objects_2/src/dist_objects_2.cpp @@ -111,20 +111,20 @@ namespace dist_object { data_type; private: template - static hpx::future create_server(Arg && value) + static hpx::future create_server(hpx::id_type where, Arg && value) { - return hpx::new_>(hpx::find_here(), std::forward(value)); + return hpx::new_>(where, std::forward(value)); } public: dist_object() {} - dist_object(data_type const& data) - : base_type(create_server(data)) + dist_object(hpx::id_type where, data_type const& data) + : base_type(create_server(where, data)) {} - dist_object(data_type && data) - : base_type(create_server(std::move(data))) + dist_object(hpx::id_type where, data_type && data) + : base_type(create_server(where, std::move(data))) {} dist_object(hpx::future &&id) @@ -215,7 +215,8 @@ namespace dist_object { : values_(values) {} - dist_object_config_data(data_type const &val, size_t num_partitions) { + dist_object_config_data(vector localities, data_type const &val, size_t num_partitions) { + HPX_ASSERT(localities.size() == num_partitions); size_t num_partitions_tmp = num_partitions; size_t slice_begin = 0; size_t last_idx = val.size(); @@ -223,7 +224,9 @@ namespace dist_object { size_t block_size = (size_t)ceil(double(last_idx) / double(num_partitions_tmp)); size_t slice_end = slice_begin + block_size; data_type partition_data = slice(val, slice_begin, slice_end); - client_type partition(partition_data); + client_type partition(localities.back(), partition_data); + localities.pop_back(); + //client_type partition = hpx::new_(); values_.push_back(make_shared(partition)); slice_begin = slice_end; num_partitions_tmp--; @@ -283,7 +286,8 @@ void run_dist_object_vector() { ////dist_object::config_data obj(); vector a(10, 2); - dist_object::dist_object_config_data test(a, 2); + vector localities = hpx::find_all_localities(); + dist_object::dist_object_config_data test(localities, a, 2); test.print(); return;