Commit d76bbd6c authored by Joseph Noir's avatar Joseph Noir

changed signature of conversion funs for spawn_cl

From const any_tuple& to any_tunple
parent 3806e14f
......@@ -56,7 +56,7 @@ template<typename MapArgs, typename MapResult>
struct get_cl_spawn_helper;
template<typename R, typename... Ts>
struct get_cl_spawn_helper<std::function<option<cow_tuple<Ts...>> (const any_tuple&)>,
struct get_cl_spawn_helper<std::function<option<cow_tuple<Ts...>> (any_tuple)>,
std::function<any_tuple (R&)>> {
typedef cl_spawn_helper<R (const Ts&...)> type;
};
......@@ -91,6 +91,36 @@ actor_ptr spawn_cl(const char* source,
f0{map_args}, f1{map_result});
}
template<typename Signature, typename... Ts>
actor_ptr spawn_cl(const opencl::program& prog,
const char* fun_name,
std::vector<size_t> dimensions,
std::vector<size_t> offset = {},
std::vector<size_t> local_dims = {}) {
using std::move;
cl_spawn_helper<Signature> f;
return f(prog, fun_name, move(dimensions), move(offset), move(local_dims));
}
template<typename MapArgs, typename MapResult>
actor_ptr spawn_cl(const opencl::program& prog,
const char* fun_name,
MapArgs map_args,
MapResult map_result,
std::vector<size_t> dimensions,
std::vector<size_t> offset = {},
std::vector<size_t> local_dims = {}) {
using std::move;
typedef typename util::get_callable_trait<MapArgs>::type t0;
typedef typename util::get_callable_trait<MapResult>::type t1;
typedef typename t0::fun_type f0;
typedef typename t1::fun_type f1;
typename get_cl_spawn_helper<f0,f1>::type f;
return f(prog, fun_name,
move(dimensions), move(offset), move(local_dims),
f0{map_args}, f1{map_result});
}
} // namespace cppa
#endif // CPPA_OPENCL_HPP
......@@ -69,7 +69,7 @@ class actor_facade<Ret(Args...)> : public actor {
public:
typedef cow_tuple<typename util::rm_ref<Args>::type...> args_tuple;
typedef std::function<option<args_tuple>(const any_tuple&)> arg_mapping;
typedef std::function<option<args_tuple>(any_tuple)> arg_mapping;
typedef std::function<any_tuple(Ret&)> result_mapping;
static actor_facade* create(command_dispatcher* dispatcher,
......@@ -152,7 +152,7 @@ class actor_facade<Ret(Args...)> : public actor {
void enqueue_impl(const actor_ptr& sender, any_tuple msg, message_id id, util::int_list<Is...>) {
auto opt = m_map_args(msg);
if (opt) {
response_handle handle{this, sender, id};
response_handle handle{this, sender, id.response_id()};
size_t number_of_values{1};
std::for_each(m_global_dimensions.begin(),
m_global_dimensions.end(),
......
......@@ -148,13 +148,13 @@ class command_impl : public command {
/* get results from gpu */
cl_int err{0};
cl_event read_event;
T results(m_number_of_values);
T result(m_number_of_values);
err = clEnqueueReadBuffer(m_queue.get(),
m_arguments[0].get(),
CL_TRUE,
0,
sizeof(typename T::value_type) * m_number_of_values,
results.data(),
result.data(),
0,
NULL,
&read_event);
......@@ -164,7 +164,7 @@ class command_impl : public command {
+ get_opencl_error(err)
+ "'.");
}
auto mapped_result = m_map_result(results);
auto mapped_result = m_map_result(result);
reply_tuple_to(m_handle, mapped_result);
//reply_to(m_handle, results);
}
......
......@@ -87,7 +87,7 @@ class command_dispatcher {
std::vector<size_t> global_dims,
std::vector<size_t> global_offs,
std::vector<size_t> local_dims,
std::function<option<cow_tuple<typename util::rm_ref<Args>::type...>>(const any_tuple&)> map_args,
std::function<option<cow_tuple<typename util::rm_ref<Args>::type...>>(any_tuple)> map_args,
std::function<any_tuple(Ret&)> map_result)
{
return actor_facade<Ret (Args...)>::create(this,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment