Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hpx::parallel::fill fails compiling #5016

Closed
hkaiser opened this issue Oct 14, 2020 · 0 comments · Fixed by #5017
Closed

hpx::parallel::fill fails compiling #5016

hkaiser opened this issue Oct 14, 2020 · 0 comments · Fixed by #5017

Comments

@hkaiser
Copy link
Member

hkaiser commented Oct 14, 2020

@stevenrbrandt reported:

I have this code that used to compile. Essentially, it's just a call to parallel fill. Now it gives an error. Is it a bug? Thanks.

The problem line of code is this:
hpx::parallel::fill(hpx::parallel::execution::par.on(exec),vd.begin(),vd.end(),2.0f);

Here's the compilation with error messages...

/usr/bin/c++ fx.cpp `pkg-config --cflags hpx_application_release` -c In file included from /usr/local/include/hpx/parallel/algorithm.hpp:22,
                  from /usr/local/include/hpx/algorithm.hpp:10,
                  from /usr/local/include/hpx/hpx.hpp:10,
                  from fx.cpp:1:
/usr/local/include/hpx/parallel/algorithms/fill.hpp: In instantiation of ‘typename hpx::parallel::util::detail::algorithm_result<ExPolicy, 
void>::type hpx::parallel::v1::fill(ExPolicy&&, FwdIter, FwdIter, const
T&) [with ExPolicy =
hpx::execution::parallel_policy_shim<hpx::compute::host::block_executor<>,
hpx::execution::static_chunk_size>; FwdIter = __gnu_cxx::__normal_iterator<float*, std::vector<float> >; T = float; int _concept_requires_217 = 42; typename
std::enable_if<((_concept_requires_637 == 43) || (hpx::is_execution_policy<T>::value && hpx::traits::is_forward_iterator<FwdIter>::value)), int>::type
_concept_check_217 = 0; typename
hpx::parallel::util::detail::algorithm_result<ExPolicy, void>::type =
void]’:
fx.cpp:38:88:   required from here
/usr/local/include/hpx/parallel/algorithms/fill.hpp:232:29: error: 
return-statement with a value, in function returning ‘hpx::parallel::util::detail::algorithm_result_impl<hpx::execution::parallel_policy_shim<hpx::compute::host::block_executor<>,
hpx::execution::static_chunk_size>, void>::type’ {aka ‘void’} [-fpermissive]
   232 |         return detail::fill_(
       |                ~~~~~~~~~~~~~^
   233 |             std::forward<ExPolicy>(policy), first, last, value, is_segmented());
       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And here's the code...

#include <hpx/hpx.hpp>
#include <hpx/include/parallel_fill.hpp> 
#include <hpx/include/compute.hpp> 
#include <hpx/include/parallel_executors.hpp>

#include <fstream>
#include <sstream>

void prvec(std::vector<float> v){
     for(auto i : v)
       std::cout << i << " ";
     std::cout << std::endl;

};

hpx::compute::host::block_executor<> getexec(){
     auto host_targets = hpx::compute::host::get_local_targets();
     typedef hpx::compute::host::block_executor<> executor_type;
     executor_type exec(host_targets);

     for(auto host : host_targets)
         std::cout << host.get_locality() << std::endl;

     return exec;
}

void fill_example(){
     auto exec = getexec();

     std::vector<float> vd;
     for(int i=0;i<5;i++) vd.push_back(1.f);
     prvec(vd);
hpx::parallel::fill(hpx::parallel::execution::par.on(exec),vd.begin(),vd.end(),2.0f);
     prvec(vd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant