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
2231bf37
"...resnet50_tensorflow.git" did not exist on "5223e64bcde282e1e7146528b6f5fb58ccdf0245"
Commit
2231bf37
authored
Jan 25, 2022
by
Jialin Li
Browse files
tofino: replace set with priority_queue
parent
7099017e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
sims/tofino/tofino.cc
sims/tofino/tofino.cc
+8
-7
No files found.
sims/tofino/tofino.cc
View file @
2231bf37
...
@@ -40,9 +40,10 @@
...
@@ -40,9 +40,10 @@
#include <cstring>
#include <cstring>
#include <fstream>
#include <fstream>
#include <iostream>
#include <iostream>
#include <
set
>
#include <
queue
>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <set>
extern
"C"
{
extern
"C"
{
#include <simbricks/netif/netif.h>
#include <simbricks/netif/netif.h>
...
@@ -86,10 +87,10 @@ struct event {
...
@@ -86,10 +87,10 @@ struct event {
};
};
struct
classcomp
{
struct
classcomp
{
bool
operator
()(
const
struct
event
&
lhs
,
const
struct
event
&
rhs
)
const
{
bool
operator
()(
const
struct
event
&
lhs
,
const
struct
event
&
rhs
)
const
{
return
lhs
.
time
<
rhs
.
time
;
return
lhs
.
time
>
rhs
.
time
;
}
}
};
};
std
::
set
<
struct
event
,
classcomp
>
event_queue
;
std
::
priority_queue
<
struct
event
,
std
::
vector
<
struct
event
>
,
classcomp
>
event_queue
;
static
bool
get_tofino_log_line
(
int
limit_ms
)
{
static
bool
get_tofino_log_line
(
int
limit_ms
)
{
using
std
::
chrono
::
system_clock
;
using
std
::
chrono
::
system_clock
;
...
@@ -213,7 +214,7 @@ static void process_event(const struct event &e) {
...
@@ -213,7 +214,7 @@ static void process_event(const struct event &e) {
de
.
time
=
cur_ts
+
pkt
.
latency
;
de
.
time
=
cur_ts
+
pkt
.
latency
;
de
.
to_switch
=
false
;
de
.
to_switch
=
false
;
de
.
port
=
pkt
.
port
;
de
.
port
=
pkt
.
port
;
event_queue
.
insert
(
de
);
event_queue
.
push
(
de
);
#ifdef DEBUG
#ifdef DEBUG
printf
(
"add to_dev event to peer %u at time %llu to queue
\n
"
,
de
.
port
,
printf
(
"add to_dev event to peer %u at time %llu to queue
\n
"
,
de
.
port
,
de
.
time
);
de
.
time
);
...
@@ -246,7 +247,7 @@ static void recv_from_peer(int port) {
...
@@ -246,7 +247,7 @@ static void recv_from_peer(int port) {
printf
(
"received packet from peer %u at time %llu
\n
"
,
port
,
e
.
time
);
printf
(
"received packet from peer %u at time %llu
\n
"
,
port
,
e
.
time
);
#endif
#endif
if
(
nsif
->
sync
)
{
if
(
nsif
->
sync
)
{
event_queue
.
insert
(
e
);
event_queue
.
push
(
e
);
#ifdef DEBUG
#ifdef DEBUG
printf
(
"add to_switch event from peer %u at time %llu to queue
\n
"
,
port
,
printf
(
"add to_switch event from peer %u at time %llu to queue
\n
"
,
port
,
e
.
time
);
e
.
time
);
...
@@ -264,10 +265,10 @@ static void recv_from_peer(int port) {
...
@@ -264,10 +265,10 @@ static void recv_from_peer(int port) {
static
void
process_event_queue
()
{
static
void
process_event_queue
()
{
while
(
!
event_queue
.
empty
())
{
while
(
!
event_queue
.
empty
())
{
const
struct
event
&
e
=
*
event_queue
.
begin
();
const
struct
event
&
e
=
event_queue
.
top
();
if
(
e
.
time
<=
cur_ts
)
{
if
(
e
.
time
<=
cur_ts
)
{
process_event
(
e
);
process_event
(
e
);
event_queue
.
erase
(
event_queue
.
begin
()
);
event_queue
.
pop
(
);
}
else
{
}
else
{
break
;
break
;
}
}
...
...
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