Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making sure for_loop(par, 0, N, ...) is actually executed in parallel
- flyby: fixing typo
- Loading branch information
Showing
4 changed files
with
48 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2016 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) | ||
|
||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/hpx.hpp> | ||
#include <hpx/include/parallel_for_loop.hpp> | ||
#include <hpx/util/lightweight_test.hpp> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
int hpx_main() | ||
{ | ||
hpx::lcos::local::spinlock mtx; | ||
std::set<hpx::thread::id> thread_ids; | ||
|
||
hpx::parallel::for_loop( | ||
hpx::parallel::par, 0, 100, | ||
[&](int i) | ||
{ | ||
std::lock_guard<hpx::lcos::local::spinlock> l(mtx); | ||
thread_ids.insert(hpx::this_thread::get_id()); | ||
}); | ||
|
||
HPX_TEST(thread_ids.size() > std::size_t(1)); | ||
|
||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std::vector<std::string> const cfg = { | ||
"hpx.os_threads=4" | ||
}; | ||
|
||
HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, | ||
"HPX main exited with non-zero status"); | ||
|
||
return hpx::util::report_errors(); | ||
} |
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