Example #1
0
 hpx::future<std::vector<T> >
 gather_data(hpx::future<hpx::id_type> id, std::size_t site,
     hpx::future<T> result)
 {
     typedef typename gather_server<T>::get_result_action action_type;
     return async(action_type(), id.get(), site, result.get());
 }
Example #2
0
 hpx::future<void>
 set_data(hpx::future<hpx::id_type> id, std::size_t which,
     hpx::future<T> result)
 {
     typedef typename gather_server<T>::set_result_action action_type;
     return async(action_type(), id.get(), which, result.get());
 }
Example #3
0
void then_test_void(hpx::future<void> f, int passed_through)
{
    HPX_ASSERT(f.is_ready());   // make sure, future is ready

    f.get();                    // propagate exceptions

    HPX_TEST_EQ(passed_through, 42);
}
 /// Register the id wrapped in the given future using the given base name.
 ///
 /// The function registers the object the given future refers to using the
 /// provided base name.
 ///
 /// \param base_name    [in] The base name for which to retrieve the
 ///                     registered ids.
 /// \param f            [in] The future which should be registered using
 ///                     the given base name.
 /// \param sequence_nr  [in, optional] The sequential number to use for the
 ///                     registration of the id. This number has to be
 ///                     unique system wide for each registration using the
 ///                     same base name. The default is the current locality
 ///                     identifier. Also, the sequence numbers have to be
 ///                     consecutive starting from zero.
 ///
 /// \returns A future representing the result of the registration operation
 ///          itself.
 ///
 /// \note    The operation will fail if the given sequence number is not
 ///          unique.
 ///
 inline hpx::future<bool> register_with_basename(std::string const& base_name,
     hpx::future<hpx::id_type> f, std::size_t sequence_nr = ~0U)
 {
     return f.then(
         [=](hpx::future<hpx::id_type> && f) mutable
         {
             return register_with_basename(base_name, f.get(), sequence_nr);
         });
 }
Example #5
0
 boost::uint64_t operator()(
     hpx::future<data_type> data
 ) const
 {
     data_type v = data.get();
     return HPX_STD_GET(0, v).get() + HPX_STD_GET(1, v).get();
 }
Example #6
0
 boost::uint64_t operator()(
     hpx::future<data_type> data
 ) const
 {
     data_type v = data.get();
     return hpx::util::get<0>(v).get() + hpx::util::get<1>(v).get();
 }
// this continuation function will be executed by an HPX thread
int cont1(hpx::future<int> f)
{
    hpx::cout << "cont1 thread id: " << hpx::this_thread::get_id() << hpx::endl;
    hpx::cout << "Status code (HPX thread): " << f.get() << hpx::endl;
    hpx::cout << hpx::flush;
    return 1;
}
Example #8
0
 hpx::id_type register_name(hpx::future<hpx::id_type> id,
     char const* basename, std::size_t site)
 {
     hpx::id_type target = id.get();
     hpx::register_with_basename(basename, target, site);
     return target;
 }
void null_callback(
    std::vector<double>& dd
  , boost::uint64_t j
  , hpx::future<double> f
    )
{
    dd[j] = f.get();
}
Example #10
0
boost::int64_t calc_cell(
    boost::uint32_t i
  , boost::uint32_t j
  , char ai
  , char bj
  , hpx::future<boost::int64_t> const& left      // H(i, j-1)
  , hpx::future<boost::int64_t> const& diagonal  // H(i-1, j-1)
  , hpx::future<boost::int64_t> const& up        // H(i-1, j) 
    )
{
    boost::int64_t match_mismatch = 0;
    if (ai == bj)
    {
        match_mismatch = diagonal.get() + match;
    } 
    else 
    {
        match_mismatch = diagonal.get() + mismatch;
    }
    boost::int64_t deletion = up.get() + gap;
    boost::int64_t insertion = left.get() + gap;        
    
    boost::int64_t ij_value
        = maximum(boost::int64_t(0), match_mismatch, deletion, insertion);

    winner H_best_old = H_best.load(); 

    while (true)
    {
        winner H_best_new(ij_value, i, j);

        if (H_best_new.value > H_best_old.value)
        {
            if (H_best.compare_exchange_weak(H_best_old, H_best_new))
                break;
        }
        else
            break;
    }

    return ij_value;
}
Example #11
0
    hpx::future<void> barrier_node::do_wait(This this_,
        hpx::future<void> future)
    {
        if (rank_ == 0)
        {
            return future.then(hpx::launch::sync,
                [this_](hpx::future<void>&& f)
                {
                    // Trigger possible errors...
                    f.get();

                    std::vector<hpx::future<void> > futures;
                    futures.reserve(this_->children_.size());

                    // After the root process received the notification that
                    // everyone entered the barrier, it will broadcast to
                    // everyone that they can leave the barrier
                    for(hpx::id_type& id : this_->children_)
                    {
                        base_lco::set_event_action action;
                        futures.push_back(hpx::async(action, id));
                    }

                    return hpx::when_all(futures);
                });
        }

        return future.then(hpx::launch::sync,
            [this_](hpx::future<void>&& f)
            {
                // Trigger possible errors...
                f.get();

                // Once the non-roots are ready to leave the barrier, we
                // need to reset our promises such that the barrier can be
                // reused.
                this_->broadcast_promise_ = hpx::lcos::local::promise<void>();
                this_->gather_promise_ = hpx::lcos::local::promise<void>();
            });
    }
Example #12
0
static std::string
device_uint_to_string(hpx::future<std::vector<char>> data_future)
{

    std::vector<char> data_raw = data_future.get();

    cl_uint res = *((cl_uint*)data_raw.data());
    
    std::stringstream ss;

    ss << res;

    return ss.str();

}
Example #13
0
static std::string
device_type_to_string(hpx::future<std::vector<char>> type_future)
{

    std::vector<char> type_raw = type_future.get();
    cl_device_type type = *((cl_device_type*) type_raw.data());

    std::vector<std::string> typelist;

    if(type & CL_DEVICE_TYPE_CPU)
        typelist.push_back("cpu");

    if(type & CL_DEVICE_TYPE_GPU)
        typelist.push_back("gpu");

    if(type & CL_DEVICE_TYPE_ACCELERATOR)
        typelist.push_back("accelerator");

    if(type & CL_DEVICE_TYPE_DEFAULT)
        typelist.push_back("default");

#ifdef CL_VERSION_1_2
    if(type & CL_DEVICE_TYPE_CUSTOM)
        typelist.push_back("custom");
#endif

    std::string result = "";

    for(size_t i = 0 ; i < typelist.size(); i++)
    {

        if(i > 0)
            result += ", ";

        result += typelist[i];

    }

    return result;

}
Example #14
0
boost::uint64_t add(
    hpx::future<boost::uint64_t> f1,
    hpx::future<boost::uint64_t> f2)
{
    return f1.get() + f2.get();
}
// this continuation function will be executed by the UI (main) thread, which is
// not an HPX thread
int cont2(hpx::future<int> f)
{
    std::cout << "Status code (main thread): " << f.get() << std::endl;
    return 1;
}
Example #16
0
 std::shared_ptr<Component>
 get_ptr_postproc(hpx::future<naming::address> f,
     naming::id_type const& id)
 {
     return get_ptr_postproc_helper<Component, Deleter>(f.get(), id);
 }
Example #17
0
int int_f5(int i, hpx::future<int> j) { ++int_f5_count; return i+j.get()+42; }