Commit 78b5ac58 authored by Dominik Charousset's avatar Dominik Charousset

Fix formatting

parent b403c75e
...@@ -113,16 +113,13 @@ struct implicit_conversions<char*, 0> { ...@@ -113,16 +113,13 @@ struct implicit_conversions<char*, 0> {
}; };
template <size_t N> template <size_t N>
struct implicit_conversions<char[N], 0> struct implicit_conversions<char[N], 0> : implicit_conversions<char*> {};
: implicit_conversions<char*> {};
template <> template <>
struct implicit_conversions<const char*, 0> struct implicit_conversions<const char*, 0> : implicit_conversions<char*> {};
: implicit_conversions<char*> {};
template <size_t N> template <size_t N>
struct implicit_conversions<const char[N], 0> struct implicit_conversions<const char[N], 0> : implicit_conversions<char*> {};
: implicit_conversions<char*> {};
template <> template <>
struct implicit_conversions<char16_t*, 0> { struct implicit_conversions<char16_t*, 0> {
...@@ -130,12 +127,12 @@ struct implicit_conversions<char16_t*, 0> { ...@@ -130,12 +127,12 @@ struct implicit_conversions<char16_t*, 0> {
}; };
template <size_t N> template <size_t N>
struct implicit_conversions<char16_t[N], 0> struct implicit_conversions<char16_t[N], 0> : implicit_conversions<char16_t*> {
: implicit_conversions<char16_t*> {}; };
template <> template <>
struct implicit_conversions<const char16_t*, 0> struct implicit_conversions<const char16_t*, 0>
: implicit_conversions<char16_t*> {}; : implicit_conversions<char16_t*> {};
template <size_t N> template <size_t N>
struct implicit_conversions<const char16_t[N], 0> struct implicit_conversions<const char16_t[N], 0>
...@@ -147,16 +144,16 @@ struct implicit_conversions<char32_t*, 0> { ...@@ -147,16 +144,16 @@ struct implicit_conversions<char32_t*, 0> {
}; };
template <size_t N> template <size_t N>
struct implicit_conversions<char32_t[N], 0> struct implicit_conversions<char32_t[N], 0> : implicit_conversions<char32_t*> {
: implicit_conversions<char32_t*> {}; };
template <> template <>
struct implicit_conversions<const char32_t*, 0> struct implicit_conversions<const char32_t*, 0>
: implicit_conversions<char32_t*> {}; : implicit_conversions<char32_t*> {};
template <size_t N> template <size_t N>
struct implicit_conversions<const char32_t[N], 0> struct implicit_conversions<const char32_t[N], 0>
: implicit_conversions<char32_t*> {}; : implicit_conversions<char32_t*> {};
template <> template <>
struct implicit_conversions<scoped_actor, 0> { struct implicit_conversions<scoped_actor, 0> {
...@@ -168,14 +165,8 @@ using implicit_conversions_t = typename implicit_conversions<T>::type; ...@@ -168,14 +165,8 @@ using implicit_conversions_t = typename implicit_conversions<T>::type;
template <class T> template <class T>
struct strip_and_convert { struct strip_and_convert {
using type = using type = typename implicit_conversions<typename std::remove_const<
typename implicit_conversions< typename std::remove_reference<T>::type>::type>::type;
typename std::remove_const<
typename std::remove_reference<
T
>::type
>::type
>::type;
}; };
template <class T> template <class T>
......
...@@ -32,8 +32,7 @@ std::false_type is_complete_impl(...); ...@@ -32,8 +32,7 @@ std::false_type is_complete_impl(...);
/// Checks whether T is a complete type. For example, passing a forward /// Checks whether T is a complete type. For example, passing a forward
/// declaration or undefined template specialization evaluates to `false`. /// declaration or undefined template specialization evaluates to `false`.
template <class T> template <class T>
struct is_complete struct is_complete {
{
static constexpr bool value static constexpr bool value
= decltype(is_complete_impl(std::declval<T*>()))::value; = decltype(is_complete_impl(std::declval<T*>()))::value;
}; };
......
...@@ -41,10 +41,12 @@ enum class level; ...@@ -41,10 +41,12 @@ enum class level;
CAF_BEGIN_TYPE_ID_BLOCK(selective_streaming, first_custom_type_id) CAF_BEGIN_TYPE_ID_BLOCK(selective_streaming, first_custom_type_id)
CAF_ADD_TYPE_ID(selective_streaming, (caf::stream<std::pair<level, std::string>>) ) CAF_ADD_TYPE_ID(selective_streaming,
(caf::stream<std::pair<level, std::string>>) )
CAF_ADD_TYPE_ID(selective_streaming, (level)) CAF_ADD_TYPE_ID(selective_streaming, (level))
CAF_ADD_TYPE_ID(selective_streaming, (std::pair<level, std::string>) ) CAF_ADD_TYPE_ID(selective_streaming, (std::pair<level, std::string>) )
CAF_ADD_TYPE_ID(selective_streaming, (std::vector<std::pair<level, std::string>>) ) CAF_ADD_TYPE_ID(selective_streaming,
(std::vector<std::pair<level, std::string>>) )
CAF_END_TYPE_ID_BLOCK(selective_streaming) CAF_END_TYPE_ID_BLOCK(selective_streaming)
......
...@@ -79,11 +79,11 @@ struct test_empty_non_pod; ...@@ -79,11 +79,11 @@ struct test_empty_non_pod;
CAF_BEGIN_TYPE_ID_BLOCK(serialization, first_custom_type_id) CAF_BEGIN_TYPE_ID_BLOCK(serialization, first_custom_type_id)
CAF_ADD_TYPE_ID(serialization, (raw_struct)) CAF_ADD_TYPE_ID(serialization, (raw_struct))
CAF_ADD_TYPE_ID(serialization, (std::vector<bool>)) CAF_ADD_TYPE_ID(serialization, (std::vector<bool>) )
CAF_ADD_TYPE_ID(serialization, (test_array)) CAF_ADD_TYPE_ID(serialization, (test_array))
CAF_ADD_TYPE_ID(serialization, (test_empty_non_pod)) CAF_ADD_TYPE_ID(serialization, (test_empty_non_pod))
CAF_ADD_TYPE_ID(serialization, (test_enum)) CAF_ADD_TYPE_ID(serialization, (test_enum))
CAF_END_TYPE_ID_BLOCK(serialization) CAF_END_TYPE_ID_BLOCK(serialization)
...@@ -170,12 +170,9 @@ struct fixture { ...@@ -170,12 +170,9 @@ struct fixture {
test_enum te = test_enum::b; test_enum te = test_enum::b;
string str = "Lorem ipsum dolor sit amet."; string str = "Lorem ipsum dolor sit amet.";
raw_struct rs; raw_struct rs;
test_array ta { test_array ta{
{0, 1, 2, 3}, {0, 1, 2, 3},
{ {{0, 1, 2, 3}, {4, 5, 6, 7}},
{0, 1, 2, 3},
{4, 5, 6, 7}
},
}; };
int ra[3] = {1, 2, 3}; int ra[3] = {1, 2, 3};
...@@ -246,10 +243,8 @@ struct is_message { ...@@ -246,10 +243,8 @@ struct is_message {
bool ok = false; bool ok = false;
// work around for gcc 4.8.4 bug // work around for gcc 4.8.4 bug
auto tup = tie(v, vs...); auto tup = tie(v, vs...);
message_handler impl { message_handler impl{
[&](T const& u, Ts const&... us) { [&](T const& u, Ts const&... us) { ok = tup == tie(u, us...); },
ok = tup == tie(u, us...);
}
}; };
impl(msg); impl(msg);
return ok; return ok;
...@@ -284,8 +279,8 @@ struct is_message { ...@@ -284,8 +279,8 @@ struct is_message {
void run_test_impl(); \ void run_test_impl(); \
}; \ }; \
using name##_binary = name##_tpl<binary_serializer, binary_deserializer>; \ using name##_binary = name##_tpl<binary_serializer, binary_deserializer>; \
using name##_stream = name##_tpl<stream_serializer<vectorbuf>, \ using name##_stream \
stream_deserializer<charbuf>>; \ = name##_tpl<stream_serializer<vectorbuf>, stream_deserializer<charbuf>>; \
::caf::test::detail::adder<::caf::test::test_impl<name##_binary>> \ ::caf::test::detail::adder<::caf::test::test_impl<name##_binary>> \
CAF_UNIQUE(a_binary){CAF_XSTR(CAF_SUITE), CAF_XSTR(name##_binary), false}; \ CAF_UNIQUE(a_binary){CAF_XSTR(CAF_SUITE), CAF_XSTR(name##_binary), false}; \
::caf::test::detail::adder<::caf::test::test_impl<name##_stream>> \ ::caf::test::detail::adder<::caf::test::test_impl<name##_stream>> \
...@@ -450,7 +445,6 @@ SERIALIZATION_TEST(multiple_messages) { ...@@ -450,7 +445,6 @@ SERIALIZATION_TEST(multiple_messages) {
CAF_CHECK(is_message(m2).equal(i32, i64, dur, ts, te, str, rs)); CAF_CHECK(is_message(m2).equal(i32, i64, dur, ts, te, str, rs));
} }
SERIALIZATION_TEST(type_erased_value) { SERIALIZATION_TEST(type_erased_value) {
auto buf = serialize(str); auto buf = serialize(str);
type_erased_value_ptr ptr{new type_erased_value_impl<std::string>}; type_erased_value_ptr ptr{new type_erased_value_impl<std::string>};
...@@ -524,8 +518,8 @@ SERIALIZATION_TEST(byte_sequence_optimization) { ...@@ -524,8 +518,8 @@ SERIALIZATION_TEST(byte_sequence_optimization) {
e = bd(data); e = bd(data);
CAF_REQUIRE(!e); CAF_REQUIRE(!e);
CAF_CHECK_EQUAL(data.size(), 42u); CAF_CHECK_EQUAL(data.size(), 42u);
CAF_CHECK(std::all_of(data.begin(), data.end(), CAF_CHECK(
[](uint8_t c) { return c == 0x2a; })); std::all_of(data.begin(), data.end(), [](uint8_t c) { return c == 0x2a; }));
} }
SERIALIZATION_TEST(long_sequences) { SERIALIZATION_TEST(long_sequences) {
......
...@@ -81,8 +81,8 @@ error make_error(mock_errc x) { ...@@ -81,8 +81,8 @@ error make_error(mock_errc x) {
} }
// check invariants of type system // check invariants of type system
using dummy1 = typed_actor<reacts_to<int32_t, int32_t>, using dummy1
replies_to<double>::with<double>>; = typed_actor<reacts_to<int32_t, int32_t>, replies_to<double>::with<double>>;
using dummy2 = dummy1::extend<reacts_to<ok_atom>>; using dummy2 = dummy1::extend<reacts_to<ok_atom>>;
...@@ -218,8 +218,8 @@ string_actor::behavior_type string_delegator(string_actor::pointer self, ...@@ -218,8 +218,8 @@ string_actor::behavior_type string_delegator(string_actor::pointer self,
}; };
} }
using maybe_string_actor = typed_actor< using maybe_string_actor
replies_to<string>::with<ok_atom, string>>; = typed_actor<replies_to<string>::with<ok_atom, string>>;
maybe_string_actor::behavior_type maybe_string_reverter() { maybe_string_actor::behavior_type maybe_string_reverter() {
return { return {
...@@ -393,9 +393,9 @@ CAF_TEST(string_delegator_chain) { ...@@ -393,9 +393,9 @@ CAF_TEST(string_delegator_chain) {
std::set<string> iface{"caf::replies_to<@str>::with<@str>"}; std::set<string> iface{"caf::replies_to<@str>::with<@str>"};
CAF_CHECK_EQUAL(aut->message_types(), iface); CAF_CHECK_EQUAL(aut->message_types(), iface);
self->request(aut, infinite, "Hello World!") self->request(aut, infinite, "Hello World!")
.receive([](const string& .receive(
answer) { CAF_CHECK_EQUAL(answer, "!dlroW olleH"); }, [](const string& answer) { CAF_CHECK_EQUAL(answer, "!dlroW olleH"); },
ERROR_HANDLER); ERROR_HANDLER);
} }
CAF_TEST(maybe_string_delegator_chain) { CAF_TEST(maybe_string_delegator_chain) {
...@@ -404,13 +404,13 @@ CAF_TEST(maybe_string_delegator_chain) { ...@@ -404,13 +404,13 @@ CAF_TEST(maybe_string_delegator_chain) {
system.spawn(maybe_string_reverter)); system.spawn(maybe_string_reverter));
CAF_MESSAGE("send empty string, expect error"); CAF_MESSAGE("send empty string, expect error");
self->request(aut, infinite, "") self->request(aut, infinite, "")
.receive([](ok_atom, .receive(
const string&) { CAF_FAIL("unexpected string response"); }, [](ok_atom, const string&) { CAF_FAIL("unexpected string response"); },
[](const error& err) { [](const error& err) {
CAF_CHECK_EQUAL(err.category(), atom("mock")); CAF_CHECK_EQUAL(err.category(), atom("mock"));
CAF_CHECK_EQUAL(err.code(), static_cast<uint8_t>( CAF_CHECK_EQUAL(err.code(),
mock_errc::cannot_revert_empty)); static_cast<uint8_t>(mock_errc::cannot_revert_empty));
}); });
CAF_MESSAGE("send abcd string, expect dcba"); CAF_MESSAGE("send abcd string, expect dcba");
self->request(aut, infinite, "abcd") self->request(aut, infinite, "abcd")
.receive([](ok_atom, const string& str) { CAF_CHECK_EQUAL(str, "dcba"); }, .receive([](ok_atom, const string& str) { CAF_CHECK_EQUAL(str, "dcba"); },
......
...@@ -16,12 +16,11 @@ ...@@ -16,12 +16,11 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include <vector>
#include <random>
#include <iomanip> #include <iomanip>
#include <numeric>
#include <iostream> #include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/opencl/all.hpp" #include "caf/opencl/all.hpp"
...@@ -30,7 +29,7 @@ CAF_BEGIN_TYPE_ID_BLOCK(scan, first_custom_type_id) ...@@ -30,7 +29,7 @@ CAF_BEGIN_TYPE_ID_BLOCK(scan, first_custom_type_id)
CAF_ADD_TYPE_ID(scan, (caf::opencl::dim_vec)) CAF_ADD_TYPE_ID(scan, (caf::opencl::dim_vec))
CAF_ADD_TYPE_ID(scan, (caf::opencl::nd_range)) CAF_ADD_TYPE_ID(scan, (caf::opencl::nd_range))
CAF_ADD_TYPE_ID(scan, (std::vector<uint32_t>)) CAF_ADD_TYPE_ID(scan, (std::vector<uint32_t>) )
CAF_END_TYPE_ID_BLOCK(scan) CAF_END_TYPE_ID_BLOCK(scan)
...@@ -188,8 +187,8 @@ int main() { ...@@ -188,8 +187,8 @@ int main() {
actor_system_config cfg; actor_system_config cfg;
cfg.load<opencl::manager>().add_message_types<id_block::scan>(); cfg.load<opencl::manager>().add_message_types<id_block::scan>();
actor_system system{cfg}; actor_system system{cfg};
cout << "Calculating exclusive scan of '" << problem_size cout << "Calculating exclusive scan of '" << problem_size << "' values."
<< "' values." << endl; << endl;
// ---- create data ---- // ---- create data ----
uvec values(problem_size); uvec values(problem_size);
std::random_device rd; std::random_device rd;
...@@ -211,7 +210,7 @@ int main() { ...@@ -211,7 +210,7 @@ int main() {
} }
if (!opt) { if (!opt) {
cerr << "Not OpenCL device available." << endl; cerr << "Not OpenCL device available." << endl;
return 0; return EXIT_FAILURE;
} else { } else {
cerr << "Found device '" << (*opt)->name() << "'." << endl; cerr << "Found device '" << (*opt)->name() << "'." << endl;
} }
...@@ -244,11 +243,8 @@ int main() { ...@@ -244,11 +243,8 @@ int main() {
return make_message(std::move(vec), static_cast<uval>(size)); return make_message(std::move(vec), static_cast<uval>(size));
}); });
}, },
in_out<uval, val, mref>{}, in_out<uval, val, mref>{}, out<uval, mref>{reduced_ref},
out<uval,mref>{reduced_ref}, local<uval>{half_block * 2}, priv<uval, val>{});
local<uval>{half_block * 2},
priv<uval, val>{}
);
auto phase2 = mngr.spawn( auto phase2 = mngr.spawn(
prog, kernel_name_2, ndr, prog, kernel_name_2, ndr,
[nd_conf](nd_range& range, message& msg) -> optional<message> { [nd_conf](nd_range& range, message& msg) -> optional<message> {
...@@ -259,10 +255,8 @@ int main() { ...@@ -259,10 +255,8 @@ int main() {
static_cast<uval>(size)); static_cast<uval>(size));
}); });
}, },
in_out<uval,mref,mref>{}, in_out<uval, mref, mref>{}, in_out<uval, mref, mref>{},
in_out<uval,mref,mref>{}, priv<uval, val>{});
priv<uval, val>{}
);
auto phase3 = mngr.spawn( auto phase3 = mngr.spawn(
prog, kernel_name_3, ndr, prog, kernel_name_3, ndr,
[nd_conf](nd_range& range, message& msg) -> optional<message> { [nd_conf](nd_range& range, message& msg) -> optional<message> {
...@@ -273,25 +267,19 @@ int main() { ...@@ -273,25 +267,19 @@ int main() {
static_cast<uval>(size)); static_cast<uval>(size));
}); });
}, },
in_out<uval,mref,val>{}, in_out<uval, mref, val>{}, in<uval, mref>{}, priv<uval, val>{});
in<uval,mref>{},
priv<uval, val>{}
);
// ---- composed scan actor ---- // ---- composed scan actor ----
auto scanner = phase3 * phase2 * phase1; auto scanner = phase3 * phase2 * phase1;
// ---- scan the data ---- // ---- scan the data ----
self->send(scanner, values); self->send(scanner, values);
self->receive( self->receive([&](const uvec& results) {
[&](const uvec& results) { cout << "Received results." << endl
cout << "Received results." << endl; << " index | values | scan " << endl
cout << " index | values | scan " << endl << "-------+--------+--------" << endl;
<< "-------+--------+--------" << endl; for (size_t i = 0; i < problem_size; ++i)
for (size_t i = 0; i < problem_size; ++i) cout << std::setw(6) << i << " | " << std::setw(6) << values[i] << " | "
cout << std::setw(6) << i << " | " << std::setw(6) << values[i] << std::setw(6) << results[i] << std::endl;
<< " | " << std::setw(6) << results[i] << std::endl; });
}
);
} }
system.await_all_actors_done(); return EXIT_SUCCESS;
return 0;
} }
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include <vector>
#include <iomanip> #include <iomanip>
#include <numeric>
#include <iostream> #include <iostream>
#include <numeric>
#include <vector>
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/opencl/all.hpp" #include "caf/opencl/all.hpp"
...@@ -30,7 +30,6 @@ CAF_BEGIN_TYPE_ID_BLOCK(simple_matrix, first_custom_type_id) ...@@ -30,7 +30,6 @@ CAF_BEGIN_TYPE_ID_BLOCK(simple_matrix, first_custom_type_id)
CAF_END_TYPE_ID_BLOCK(simple_matrix) CAF_END_TYPE_ID_BLOCK(simple_matrix)
using namespace std; using namespace std;
using namespace caf; using namespace caf;
using namespace caf::opencl; using namespace caf::opencl;
...@@ -101,17 +100,14 @@ void multiplier(event_based_actor* self) { ...@@ -101,17 +100,14 @@ void multiplier(event_based_actor* self) {
// expects its arguments for global memory to be passed in vectors, // expects its arguments for global memory to be passed in vectors,
// the vector type is omitted for brevity. // the vector type is omitted for brevity.
auto worker = self->system().opencl_manager().spawn( auto worker = self->system().opencl_manager().spawn(
kernel_source, kernel_name, kernel_source, kernel_name, nd_range{dim_vec{matrix_size, matrix_size}},
nd_range{dim_vec{matrix_size, matrix_size}}, in<float>{}, in<float>{}, out<float>{});
in<float>{}, in<float>{}, out<float>{}
);
// send both matrices to the actor and wait for a result // send both matrices to the actor and wait for a result
self->request(worker, chrono::seconds(5), move(m1), move(m2)).then( self->request(worker, chrono::seconds(5), move(m1), move(m2))
[](const fvec& result) { .then([](const fvec& result) {
cout << "result: " << endl; cout << "result: " << endl;
print_as_matrix(result); print_as_matrix(result);
} });
);
} }
int main() { int main() {
......
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