Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
78b5ac58
Commit
78b5ac58
authored
May 07, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting
parent
b403c75e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
102 deletions
+72
-102
libcaf_core/caf/detail/implicit_conversions.hpp
libcaf_core/caf/detail/implicit_conversions.hpp
+12
-21
libcaf_core/caf/detail/is_complete.hpp
libcaf_core/caf/detail/is_complete.hpp
+1
-2
libcaf_core/test/selective_streaming.cpp
libcaf_core/test/selective_streaming.cpp
+4
-2
libcaf_core/test/serialization.cpp
libcaf_core/test/serialization.cpp
+13
-19
libcaf_core/test/typed_spawn.cpp
libcaf_core/test/typed_spawn.cpp
+14
-14
libcaf_opencl/examples/scan.cpp
libcaf_opencl/examples/scan.cpp
+21
-33
libcaf_opencl/examples/simple_matrix.cpp
libcaf_opencl/examples/simple_matrix.cpp
+7
-11
No files found.
libcaf_core/caf/detail/implicit_conversions.hpp
View file @
78b5ac58
...
...
@@ -113,16 +113,13 @@ struct implicit_conversions<char*, 0> {
};
template
<
size_t
N
>
struct
implicit_conversions
<
char
[
N
],
0
>
:
implicit_conversions
<
char
*>
{};
struct
implicit_conversions
<
char
[
N
],
0
>
:
implicit_conversions
<
char
*>
{};
template
<
>
struct
implicit_conversions
<
const
char
*
,
0
>
:
implicit_conversions
<
char
*>
{};
struct
implicit_conversions
<
const
char
*
,
0
>
:
implicit_conversions
<
char
*>
{};
template
<
size_t
N
>
struct
implicit_conversions
<
const
char
[
N
],
0
>
:
implicit_conversions
<
char
*>
{};
struct
implicit_conversions
<
const
char
[
N
],
0
>
:
implicit_conversions
<
char
*>
{};
template
<
>
struct
implicit_conversions
<
char16_t
*
,
0
>
{
...
...
@@ -130,8 +127,8 @@ struct implicit_conversions<char16_t*, 0> {
};
template
<
size_t
N
>
struct
implicit_conversions
<
char16_t
[
N
],
0
>
:
implicit_conversions
<
char16_t
*>
{
};
struct
implicit_conversions
<
char16_t
[
N
],
0
>
:
implicit_conversions
<
char16_t
*>
{
};
template
<
>
struct
implicit_conversions
<
const
char16_t
*
,
0
>
...
...
@@ -147,8 +144,8 @@ struct implicit_conversions<char32_t*, 0> {
};
template
<
size_t
N
>
struct
implicit_conversions
<
char32_t
[
N
],
0
>
:
implicit_conversions
<
char32_t
*>
{
};
struct
implicit_conversions
<
char32_t
[
N
],
0
>
:
implicit_conversions
<
char32_t
*>
{
};
template
<
>
struct
implicit_conversions
<
const
char32_t
*
,
0
>
...
...
@@ -168,14 +165,8 @@ using implicit_conversions_t = typename implicit_conversions<T>::type;
template
<
class
T
>
struct
strip_and_convert
{
using
type
=
typename
implicit_conversions
<
typename
std
::
remove_const
<
typename
std
::
remove_reference
<
T
>::
type
>::
type
>::
type
;
using
type
=
typename
implicit_conversions
<
typename
std
::
remove_const
<
typename
std
::
remove_reference
<
T
>::
type
>::
type
>::
type
;
};
template
<
class
T
>
...
...
libcaf_core/caf/detail/is_complete.hpp
View file @
78b5ac58
...
...
@@ -32,8 +32,7 @@ std::false_type is_complete_impl(...);
/// Checks whether T is a complete type. For example, passing a forward
/// declaration or undefined template specialization evaluates to `false`.
template
<
class
T
>
struct
is_complete
{
struct
is_complete
{
static
constexpr
bool
value
=
decltype
(
is_complete_impl
(
std
::
declval
<
T
*>
()))
::
value
;
};
...
...
libcaf_core/test/selective_streaming.cpp
View file @
78b5ac58
...
...
@@ -41,10 +41,12 @@ enum class level;
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
,
(
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
)
...
...
libcaf_core/test/serialization.cpp
View file @
78b5ac58
...
...
@@ -80,7 +80,7 @@ struct test_empty_non_pod;
CAF_BEGIN_TYPE_ID_BLOCK
(
serialization
,
first_custom_type_id
)
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_empty_non_pod
))
CAF_ADD_TYPE_ID
(
serialization
,
(
test_enum
))
...
...
@@ -170,12 +170,9 @@ struct fixture {
test_enum
te
=
test_enum
::
b
;
string
str
=
"Lorem ipsum dolor sit amet."
;
raw_struct
rs
;
test_array
ta
{
test_array
ta
{
{
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
};
...
...
@@ -246,10 +243,8 @@ struct is_message {
bool
ok
=
false
;
// work around for gcc 4.8.4 bug
auto
tup
=
tie
(
v
,
vs
...);
message_handler
impl
{
[
&
](
T
const
&
u
,
Ts
const
&
...
us
)
{
ok
=
tup
==
tie
(
u
,
us
...);
}
message_handler
impl
{
[
&
](
T
const
&
u
,
Ts
const
&
...
us
)
{
ok
=
tup
==
tie
(
u
,
us
...);
},
};
impl
(
msg
);
return
ok
;
...
...
@@ -284,8 +279,8 @@ struct is_message {
void run_test_impl(); \
}; \
using name##_binary = name##_tpl<binary_serializer, binary_deserializer>; \
using name##_stream
= name##_tpl<stream_serializer<vectorbuf>,
\
stream_deserializer<charbuf>>;
\
using name##_stream
\
= name##_tpl<stream_serializer<vectorbuf>, stream_deserializer<charbuf>>;
\
::caf::test::detail::adder<::caf::test::test_impl<name##_binary>> \
CAF_UNIQUE(a_binary){CAF_XSTR(CAF_SUITE), CAF_XSTR(name##_binary), false}; \
::caf::test::detail::adder<::caf::test::test_impl<name##_stream>> \
...
...
@@ -450,7 +445,6 @@ SERIALIZATION_TEST(multiple_messages) {
CAF_CHECK
(
is_message
(
m2
).
equal
(
i32
,
i64
,
dur
,
ts
,
te
,
str
,
rs
));
}
SERIALIZATION_TEST
(
type_erased_value
)
{
auto
buf
=
serialize
(
str
);
type_erased_value_ptr
ptr
{
new
type_erased_value_impl
<
std
::
string
>
};
...
...
@@ -524,8 +518,8 @@ SERIALIZATION_TEST(byte_sequence_optimization) {
e
=
bd
(
data
);
CAF_REQUIRE
(
!
e
);
CAF_CHECK_EQUAL
(
data
.
size
(),
42u
);
CAF_CHECK
(
std
::
all_of
(
data
.
begin
(),
data
.
end
(),
[](
uint8_t
c
)
{
return
c
==
0x2a
;
}));
CAF_CHECK
(
std
::
all_of
(
data
.
begin
(),
data
.
end
(),
[](
uint8_t
c
)
{
return
c
==
0x2a
;
}));
}
SERIALIZATION_TEST
(
long_sequences
)
{
...
...
libcaf_core/test/typed_spawn.cpp
View file @
78b5ac58
...
...
@@ -81,8 +81,8 @@ error make_error(mock_errc x) {
}
// check invariants of type system
using
dummy1
=
typed_actor
<
reacts_to
<
int32_t
,
int32_t
>
,
replies_to
<
double
>::
with
<
double
>>
;
using
dummy1
=
typed_actor
<
reacts_to
<
int32_t
,
int32_t
>
,
replies_to
<
double
>::
with
<
double
>>
;
using
dummy2
=
dummy1
::
extend
<
reacts_to
<
ok_atom
>>
;
...
...
@@ -218,8 +218,8 @@ string_actor::behavior_type string_delegator(string_actor::pointer self,
};
}
using
maybe_string_actor
=
typed_actor
<
replies_to
<
string
>::
with
<
ok_atom
,
string
>>
;
using
maybe_string_actor
=
typed_actor
<
replies_to
<
string
>::
with
<
ok_atom
,
string
>>
;
maybe_string_actor
::
behavior_type
maybe_string_reverter
()
{
return
{
...
...
@@ -393,8 +393,8 @@ CAF_TEST(string_delegator_chain) {
std
::
set
<
string
>
iface
{
"caf::replies_to<@str>::with<@str>"
};
CAF_CHECK_EQUAL
(
aut
->
message_types
(),
iface
);
self
->
request
(
aut
,
infinite
,
"Hello World!"
)
.
receive
(
[](
const
string
&
answer
)
{
CAF_CHECK_EQUAL
(
answer
,
"!dlroW olleH"
);
},
.
receive
(
[](
const
string
&
answer
)
{
CAF_CHECK_EQUAL
(
answer
,
"!dlroW olleH"
);
},
ERROR_HANDLER
);
}
...
...
@@ -404,12 +404,12 @@ CAF_TEST(maybe_string_delegator_chain) {
system
.
spawn
(
maybe_string_reverter
));
CAF_MESSAGE
(
"send empty string, expect error"
);
self
->
request
(
aut
,
infinite
,
""
)
.
receive
(
[](
ok_atom
,
const
string
&
)
{
CAF_FAIL
(
"unexpected string response"
);
},
.
receive
(
[](
ok_atom
,
const
string
&
)
{
CAF_FAIL
(
"unexpected string response"
);
},
[](
const
error
&
err
)
{
CAF_CHECK_EQUAL
(
err
.
category
(),
atom
(
"mock"
));
CAF_CHECK_EQUAL
(
err
.
code
(),
static_cast
<
uint8_t
>
(
mock_errc
::
cannot_revert_empty
));
CAF_CHECK_EQUAL
(
err
.
code
(),
static_cast
<
uint8_t
>
(
mock_errc
::
cannot_revert_empty
));
});
CAF_MESSAGE
(
"send abcd string, expect dcba"
);
self
->
request
(
aut
,
infinite
,
"abcd"
)
...
...
libcaf_opencl/examples/scan.cpp
View file @
78b5ac58
...
...
@@ -16,12 +16,11 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include <vector>
#include <random>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include "caf/all.hpp"
#include "caf/opencl/all.hpp"
...
...
@@ -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
::
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
)
...
...
@@ -188,8 +187,8 @@ int main() {
actor_system_config
cfg
;
cfg
.
load
<
opencl
::
manager
>
().
add_message_types
<
id_block
::
scan
>
();
actor_system
system
{
cfg
};
cout
<<
"Calculating exclusive scan of '"
<<
problem_size
<<
"' values."
<<
endl
;
cout
<<
"Calculating exclusive scan of '"
<<
problem_size
<<
"' values."
<<
endl
;
// ---- create data ----
uvec
values
(
problem_size
);
std
::
random_device
rd
;
...
...
@@ -211,7 +210,7 @@ int main() {
}
if
(
!
opt
)
{
cerr
<<
"Not OpenCL device available."
<<
endl
;
return
0
;
return
EXIT_FAILURE
;
}
else
{
cerr
<<
"Found device '"
<<
(
*
opt
)
->
name
()
<<
"'."
<<
endl
;
}
...
...
@@ -244,11 +243,8 @@ int main() {
return
make_message
(
std
::
move
(
vec
),
static_cast
<
uval
>
(
size
));
});
},
in_out
<
uval
,
val
,
mref
>
{},
out
<
uval
,
mref
>
{
reduced_ref
},
local
<
uval
>
{
half_block
*
2
},
priv
<
uval
,
val
>
{}
);
in_out
<
uval
,
val
,
mref
>
{},
out
<
uval
,
mref
>
{
reduced_ref
},
local
<
uval
>
{
half_block
*
2
},
priv
<
uval
,
val
>
{});
auto
phase2
=
mngr
.
spawn
(
prog
,
kernel_name_2
,
ndr
,
[
nd_conf
](
nd_range
&
range
,
message
&
msg
)
->
optional
<
message
>
{
...
...
@@ -259,10 +255,8 @@ int main() {
static_cast
<
uval
>
(
size
));
});
},
in_out
<
uval
,
mref
,
mref
>
{},
in_out
<
uval
,
mref
,
mref
>
{},
priv
<
uval
,
val
>
{}
);
in_out
<
uval
,
mref
,
mref
>
{},
in_out
<
uval
,
mref
,
mref
>
{},
priv
<
uval
,
val
>
{});
auto
phase3
=
mngr
.
spawn
(
prog
,
kernel_name_3
,
ndr
,
[
nd_conf
](
nd_range
&
range
,
message
&
msg
)
->
optional
<
message
>
{
...
...
@@ -273,25 +267,19 @@ int main() {
static_cast
<
uval
>
(
size
));
});
},
in_out
<
uval
,
mref
,
val
>
{},
in
<
uval
,
mref
>
{},
priv
<
uval
,
val
>
{}
);
in_out
<
uval
,
mref
,
val
>
{},
in
<
uval
,
mref
>
{},
priv
<
uval
,
val
>
{});
// ---- composed scan actor ----
auto
scanner
=
phase3
*
phase2
*
phase1
;
// ---- scan the data ----
self
->
send
(
scanner
,
values
);
self
->
receive
(
[
&
](
const
uvec
&
results
)
{
cout
<<
"Received results."
<<
endl
;
cout
<<
" index | values | scan "
<<
endl
self
->
receive
([
&
](
const
uvec
&
results
)
{
cout
<<
"Received results."
<<
endl
<<
" index | values | scan "
<<
endl
<<
"-------+--------+--------"
<<
endl
;
for
(
size_t
i
=
0
;
i
<
problem_size
;
++
i
)
cout
<<
std
::
setw
(
6
)
<<
i
<<
" | "
<<
std
::
setw
(
6
)
<<
values
[
i
]
<<
" | "
<<
std
::
setw
(
6
)
<<
results
[
i
]
<<
std
::
endl
;
}
);
cout
<<
std
::
setw
(
6
)
<<
i
<<
" | "
<<
std
::
setw
(
6
)
<<
values
[
i
]
<<
" | "
<<
std
::
setw
(
6
)
<<
results
[
i
]
<<
std
::
endl
;
});
}
system
.
await_all_actors_done
();
return
0
;
return
EXIT_SUCCESS
;
}
libcaf_opencl/examples/simple_matrix.cpp
View file @
78b5ac58
...
...
@@ -16,10 +16,10 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include <vector>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <numeric>
#include <vector>
#include "caf/all.hpp"
#include "caf/opencl/all.hpp"
...
...
@@ -30,7 +30,6 @@ CAF_BEGIN_TYPE_ID_BLOCK(simple_matrix, first_custom_type_id)
CAF_END_TYPE_ID_BLOCK
(
simple_matrix
)
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
::
opencl
;
...
...
@@ -101,17 +100,14 @@ void multiplier(event_based_actor* self) {
// expects its arguments for global memory to be passed in vectors,
// the vector type is omitted for brevity.
auto
worker
=
self
->
system
().
opencl_manager
().
spawn
(
kernel_source
,
kernel_name
,
nd_range
{
dim_vec
{
matrix_size
,
matrix_size
}},
in
<
float
>
{},
in
<
float
>
{},
out
<
float
>
{}
);
kernel_source
,
kernel_name
,
nd_range
{
dim_vec
{
matrix_size
,
matrix_size
}},
in
<
float
>
{},
in
<
float
>
{},
out
<
float
>
{});
// send both matrices to the actor and wait for a result
self
->
request
(
worker
,
chrono
::
seconds
(
5
),
move
(
m1
),
move
(
m2
))
.
then
(
[](
const
fvec
&
result
)
{
self
->
request
(
worker
,
chrono
::
seconds
(
5
),
move
(
m1
),
move
(
m2
))
.
then
(
[](
const
fvec
&
result
)
{
cout
<<
"result: "
<<
endl
;
print_as_matrix
(
result
);
}
);
});
}
int
main
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment