Commit 02d4c3f4 authored by Marian Triebe's avatar Marian Triebe

Fix compile as libcaf submodule

parent 42045189
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "caf/channel.hpp" #include "caf/channel.hpp"
#include "caf/to_string.hpp" #include "caf/to_string.hpp"
#include "caf/tuple_cast.hpp" #include "cppa/tuple_cast.hpp"
#include "caf/intrusive_ptr.hpp" #include "caf/intrusive_ptr.hpp"
#include "caf/detail/int_list.hpp" #include "caf/detail/int_list.hpp"
...@@ -58,8 +58,8 @@ class actor_facade<Ret(Args...)> : public abstract_actor { ...@@ -58,8 +58,8 @@ class actor_facade<Ret(Args...)> : public abstract_actor {
using args_tuple = using args_tuple =
cow_tuple<typename detail::rm_const_and_ref<Args>::type...>; cow_tuple<typename detail::rm_const_and_ref<Args>::type...>;
using arg_mapping = std::function<optional<args_tuple>(any_tuple)>; using arg_mapping = std::function<optional<args_tuple>(message)>;
using result_mapping = std::function<any_tuple(Ret&)>; using result_mapping = std::function<message(Ret&)>;
static intrusive_ptr<actor_facade> static intrusive_ptr<actor_facade>
create(const program& prog, const char* kernel_name, arg_mapping map_args, create(const program& prog, const char* kernel_name, arg_mapping map_args,
...@@ -100,10 +100,11 @@ class actor_facade<Ret(Args...)> : public abstract_actor { ...@@ -100,10 +100,11 @@ class actor_facade<Ret(Args...)> : public abstract_actor {
local_dims, std::move(map_args), std::move(map_result), result_size}; local_dims, std::move(map_args), std::move(map_result), result_size};
} }
void enqueue(msg_hdr_cref hdr, any_tuple msg, execution_unit*) override { void enqueue(const actor_addr &sender, message_id mid, message content,
execution_unit *host) override {
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
typename detail::il_indices<detail::type_list<Args...>>::type indices; typename detail::il_indices<detail::type_list<Args...>>::type indices;
enqueue_impl(hdr.sender, std::move(msg), hdr.id, indices); enqueue_impl(sender, mid, std::move(content), indices);
} }
private: private:
...@@ -128,16 +129,16 @@ class actor_facade<Ret(Args...)> : public abstract_actor { ...@@ -128,16 +129,16 @@ class actor_facade<Ret(Args...)> : public abstract_actor {
} }
template <long... Is> template <long... Is>
void enqueue_impl(const actor_addr& sender, any_tuple msg, message_id id, void enqueue_impl(const actor_addr& sender, message_id mid, message msg,
detail::int_list<Is...>) { detail::int_list<Is...>) {
auto opt = m_map_args(std::move(msg)); auto opt = m_map_args(std::move(msg));
if (opt) { if (opt) {
response_promise handle{this->address(), sender, id.response_id()}; response_promise handle{this->address(), sender, mid.response_id()};
evnt_vec events; evnt_vec events;
args_vec arguments; args_vec arguments;
add_arguments_to_kernel<Ret>(events, arguments, m_result_size, add_arguments_to_kernel<Ret>(events, arguments, m_result_size,
get_ref<Is>(*opt)...); get_ref<Is>(*opt)...);
auto cmd = make_counted<command<actor_facade, Ret>>( auto cmd = detail::make_counted<command<actor_facade, Ret>>(
handle, this, std::move(events), std::move(arguments), m_result_size, handle, this, std::move(events), std::move(arguments), m_result_size,
*opt); *opt);
cmd->enqueue(); cmd->enqueue();
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include "caf/logging.hpp" #include "caf/detail/logging.hpp"
#include "caf/opencl/global.hpp" #include "caf/opencl/global.hpp"
#include "caf/abstract_actor.hpp" #include "caf/abstract_actor.hpp"
#include "caf/response_promise.hpp" #include "caf/response_promise.hpp"
...@@ -41,7 +41,7 @@ class command : public ref_counted { ...@@ -41,7 +41,7 @@ class command : public ref_counted {
public: public:
command(response_promise handle, intrusive_ptr<T> actor_facade, command(response_promise handle, intrusive_ptr<T> actor_facade,
std::vector<cl_event> events, std::vector<mem_ptr> arguments, std::vector<cl_event> events, std::vector<mem_ptr> arguments,
size_t result_size, any_tuple msg) size_t result_size, message msg)
: m_result_size(result_size), : m_result_size(result_size),
m_handle(handle), m_handle(handle),
m_actor_facade(actor_facade), m_actor_facade(actor_facade),
...@@ -122,7 +122,7 @@ class command : public ref_counted { ...@@ -122,7 +122,7 @@ class command : public ref_counted {
std::vector<cl_event> m_events; std::vector<cl_event> m_events;
std::vector<mem_ptr> m_arguments; std::vector<mem_ptr> m_arguments;
R m_result; R m_result;
any_tuple m_msg; // required to keep the argument buffers alive (async copy) message m_msg; // required to keep the argument buffers alive (async copy)
void handle_results() { void handle_results() {
m_handle.deliver(m_actor_facade->m_map_result(m_result)); m_handle.deliver(m_actor_facade->m_map_result(m_result));
......
...@@ -33,36 +33,38 @@ ...@@ -33,36 +33,38 @@
#include "caf/opencl/device_info.hpp" #include "caf/opencl/device_info.hpp"
#include "caf/opencl/actor_facade.hpp" #include "caf/opencl/actor_facade.hpp"
#include "caf/detail/singleton_mixin.hpp" //#include "caf/detail/singleton_mixin.hpp"
#include "caf/detail/singleton_manager.hpp" //#include "caf/detail/singleton_manager.hpp"
#include "caf/detail/singletons.hpp"
namespace caf { namespace caf {
namespace opencl { namespace opencl {
class opencl_metainfo { class opencl_metainfo : public detail::abstract_singleton {
friend class program; friend class program;
friend class detail::singleton_manager; friend class detail::singletons;
friend command_queue_ptr get_command_queue(uint32_t id); friend command_queue_ptr get_command_queue(uint32_t id);
public: public:
const std::vector<device_info> get_devices() const; const std::vector<device_info> get_devices() const;
/**
* Get opencl_metainfo instance.
*/
static opencl_metainfo* instance();
private: private:
static inline opencl_metainfo* create_singleton() { opencl_metainfo();
return new opencl_metainfo;
}
void initialize(); void stop();
void dispose(); void initialize() override;
void destroy(); void dispose() override;
context_ptr m_context; context_ptr m_context;
std::vector<device_info> m_devices; std::vector<device_info> m_devices;
}; };
opencl_metainfo* get_opencl_metainfo();
} // namespace opencl } // namespace opencl
} // namespace caf } // namespace caf
......
...@@ -74,20 +74,20 @@ struct cl_spawn_helper<R(Ts...), void> { ...@@ -74,20 +74,20 @@ struct cl_spawn_helper<R(Ts...), void> {
Us&&... args) const { Us&&... args) const {
using std::move; using std::move;
using std::forward; using std::forward;
map_arg_fun f0 = [](any_tuple msg) { map_arg_fun f0 = [](message msg) {
return tuple_cast<typename util::rm_const_and_ref< return tuple_cast<typename util::rm_const_and_ref<
typename carr_to_vec<Ts>::type>::type...>(msg); typename carr_to_vec<Ts>::type>::type...>(msg);
}; };
map_res_fun f1 = [](result_type& result) { map_res_fun f1 = [](result_type& result) {
return make_any_tuple(move(result)); return make_message(move(result));
}; };
return impl::create(p, fname, move(f0), move(f1), forward<Us>(args)...); return impl::create(p, fname, move(f0), move(f1), forward<Us>(args)...);
} }
}; };
template <typename R, typename... Ts> template <typename R, typename... Ts>
struct cl_spawn_helper<std::function<optional<cow_tuple<Ts...>>(any_tuple)>, struct cl_spawn_helper<std::function<optional<cow_tuple<Ts...>>(message)>,
std::function<any_tuple(R&)>> std::function<message(R&)>>
: cl_spawn_helper<R(Ts...)> {}; : cl_spawn_helper<R(Ts...)> {};
} // namespace detail } // namespace detail
......
...@@ -24,6 +24,13 @@ using namespace std; ...@@ -24,6 +24,13 @@ using namespace std;
namespace caf { namespace caf {
namespace opencl { namespace opencl {
opencl_metainfo* opencl_metainfo::instance() {
auto sid = detail::singletons::opencl_plugin_id;
auto fac = [] { return new opencl_metainfo; };
auto res = detail::singletons::get_plugin_singleton(sid, fac);
return static_cast<opencl_metainfo*>(res);
}
const std::vector<device_info> opencl_metainfo::get_devices() const { const std::vector<device_info> opencl_metainfo::get_devices() const {
return m_devices; return m_devices;
} }
...@@ -164,13 +171,8 @@ void opencl_metainfo::initialize() { ...@@ -164,13 +171,8 @@ void opencl_metainfo::initialize() {
} }
} }
void opencl_metainfo::destroy() { delete this; }
void opencl_metainfo::dispose() { delete this; } void opencl_metainfo::dispose() { delete this; }
opencl_metainfo* get_opencl_metainfo() {
return detail::singleton_manager::get_opencl_metainfo();
}
} // namespace opencl } // namespace opencl
} // namespace caf } // namespace caf
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include "caf/singletons.hpp" #include "caf/detail/singletons.hpp"
#include "caf/opencl/program.hpp" #include "caf/opencl/program.hpp"
#include "caf/opencl/opencl_metainfo.hpp" #include "caf/opencl/opencl_metainfo.hpp"
...@@ -39,9 +39,9 @@ program::program(context_ptr context, command_queue_ptr queue, ...@@ -39,9 +39,9 @@ program::program(context_ptr context, command_queue_ptr queue,
program program::create(const char* kernel_source, const char* options, program program::create(const char* kernel_source, const char* options,
uint32_t device_id) { uint32_t device_id) {
auto metainfo = get_opencl_metainfo(); auto metainfo = opencl_metainfo::instance();
auto devices = metainfo->get_devices(); auto devices = metainfo->get_devices();
auto context = metainfo->m_context; auto context = metainfo->m_context;
if (devices.size() <= device_id) { if (devices.size() <= device_id) {
ostringstream oss; ostringstream oss;
......
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