Permalink
Browse files

CPPA_OPENCL doesn't need to be set for user apps

instead of requiring users to define CPPA_OPENCL, the library will
throw an exception if compiled without OpenCL support
  • Loading branch information...
1 parent f9b9aad commit 5a8a755b8ee25a36f4a4d472feb140822aceb58f @Neverlord Neverlord committed Apr 4, 2013
Showing with 17 additions and 8 deletions.
  1. +3 −2 cppa/opencl.hpp
  2. +0 −5 cppa/opencl/command_dispatcher.hpp
  3. +14 −1 src/singleton_manager.cpp
View
5 cppa/opencl.hpp
@@ -86,10 +86,11 @@ actor_ptr spawn_cl(const char* source,
typedef typename t0::fun_type f0;
typedef typename t1::fun_type f1;
typename get_cl_spawn_helper<f0,f1>::type f;
- f(source, fun_name, move(dimensions), move(offset), move(local_dims), f0{map_args}, f1{map_result});
+ return f(source, fun_name,
+ move(dimensions), move(offset), move(local_dims),
+ f0{map_args}, f1{map_result});
}
-
} // namespace cppa
#endif // CPPA_OPENCL_HPP
View
5 cppa/opencl/command_dispatcher.hpp
@@ -64,7 +64,6 @@ option<cow_tuple<Ts...>> default_map_args(any_tuple msg) {
return tuple_cast<Ts...>(msg);
}
-#ifdef CPPA_OPENCL
class command_dispatcher {
struct worker;
@@ -174,10 +173,6 @@ class command_dispatcher {
command_ptr);
};
-#else // CPPA_OPENCL
-class command_dispatcher : public detail::singleton_mixin<command_dispatcher> { };
-#endif // CPPA_OPENCL
-
command_dispatcher* get_command_dispatcher();
} } // namespace cppa::opencl
View
15 src/singleton_manager.cpp
@@ -48,7 +48,15 @@
#include "cppa/detail/thread_pool_scheduler.hpp"
#include "cppa/detail/uniform_type_info_map.hpp"
-#include "cppa/opencl/command_dispatcher.hpp"
+#ifdef CPPA_OPENCL
+# include "cppa/opencl/command_dispatcher.hpp"
+#else
+namespace cppa { namespace opencl {
+
+class command_dispatcher : public detail::singleton_mixin<command_dispatcher> { };
+
+} } // namespace cppa::opencl
+#endif
namespace cppa { void shutdown() { detail::singleton_manager::shutdown(); } }
@@ -99,7 +107,12 @@ void singleton_manager::shutdown() {
}
opencl::command_dispatcher* singleton_manager::get_command_dispatcher() {
+# ifdef CPPA_OPENCL
return lazy_get(s_command_dispatcher);
+# else
+ CPPA_LOGF_ERROR("libcppa was compiled without OpenCL support");
+ throw std::logic_error("libcppa was compiled without OpenCL support");
+# endif
}
actor_registry* singleton_manager::get_actor_registry() {

0 comments on commit 5a8a755

Please sign in to comment.