Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
12cca0cf
Commit
12cca0cf
authored
Feb 14, 2021
by
Antoine Kaufmann
Browse files
lib/proto: create base header with sync mode defines
parent
803110a8
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
28 deletions
+66
-28
lib/simbricks/netif/netsim.c
lib/simbricks/netif/netsim.c
+6
-5
lib/simbricks/netif/netsim.h
lib/simbricks/netif/netsim.h
+0
-3
lib/simbricks/nicbm/nicbm.cc
lib/simbricks/nicbm/nicbm.cc
+7
-2
lib/simbricks/nicif/nicsim.c
lib/simbricks/nicif/nicsim.c
+8
-7
lib/simbricks/nicif/nicsim.h
lib/simbricks/nicif/nicsim.h
+0
-3
lib/simbricks/proto/base.h
lib/simbricks/proto/base.h
+31
-0
sims/external/gem5
sims/external/gem5
+1
-1
sims/external/qemu
sims/external/qemu
+1
-1
sims/net/switch/net_switch.cc
sims/net/switch/net_switch.cc
+4
-2
sims/net/wire/net_wire.c
sims/net/wire/net_wire.c
+4
-2
sims/nic/corundum/corundum_verilator.cc
sims/nic/corundum/corundum_verilator.cc
+4
-2
No files found.
lib/simbricks/netif/netsim.c
View file @
12cca0cf
...
...
@@ -32,6 +32,7 @@
#include <simbricks/netif/netsim.h>
#include "lib/simbricks/netif/internal.h"
#include <simbricks/proto/base.h>
static
uint64_t
current_epoch
=
0
;
...
...
@@ -144,11 +145,11 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
return
0
;
switch
(
sync_mode
)
{
case
S
YNC_MODE
S
:
case
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
:
do_sync
=
nsif
->
n2d_timestamp
==
0
||
timestamp
-
nsif
->
n2d_timestamp
>=
sync_delay
;
break
;
case
SYNC_BARRIER
:
case
SIMBRICKS_PROTO_
SYNC_BARRIER
:
do_sync
=
current_epoch
==
0
||
timestamp
-
current_epoch
>=
sync_delay
;
break
;
default:
...
...
@@ -174,7 +175,7 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
void
netsim_advance_epoch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
{
if
(
sync_mode
==
SYNC_BARRIER
)
{
if
(
sync_mode
==
SIMBRICKS_PROTO_
SYNC_BARRIER
)
{
if
(
timestamp
-
current_epoch
>=
sync_delay
)
{
current_epoch
=
timestamp
;
}
...
...
@@ -184,9 +185,9 @@ void netsim_advance_epoch(uint64_t timestamp, uint64_t sync_delay,
uint64_t
netsim_advance_time
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
{
switch
(
sync_mode
)
{
case
S
YNC_MODE
S
:
case
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
:
return
timestamp
;
case
SYNC_BARRIER
:
case
SIMBRICKS_PROTO_
SYNC_BARRIER
:
return
timestamp
<
current_epoch
+
sync_delay
?
timestamp
:
current_epoch
+
sync_delay
;
...
...
lib/simbricks/netif/netsim.h
View file @
12cca0cf
...
...
@@ -30,9 +30,6 @@
#include <simbricks/proto/network.h>
#define SYNC_MODES 0
#define SYNC_BARRIER 1
struct
netsim_interface
{
uint8_t
*
d2n_queue
;
size_t
d2n_pos
;
...
...
lib/simbricks/nicbm/nicbm.cc
View file @
12cca0cf
...
...
@@ -35,6 +35,10 @@
#include <ctime>
#include <iostream>
extern
"C"
{
#include <simbricks/proto/base.h>
}
// #define DEBUG_NICBM 1
#define DMA_MAX_PENDING 64
...
...
@@ -394,7 +398,7 @@ int Runner::runMain(int argc, char *argv[]) {
uint64_t
sync_period
=
100
*
1000ULL
;
uint64_t
pci_latency
=
500
*
1000ULL
;
uint64_t
eth_latency
=
500
*
1000ULL
;
int
sync_mode
=
S
YNC_MODE
S
;
int
sync_mode
=
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
;
if
(
argc
<
4
&&
argc
>
9
)
{
fprintf
(
stderr
,
...
...
@@ -428,7 +432,8 @@ int Runner::runMain(int argc, char *argv[]) {
nsparams
.
pci_latency
=
pci_latency
;
nsparams
.
eth_latency
=
eth_latency
;
nsparams
.
sync_delay
=
sync_period
;
assert
(
sync_mode
==
SYNC_MODES
||
sync_mode
==
SYNC_BARRIER
);
assert
(
sync_mode
==
SIMBRICKS_PROTO_SYNC_SIMBRICKS
||
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
nsparams
.
sync_mode
=
sync_mode
;
if
(
nicsim_init
(
&
nsparams
,
&
dintro
))
{
...
...
lib/simbricks/nicif/nicsim.c
View file @
12cca0cf
...
...
@@ -32,6 +32,7 @@
#include <simbricks/nicif/nicsim.h>
#include "lib/simbricks/nicif/internal.h"
#include <simbricks/proto/base.h>
#define D2H_ELEN (9024 + 64)
#define D2H_ENUM 1024
...
...
@@ -259,11 +260,11 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
if
(
params
->
sync_pci
)
{
int
sync
;
switch
(
params
->
sync_mode
)
{
case
S
YNC_MODE
S
:
case
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
:
sync
=
pci_last_tx_time
==
0
||
timestamp
-
pci_last_tx_time
>=
params
->
sync_delay
;
break
;
case
SYNC_BARRIER
:
case
SIMBRICKS_PROTO_
SYNC_BARRIER
:
sync
=
current_epoch
==
0
||
timestamp
-
current_epoch
>=
params
->
sync_delay
;
break
;
...
...
@@ -288,11 +289,11 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
if
(
params
->
sync_eth
)
{
int
sync
;
switch
(
params
->
sync_mode
)
{
case
S
YNC_MODE
S
:
case
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
:
sync
=
eth_last_tx_time
==
0
||
timestamp
-
eth_last_tx_time
>=
params
->
sync_delay
;
break
;
case
SYNC_BARRIER
:
case
SIMBRICKS_PROTO_
SYNC_BARRIER
:
sync
=
current_epoch
==
0
||
timestamp
-
current_epoch
>=
params
->
sync_delay
;
break
;
...
...
@@ -316,7 +317,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
}
void
nicsim_advance_epoch
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
if
(
params
->
sync_mode
==
SYNC_BARRIER
)
{
if
(
params
->
sync_mode
==
SIMBRICKS_PROTO_
SYNC_BARRIER
)
{
if
((
params
->
sync_pci
||
params
->
sync_eth
)
&&
timestamp
-
current_epoch
>=
params
->
sync_delay
)
{
current_epoch
=
timestamp
;
...
...
@@ -326,9 +327,9 @@ void nicsim_advance_epoch(struct nicsim_params *params, uint64_t timestamp) {
uint64_t
nicsim_advance_time
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
switch
(
params
->
sync_mode
)
{
case
S
YNC_MODE
S
:
case
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
:
return
timestamp
;
case
SYNC_BARRIER
:
case
SIMBRICKS_PROTO_
SYNC_BARRIER
:
return
timestamp
<
current_epoch
+
params
->
sync_delay
?
timestamp
:
current_epoch
+
params
->
sync_delay
;
...
...
lib/simbricks/nicif/nicsim.h
View file @
12cca0cf
...
...
@@ -28,9 +28,6 @@
#include <simbricks/proto/network.h>
#include <simbricks/proto/pcie.h>
#define SYNC_MODES 0 // ModES style synchronization
#define SYNC_BARRIER 1 // Global barrier style synchronization
struct
nicsim_params
{
const
char
*
pci_socket_path
;
const
char
*
eth_socket_path
;
...
...
lib/simbricks/proto/base.h
0 → 100644
View file @
12cca0cf
/*
* Copyright 2021 Max Planck Institute for Software Systems, and
* National University of Singapore
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SIMBRICKS_PROTO_BASE_H_
#define SIMBRICKS_PROTO_BASE_H_
#define SIMBRICKS_PROTO_SYNC_SIMBRICKS 0
#define SIMBRICKS_PROTO_SYNC_BARRIER 1
#endif // SIMBRICKS_PROTO_BASE_H_
gem5
@
84aa4eeb
Compare
3424c70b
...
84aa4eeb
Subproject commit
3424c70bf8309fab93e8e4a76225452c9c967f58
Subproject commit
84aa4eeb7696741c355ca0b508c6760d90481710
qemu
@
885a383b
Compare
a25e4b55
...
885a383b
Subproject commit
a25e4b55426c5120acd204e4f293b1de7d7fe82b
Subproject commit
885a383bf495d94e9dcbf74557fc6cb1c0212090
sims/net/switch/net_switch.cc
View file @
12cca0cf
...
...
@@ -35,6 +35,7 @@
extern
"C"
{
#include <simbricks/netif/netsim.h>
#include <simbricks/proto/base.h>
};
static
uint64_t
sync_period
=
(
500
*
1000ULL
);
// 500ns
...
...
@@ -141,7 +142,7 @@ static void switch_pkt(struct netsim_interface *nsif, int iport) {
int
main
(
int
argc
,
char
*
argv
[])
{
int
c
;
int
bad_option
=
0
;
int
sync_mode
=
S
YNC_MODE
S
;
int
sync_mode
=
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
;
// Parse command line argument
while
((
c
=
getopt
(
argc
,
argv
,
"s:S:E:m:"
))
!=
-
1
&&
!
bad_option
)
{
...
...
@@ -167,7 +168,8 @@ int main(int argc, char *argv[]) {
case
'm'
:
sync_mode
=
strtol
(
optarg
,
NULL
,
0
);
assert
(
sync_mode
==
SYNC_MODES
||
sync_mode
==
SYNC_BARRIER
);
assert
(
sync_mode
==
SIMBRICKS_PROTO_SYNC_SIMBRICKS
||
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
break
;
default:
...
...
sims/net/wire/net_wire.c
View file @
12cca0cf
...
...
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <simbricks/netif/netsim.h>
#include <simbricks/proto/base.h>
static
uint64_t
sync_period
=
(
500
*
1000ULL
);
// 500ns
static
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
...
...
@@ -106,7 +107,7 @@ int main(int argc, char *argv[]) {
uint64_t
ts_a
,
ts_b
;
int
sync_a
,
sync_b
;
pcap_t
*
pc
=
NULL
;
int
sync_mode
=
S
YNC_MODE
S
;
int
sync_mode
=
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
;
if
(
argc
<
3
&&
argc
>
7
)
{
fprintf
(
stderr
,
...
...
@@ -139,7 +140,8 @@ int main(int argc, char *argv[]) {
dumpfile
=
pcap_dump_open
(
pc
,
argv
[
6
]);
}
assert
(
sync_mode
==
SYNC_MODES
||
sync_mode
==
SYNC_BARRIER
);
assert
(
sync_mode
==
SIMBRICKS_PROTO_SYNC_SIMBRICKS
||
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
sync_a
=
sync_b
=
1
;
if
(
netsim_init
(
&
nsif_a
,
argv
[
1
],
&
sync_a
)
!=
0
)
{
...
...
sims/nic/corundum/corundum_verilator.cc
View file @
12cca0cf
...
...
@@ -34,6 +34,7 @@
extern
"C"
{
#include <simbricks/nicif/nicsim.h>
#include <simbricks/proto/base.h>
#include <simbricks/proto/pcie.h>
}
...
...
@@ -794,7 +795,7 @@ static void msi_step(Vinterface &top, PCICoordinator &coord) {
int
main
(
int
argc
,
char
*
argv
[])
{
char
*
vargs
[
2
]
=
{
argv
[
0
],
NULL
};
Verilated
::
commandArgs
(
1
,
vargs
);
int
sync_mode
=
S
YNC_MODE
S
;
int
sync_mode
=
S
IMBRICKS_PROTO_SYNC_SIMBRICK
S
;
#ifdef TRACE_ENABLED
Verilated
::
traceEverOn
(
true
);
#endif
...
...
@@ -840,7 +841,8 @@ int main(int argc, char *argv[]) {
nsparams
.
pci_latency
=
pci_latency
;
nsparams
.
eth_latency
=
eth_latency
;
nsparams
.
sync_delay
=
sync_period
;
assert
(
sync_mode
==
SYNC_MODES
||
sync_mode
==
SYNC_BARRIER
);
assert
(
sync_mode
==
SIMBRICKS_PROTO_SYNC_SIMBRICKS
||
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
nsparams
.
sync_mode
=
sync_mode
;
if
(
nicsim_init
(
&
nsparams
,
&
di
))
{
...
...
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