-
-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #1001: Zero copy serialization raises assert
- Loading branch information
Showing
4 changed files
with
133 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) 2007-2013 Hartmut Kaiser | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// This test verifies that issue #1001 is resolved (Zero copy serialization raises assert). | ||
|
||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/include/util.hpp> | ||
#include <hpx/include/actions.hpp> | ||
#include <hpx/include/async.hpp> | ||
#include <hpx/include/lcos.hpp> | ||
#include <hpx/util/serialize_buffer.hpp> | ||
#include <hpx/util/lightweight_test.hpp> | ||
|
||
#include <algorithm> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
hpx::util::serialize_buffer<int> test(hpx::util::serialize_buffer<int> const& b) | ||
{ | ||
return b; | ||
} | ||
HPX_PLAIN_ACTION(test, test_action) | ||
|
||
struct inc | ||
{ | ||
inc() : cnt_(0) {} | ||
|
||
int operator()() | ||
{ | ||
return cnt_++; | ||
} | ||
|
||
int cnt_; | ||
}; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
int hpx_main() | ||
{ | ||
std::vector<hpx::naming::id_type> localities = hpx::find_remote_localities(); | ||
|
||
if (localities.empty()) | ||
{ | ||
HPX_TEST_MSG(!localities.empty(), "This test must be run on more than one locality"); | ||
} | ||
else | ||
{ | ||
test_action act; | ||
|
||
std::size_t size = 1; | ||
for (std::size_t i = 0; i != 14; ++i) | ||
{ | ||
std::vector<int> data; | ||
data.resize(size << i); | ||
|
||
std::generate(data.begin(), data.end(), inc()); | ||
|
||
hpx::util::serialize_buffer<int> buffer(data.data(), data.size(), | ||
hpx::util::serialize_buffer<int>::reference); | ||
|
||
hpx::util::serialize_buffer<int> result = act(localities[0], buffer); | ||
|
||
HPX_TEST(std::equal(data.begin(), data.end(), result.data())); | ||
} | ||
} | ||
|
||
return hpx::finalize(); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
int main(int argc, char* argv[]) | ||
{ | ||
// Initialize and run HPX | ||
HPX_TEST_EQ(hpx::init(argc, argv), 0); | ||
|
||
return hpx::util::report_errors(); | ||
} | ||
|