Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tansiv
TANSIV
Commits
8767472a
Verified
Commit
8767472a
authored
May 24, 2020
by
SIMONIN Matthieu
Browse files
[benchs/qemus]
- add a first bench (gettimeofday example) - sync with tantap implem (qemus example)
parent
8070d3b5
Changes
7
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
8767472a
...
...
@@ -41,14 +41,19 @@ configure_file(examples/send/deployment.xml examples/send/deployment.xml)
configure_file
(
examples/send/nova_cluster.xml examples/send/nova_cluster.xml
)
add_dependencies
(
send fake-vm
)
# Bench (with vsg)
# Benchs
add_executable
(
gettimeofday examples/benchs/gettimeofday.cpp
)
set_target_properties
(
gettimeofday PROPERTIES RUNTIME_OUTPUT_DIRECTORY examples/benchs
)
target_link_libraries
(
gettimeofday PUBLIC
${
FAKEVM_LIBS
}
vsg
)
configure_file
(
examples/benchs/deployment.xml examples/benchs/deployment.xml
)
configure_file
(
examples/benchs/nova_cluster.xml examples/benchs/nova_cluster.xml
)
add_dependencies
(
gettimeofday fake-vm
)
# Qemus
configure_file
(
examples/qemus/boot_and_log.sh examples/qemus/boot_and_log.sh COPYONLY
)
configure_file
(
examples/qemus/deployment.xml examples/qemus/deployment.xml COPYONLY
)
configure_file
(
examples/qemus/nova_cluster.xml examples/qemus/nova_cluster.xml COPYONLY
)
# Unit tests
add_executable
(
tests src/tests/tests.cpp
)
target_link_libraries
(
tests PUBLIC
${
FAKEVM_LIBS
}
vsg
${
SimGrid_LIBRARY
}
)
...
...
examples/benchs/deployment.xml
0 → 100644
View file @
8767472a
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<platform
version=
"4.1"
>
<actor
host=
"nova-1.lyon.grid5000.fr"
function=
"vsg_vm"
>
<argument
value=
"10.0.0.1"
/>
<!-- whoam i from the protocol perspective; must be consistent with send.cpp:make_addr() -->
<argument
value=
"./examples/benchs/gettimeofday"
/>
</actor>
</platform>
examples/benchs/gettimeofday.cpp
0 → 100644
View file @
8767472a
#include <atomic>
#include <cstring>
#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/time.h>
extern
"C"
{
#include <fake_vm.h>
#include <vsg.h>
}
using
namespace
std
;
// Addresses used in this program
#define ADDR_FMT "10.0.%d.1"
void
die
(
const
char
*
msg
,
int
error
)
{
fprintf
(
stderr
,
"%s"
,
msg
);
if
(
error
)
fprintf
(
stderr
,
"
\t
%s
\n
"
,
std
::
strerror
(
error
));
exit
(
1
);
}
// addr must point at at least INET_ADDRSTRLEN chars.
void
make_addr
(
char
*
addr
,
int
id
)
{
if
(
snprintf
(
addr
,
INET_ADDRSTRLEN
,
ADDR_FMT
,
id
)
>=
INET_ADDRSTRLEN
)
{
die
(
"Invalid address template or id"
,
0
);
}
}
void
recv_cb
(
uintptr_t
arg
)
{
std
::
atomic
<
bool
>*
callback_called
=
(
std
::
atomic
<
bool
>*
)
arg
;
*
callback_called
=
true
;
};
vsg_context
*
init_vsg
(
int
argc
,
char
*
argv
[])
{
std
::
string
src_str
=
"10.0.0.1"
;
uint32_t
src
=
inet_addr
(
src_str
.
c_str
());
int
vsg_argc
=
6
;
const
char
*
const
vsg_argv
[]
=
{
"-a"
,
CONNECTION_SOCKET_NAME
,
"-n"
,
src_str
.
c_str
(),
"-t"
,
"1970-01-01T00:00:00"
};
std
::
atomic
<
bool
>
callback_called
(
false
);
vsg_context
*
context
=
vsg_init
(
vsg_argc
,
vsg_argv
,
NULL
,
recv_cb
,
(
uintptr_t
)
&
callback_called
);
if
(
!
context
)
{
die
(
"Unable to initialize the context"
,
0
);
}
int
ret
=
vsg_start
(
context
);
if
(
ret
)
{
die
(
"Unable to start the vsg client"
,
ret
);
}
return
context
;
}
#define LIMIT 5
int
bench_vsg_gettimeofday
(
int
argc
,
char
*
argv
[])
{
vsg_context
*
context
=
init_vsg
(
argc
,
argv
);
timeval
limit
=
{.
tv_sec
=
LIMIT
,
.
tv_usec
=
0
};
int
loop_count
;
timeval
start
;
vsg_gettimeofday
(
context
,
&
start
,
NULL
);
timeval
current
;
timeval
diff
;
for
(
loop_count
=
0
;
loop_count
<
std
::
numeric_limits
<
int
>::
max
();
loop_count
++
)
{
vsg_gettimeofday
(
context
,
&
current
,
NULL
);
timersub
(
&
current
,
&
start
,
&
diff
);
if
(
timercmp
(
&
diff
,
&
limit
,
>=
))
{
break
;
}
}
printf
(
"I'm done with bench_vsg_gettimeofday
\n
"
);
return
loop_count
;
}
int
bench_gettimeofday
(
int
argc
,
char
*
argv
[])
{
timeval
limit
=
{.
tv_sec
=
LIMIT
,
.
tv_usec
=
0
};
int
loop_count
;
timeval
start
;
gettimeofday
(
&
start
,
NULL
);
timeval
current
;
timeval
diff
;
for
(
loop_count
=
0
;
loop_count
<
std
::
numeric_limits
<
int
>::
max
();
loop_count
++
)
{
// TODO(msimonin): faire un truc genre une addition
// à nombre d'itérations fixé
// compilé en mode release (make RELEASE=0)
// make install avec prefix connu
gettimeofday
(
&
current
,
NULL
);
timersub
(
&
current
,
&
start
,
&
diff
);
if
(
timercmp
(
&
diff
,
&
limit
,
>=
))
{
break
;
}
}
printf
(
"I'm done with bench_gettimeofday
\n
"
);
return
loop_count
;
}
/*
*
* Run a simple benchmark to see the effect of gettimeofday implementation
*/
int
main
(
int
argc
,
char
*
argv
[])
{
int
count1
=
bench_gettimeofday
(
argc
,
argv
);
int
count2
=
bench_vsg_gettimeofday
(
argc
,
argv
);
double
rate1
=
(
double
)
count1
/
LIMIT
;
double
rate2
=
(
double
)
count2
/
LIMIT
;
printf
(
"
\n
"
);
printf
(
"|%-20s|%16.2f /s|
\n
"
,
"gettimeofday"
,
rate1
);
printf
(
"|%-20s|%16.2f /s|
\n
"
,
"vsg_gettimeofday"
,
rate2
);
printf
(
"
\n
"
);
exit
(
0
);
}
examples/benchs/nova_cluster.xml
0 → 100644
View file @
8767472a
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
<platform
version=
"4.1"
>
<zone
id=
"AS0"
routing=
"Full"
>
<cluster
id=
"nova"
prefix=
"nova-"
suffix=
".lyon.grid5000.fr"
radical=
"0-200"
speed=
"16120000000.0f,0.0f,0.0f"
core=
"16"
bw=
"10Gbps"
lat=
"1.0E-4s"
router_id=
"router1"
>
<prop
id=
"watt_per_state"
value=
"75.83:81.97:174.04, 123.86:123.86:123.86, 66:66:66"
/>
<prop
id=
"watt_off"
value=
"8.81"
/>
</cluster>
</zone>
</platform>
examples/qemus/boot_and_log.sh
View file @
8767472a
...
...
@@ -9,14 +9,12 @@ Start an UDP listener and an UDP client inside the VM.
Use
$(
tmux a
)
inside the vm to start using.
USAGE:
./boot_and_log.sh
LISTEN_PORT CONNECT_HOST CONNECT_PORT
./boot_and_log.sh
IP MAC
Positional Arguments:
IP: the ip to use (this is likely to be correlated to the MAC but it's good enough for now)
MAC: the mac address to use
LISTEN_HOST: start an UDP server that will listen on this address in the VM
LISTEN_PORT: start an UDP server that will listen on this port in the VM
CONNECT_HOST: The UDP client will use this a foreign address
CONNECT_PORT: The UDP client will use this as foreign port
Environment Variables:
owned:
...
...
@@ -24,7 +22,6 @@ Environment Variables:
from third party (examples)
SLIRP_DEBUG="all": activate all debug message from slirp
G_MESSAGES_DEBUG="Slirp": glib debug filter
HOSTFWD=hostfwd=tcp::10022-:22: add a redirection
EOF
}
...
...
@@ -34,24 +31,16 @@ then
exit
1
fi
if
((
"$#"
!=
"
4
"
))
if
((
"$#"
!=
"
2
"
))
then
usage
exit
1
fi
LISTEN_HOST
=
$1
shift
LISTEN_PORT
=
$1
shift
IP
=
$1
MAC
=
$2
CONNECT_HOST
=
$1
shift
CONNECT_PORT
=
$1
shift
VM_NAME
=
"vm-
$LISTEN_PORT
"
VM_NAME
=
"vm-
${
MAC
//
:/-
}
"
# A decent key to use
cloud_init_key
=
$(
cat
~/.ssh/id_rsa.pub
)
...
...
@@ -74,10 +63,6 @@ local-hostname: $VM_NAME
disable_root: false
bootcmd:
- echo "-----> START of MY CLOUD INIT <----------
\n
"
- apt update && apt install -y tmux netcat-openbsd
- tmux new-session -s tansiv -d "echo -e 'listener
$LISTEN_HOST
->localhost:
$LISTEN_PORT
\n
'; nc -u -l 0.0.0.0
$LISTEN_PORT
"
- tmux new-session -s tansiv2 -d "echo -e 'client
$CONNECT_HOST
:
$CONNECT_PORT
\n
'; nc -u
$CONNECT_HOST
$CONNECT_PORT
"
- tmux move-pane -s tansiv2 -t tansiv
- echo "-----> END of MY CLOUD INIT <----------
\n
"
EOF
...
...
@@ -93,19 +78,10 @@ VM_IMAGE=$VM_NAME.qcow2
# start on the base one
# VM_IMAGE=debian10-x64-min.qcow2
# redir one udp port passed in parameter:;
UDP_REDIR
=
"hostfwd=udp:
$LISTEN_HOST
:
$LISTEN_PORT
-:
$LISTEN_PORT
"
TCP_REDIR
=
"hostfwd=tcp::1
$LISTEN_PORT
-:22"
if
[
-z
"
$HOSTFWD
"
]
then
HOSTFWD
=
$TCP_REDIR
,
$UDP_REDIR
else
HOSTFWD
=
"
$HOSTFWD
,
$TCP_REDIR
,
$UDP_REDIR
"
fi
TAP_NAME
=
tap
${
MAC
:
(-2)
}
$QEMU
\
-m
1g
\
-drive
file
=
$VM_IMAGE
\
-cdrom
$CLOUD_INIT_ISO
\
-netdev
user
,id
=
net
work0,
$HOSTFWD
\
-device
e1000,netdev
=
net
work0
-netdev
tantap,src
=
$IP
,id
=
my
net
0,ifname
=
$TAP_NAME
,script
=
no,downscript
=
no
\
-device
e1000,netdev
=
my
net
0,mac
=
$MAC
\ No newline at end of file
examples/qemus/deployment.xml
View file @
8767472a
...
...
@@ -3,21 +3,17 @@
<platform
version=
"4.1"
>
<actor
host=
"nova-1.lyon.grid5000.fr"
function=
"vsg_vm"
>
<argument
value=
"192.168.0.
53
"
/>
<!-- how simgrid knows me-->
<argument
value=
"192.168.0.
10
"
/>
<!-- how simgrid knows me-->
<argument
value=
"./examples/qemus/boot_and_log.sh"
/>
<argument
value=
"192.168.0.53"
/>
<!-- listen to this -->
<argument
value=
"1234"
/>
<!-- listen to this -->
<argument
value=
"192.168.0.54"
/>
<!-- connect to this -->
<argument
value=
"1235"
/>
<!-- connect to this -->
<argument
value=
"192.168.0.10"
/>
<!-- how vsg knows me-->
<argument
value=
"52:54:00:00:00:10"
/>
<!-- my mac address so that the dhcp give the above IP -->
</actor>
<actor
host=
"nova-2.lyon.grid5000.fr"
function=
"vsg_vm"
>
<argument
value=
"192.168.0.
54
"
/>
<!-- how simgrid knows me-->
<argument
value=
"192.168.0.
11
"
/>
<!-- how simgrid knows me-->
<argument
value=
"./examples/qemus/boot_and_log.sh"
/>
<argument
value=
"192.168.0.54"
/>
<!-- listen to this -->
<argument
value=
"1235"
/>
<!-- listen to this -->
<argument
value=
"192.168.0.53"
/>
<!-- connect to this -->
<argument
value=
"1234"
/>
<!-- connect to this -->
<argument
value=
"192.168.0.11"
/>
<!-- how vsg knows me-->
<argument
value=
"52:54:00:00:00:11"
/>
<!-- my mac address so that the dhcp give the above IP -->
</actor>
</platform>
\ No newline at end of file
examples/qemus/nova_cluster.xml
0 → 100644
View file @
8767472a
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
<platform
version=
"4.1"
>
<zone
id=
"AS0"
routing=
"Full"
>
<cluster
id=
"nova"
prefix=
"nova-"
suffix=
".lyon.grid5000.fr"
radical=
"0-200"
speed=
"16120000000.0f,0.0f,0.0f"
core=
"16"
bw=
"10Gbps"
lat=
"1.0E-1s"
router_id=
"router1"
>
<prop
id=
"watt_per_state"
value=
"75.83:81.97:174.04, 123.86:123.86:123.86, 66:66:66"
/>
<prop
id=
"watt_off"
value=
"8.81"
/>
</cluster>
</zone>
</platform>
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