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
ad3754fa
Commit
ad3754fa
authored
Jan 21, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
num_cores
parent
2ee9b056
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
211 additions
and
61 deletions
+211
-61
benchmarks/mixed_case.cpp
benchmarks/mixed_case.cpp
+32
-61
benchmarks/theron_mixed_case.cpp
benchmarks/theron_mixed_case.cpp
+152
-0
benchmarks/utility.hpp
benchmarks/utility.hpp
+26
-0
cppa.files
cppa.files
+1
-0
No files found.
benchmarks/mixed_case.cpp
View file @
ad3754fa
...
@@ -51,31 +51,6 @@ constexpr uint64_t s_task_n = uint64_t(86028157)*329545133;
...
@@ -51,31 +51,6 @@ constexpr uint64_t s_task_n = uint64_t(86028157)*329545133;
constexpr
uint64_t
s_factor1
=
86028157
;
constexpr
uint64_t
s_factor1
=
86028157
;
constexpr
uint64_t
s_factor2
=
329545133
;
constexpr
uint64_t
s_factor2
=
329545133
;
factors
factorize
(
uint64_t
n
)
{
factors
result
;
if
(
n
<=
3
)
{
result
.
push_back
(
n
);
return
std
::
move
(
result
);
}
uint64_t
d
=
2
;
while
(
d
<
n
)
{
if
((
n
%
d
)
==
0
)
{
result
.
push_back
(
d
);
n
/=
d
;
}
else
{
d
=
(
d
==
2
)
?
3
:
(
d
+
2
);
}
}
result
.
push_back
(
d
);
return
std
::
move
(
result
);
}
void
check_factors
(
factors
const
&
vec
)
void
check_factors
(
factors
const
&
vec
)
{
{
assert
(
vec
.
size
()
==
2
);
assert
(
vec
.
size
()
==
2
);
...
@@ -148,9 +123,7 @@ struct fsm_chain_master : fsm_actor<fsm_chain_master>
...
@@ -148,9 +123,7 @@ struct fsm_chain_master : fsm_actor<fsm_chain_master>
new_ring
(
rs
,
itv
);
new_ring
(
rs
,
itv
);
become
become
(
(
on
<
atom
(
"token"
),
int
>
()
>>
[
=
](
int
v
)
on
(
atom
(
"token"
),
0
)
>>
[
=
]()
{
if
(
v
==
0
)
{
{
if
(
++
iteration
<
n
)
if
(
++
iteration
<
n
)
{
{
...
@@ -162,12 +135,11 @@ struct fsm_chain_master : fsm_actor<fsm_chain_master>
...
@@ -162,12 +135,11 @@ struct fsm_chain_master : fsm_actor<fsm_chain_master>
send
(
mc
,
atom
(
"masterdone"
));
send
(
mc
,
atom
(
"masterdone"
));
become_void
();
become_void
();
}
}
}
},
else
on
<
atom
(
"token"
),
int
>
()
>>
[
=
](
int
v
)
{
{
send
(
next
,
atom
(
"token"
),
v
-
1
);
send
(
next
,
atom
(
"token"
),
v
-
1
);
}
}
}
);
);
}
}
);
);
...
@@ -312,15 +284,17 @@ void run_test(F&& spawn_impl,
...
@@ -312,15 +284,17 @@ void run_test(F&& spawn_impl,
void
usage
()
void
usage
()
{
{
cout
<<
"usage: mailbox_performance "
cout
<<
"usage: mailbox_performance "
"(stacked|event-based) (ring size) (repetitions)"
<<
endl
"(stacked|event-based) (num rings) (ring size) "
"(initial token value) (repetitions)"
<<
endl
<<
endl
;
<<
endl
;
exit
(
1
);
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
announce
<
factors
>
();
announce
<
factors
>
();
if
(
argc
==
6
)
if
(
argc
!=
6
)
usage
();
{
int
num_rings
=
rd
<
int
>
(
argv
[
2
]);
int
num_rings
=
rd
<
int
>
(
argv
[
2
]);
int
ring_size
=
rd
<
int
>
(
argv
[
3
]);
int
ring_size
=
rd
<
int
>
(
argv
[
3
]);
int
initial_token_value
=
rd
<
int
>
(
argv
[
4
]);
int
initial_token_value
=
rd
<
int
>
(
argv
[
4
]);
...
@@ -340,7 +314,4 @@ int main(int argc, char** argv)
...
@@ -340,7 +314,4 @@ int main(int argc, char** argv)
num_rings
,
ring_size
,
initial_token_value
,
repetitions
);
num_rings
,
ring_size
,
initial_token_value
,
repetitions
);
return
0
;
return
0
;
}
}
}
cerr
<<
"usage: mixed_case (stacked|event-based)"
<<
endl
;
return
1
;
}
}
benchmarks/theron_mixed_case.cpp
0 → 100644
View file @
ad3754fa
#define THERON_USE_BOOST_THREADS 1
#include <Theron/Framework.h>
#include <Theron/Actor.h>
#include <thread>
#include <cstdint>
#include <iostream>
#include <functional>
#include "utility.hpp"
using
std
::
cerr
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
int64_t
;
using
namespace
Theron
;
constexpr
uint64_t
s_task_n
=
uint64_t
(
86028157
)
*
329545133
;
constexpr
uint64_t
s_factor1
=
86028157
;
constexpr
uint64_t
s_factor2
=
329545133
;
typedef
std
::
vector
<
uint64_t
>
factors
;
struct
calc_msg
{
uint64_t
value
;
};
struct
result_msg
{
factors
result
;
};
struct
token_msg
{
int
value
;
};
struct
init_msg
{
int
ring_size
;
int
token_value
;
int
iterations
;
};
struct
master_done
{
};
struct
worker_done
{
};
struct
worker
:
Actor
{
void
handle_calc
(
calc_msg
const
&
msg
,
Address
from
)
{
factorize
(
msg
.
value
);
}
void
handle_master_done
(
master_done
const
&
,
Address
from
)
{
Send
(
worker_done
(),
from
);
}
worker
()
{
RegisterHandler
(
this
,
&
worker
::
handle_calc
);
RegisterHandler
(
this
,
&
worker
::
handle_master_done
);
}
};
struct
chain_link
:
Actor
{
Address
next
;
void
handle_token
(
token_msg
const
&
msg
,
Address
)
{
Send
(
msg
,
next
);
}
typedef
struct
{
Address
next
}
Parameters
;
chain_link
(
Parameters
const
&
p
)
:
next
(
p
.
next
)
{
RegisterHandler
(
this
,
&
chain_link
::
handle_token
);
}
}
;
struct
master
:
Actor
{
Address
mc
;
int
iteration
;
int
max_iterations
;
Address
next
;
ActorRef
worker
;
int
ring_size
;
int
initial_token_value
;
std
::
vector
<
ActorRef
>
m_children
;
void
new_ring
()
{
m_children
.
clear
();
worker
.
Push
(
calc_msg
{
s_task_n
},
GetAddress
());
next
=
GetAddress
();
for
(
int
i
=
1
;
i
<
ring_size
;
++
i
)
{
m_children
.
push_back
(
GetFramework
().
CreateActor
<
chain_link
>
(
chain_link
::
Parameters
(
next
)));
next
=
m_children
.
back
().
GetAddress
();
}
Send
(
token_msg
{
initial_token_value
},
next
);
}
void
handle_init
(
init_msg
const
&
msg
,
Address
)
{
worker
=
GetFramework
().
CreateActor
<
worker
>
();
iteration
=
0
;
ring_size
=
msg
.
ring_size
;
initial_token_value
=
msg
.
token_value
;
max_iterations
=
msg
.
iterations
;
new_ring
();
}
void
handle_token
(
token_msg
const
&
msg
,
Address
)
{
if
(
msg
.
value
==
0
)
{
if
(
++
iteration
<
max_iterations
)
{
new_ring
();
}
else
{
worker
.
Push
(
master_done
(),
GetAddress
());
}
}
else
{
Send
(
token_msg
{
msg
.
value
-
1
},
next
);
}
}
void
handle_worker_done
(
worker_done
const
&
,
Address
)
{
Send
(
master_done
(),
mc
);
}
typedef
struct
{
Address
mc
;
}
Parameters
;
master
(
Parameters
const
&
p
)
mc
(
p
.
mc
),
iteration
(
0
)
{
}
}
;
void
usage
()
{
cout
<<
"usage: mailbox_performance "
"_ (num rings) (ring size) "
"(initial token value) (repetitions)"
<<
endl
<<
endl
;
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
6
)
usage
();
int
num_rings
=
rd
<
int
>
(
argv
[
2
]);
int
ring_size
=
rd
<
int
>
(
argv
[
3
]);
int
inital_token_value
=
rd
<
int
>
(
argv
[
4
]);
int
repetitions
=
rd
<
int
>
(
argv
[
5
]);
Receiver
r
;
Framework
framework
(
num_cores
());
std
::
vector
<
ActorRef
>
masters
;
for
(
int
i
=
0
;
i
<
num_rings
;
++
i
)
{
masters
.
push_back
(
framework
.
CreateActor
<
master
>
(
master
::
Parameters
{
r
.
GetAddress
()}));
}
for
(
ActorRef
&
m
:
masters
)
{
m
.
Push
(
init_msg
{
ring_size
,
inital_token_value
,
repetitions
},
r
.
GetAddress
());
}
for
(
int
i
=
0
;
i
<
num_rings
;
++
i
)
r
.
Wait
();
return
0
;
}
benchmarks/utility.hpp
View file @
ad3754fa
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#ifndef UTILITY_HPP
#ifndef UTILITY_HPP
#define UTILITY_HPP
#define UTILITY_HPP
#include <vector>
#include <stdexcept>
#include <stdexcept>
#include <algorithm>
#include <algorithm>
...
@@ -65,4 +66,29 @@ int num_cores()
...
@@ -65,4 +66,29 @@ int num_cores()
return
rd
<
int
>
(
cbuf
);
return
rd
<
int
>
(
cbuf
);
}
}
std
::
vector
<
uint64_t
>
factorize
(
uint64_t
n
)
{
std
::
vector
<
uint64_t
>
result
;
if
(
n
<=
3
)
{
result
.
push_back
(
n
);
return
std
::
move
(
result
);
}
uint64_t
d
=
2
;
while
(
d
<
n
)
{
if
((
n
%
d
)
==
0
)
{
result
.
push_back
(
d
);
n
/=
d
;
}
else
{
d
=
(
d
==
2
)
?
3
:
(
d
+
2
);
}
}
result
.
push_back
(
d
);
return
std
::
move
(
result
);
}
#endif // UTILITY_HPP
#endif // UTILITY_HPP
cppa.files
View file @
ad3754fa
...
@@ -258,3 +258,4 @@ benchmarks/matching.erl
...
@@ -258,3 +258,4 @@ benchmarks/matching.erl
benchmarks/theron_mailbox_performance.cpp
benchmarks/theron_mailbox_performance.cpp
benchmarks/utility.hpp
benchmarks/utility.hpp
benchmarks/theron_actor_creation.cpp
benchmarks/theron_actor_creation.cpp
benchmarks/theron_mixed_case.cpp
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