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
c0a2a70a
Commit
c0a2a70a
authored
Dec 29, 2021
by
Zhiqiang Xie
Browse files
log blocking timelines in npy files
scripts plotting figures comments
parent
366d651c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
745 additions
and
27 deletions
+745
-27
.gitignore
.gitignore
+5
-0
experiments/parse_timeline.py
experiments/parse_timeline.py
+43
-0
lib/simbricks/nicbm/nicbm.cc
lib/simbricks/nicbm/nicbm.cc
+11
-19
lib/simbricks/proto/npy.hpp
lib/simbricks/proto/npy.hpp
+677
-0
sims/external/gem5
sims/external/gem5
+1
-1
sims/net/switch/net_switch.cc
sims/net/switch/net_switch.cc
+8
-7
No files found.
.gitignore
View file @
c0a2a70a
...
@@ -34,3 +34,8 @@ experiments/slurm
...
@@ -34,3 +34,8 @@ experiments/slurm
dist/net_rdma
dist/net_rdma
trace/process
trace/process
mk/local.mk
mk/local.mk
.vscode
*.log
*.npy
experiments/archived_logs
\ No newline at end of file
experiments/parse_timeline.py
0 → 100644
View file @
c0a2a70a
import
sys
import
numpy
as
np
import
matplotlib.pyplot
as
plt
def
parse_timeline
(
file_name
):
timeline
=
np
.
load
(
file_name
)
# more to be added
plot_execution_ratio
(
timeline
,
file_name
+
'_ratio.png'
)
def
plot_execution_ratio
(
timeline
,
plot_name
,
num_intervals
=
100
):
durations
=
timeline
[
1
:]
-
timeline
[:
-
1
]
time_interval
=
(
timeline
[
-
1
]
-
timeline
[
0
])
/
num_intervals
time_offset
,
flag
=
0
,
-
2
# span[0], span[1]: sum of idle time, sum of execution time
span
,
ratio_list
=
[
0
,
0
],
[]
for
duration
in
durations
:
while
time_offset
+
duration
>
time_interval
:
remaining
=
time_interval
-
time_offset
span
[
flag
]
=
span
[
flag
]
+
remaining
duration
=
duration
-
remaining
time_offset
=
0
ratio_list
.
append
(
span
[
1
]
/
sum
(
span
))
span
=
[
0
,
0
]
else
:
time_offset
=
time_offset
+
duration
span
[
flag
]
=
span
[
flag
]
+
duration
flag
=
~
flag
fig
=
plt
.
figure
()
plt
.
plot
(
ratio_list
)
plt
.
xlabel
(
"time intervals"
)
plt
.
ylabel
(
"ratio of execution (non-blocking)"
)
fig
.
savefig
(
plot_name
)
return
ratio_list
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
==
2
:
parse_timeline
(
sys
.
argv
[
1
])
else
:
print
(
"usage: python parse_timeline.py log_file"
)
lib/simbricks/nicbm/nicbm.cc
View file @
c0a2a70a
...
@@ -35,9 +35,8 @@
...
@@ -35,9 +35,8 @@
#include <ctime>
#include <ctime>
#include <iostream>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <iterator>
#include <simbricks/proto/npy.hpp>
#include <chrono>
extern
"C"
{
extern
"C"
{
#include <simbricks/proto/base.h>
#include <simbricks/proto/base.h>
...
@@ -328,11 +327,6 @@ void Runner::EthSend(const void *data, size_t len) {
...
@@ -328,11 +327,6 @@ void Runner::EthSend(const void *data, size_t len) {
int64_t
rdtsc_cycle
()
{
return
__builtin_ia32_rdtsc
();
}
int64_t
rdtsc_cycle
()
{
return
__builtin_ia32_rdtsc
();
}
int64_t
get_time
()
{
using
namespace
std
::
chrono
;
return
duration_cast
<
microseconds
>
(
steady_clock
::
now
().
time_since_epoch
()).
count
();
}
void
Runner
::
PollH2D
(
std
::
vector
<
int64_t
>
*
block_logging
)
{
void
Runner
::
PollH2D
(
std
::
vector
<
int64_t
>
*
block_logging
)
{
volatile
union
SimbricksProtoPcieH2D
*
msg
=
volatile
union
SimbricksProtoPcieH2D
*
msg
=
SimbricksNicIfH2DPoll
(
&
nsparams_
,
main_time
);
SimbricksNicIfH2DPoll
(
&
nsparams_
,
main_time
);
...
@@ -551,6 +545,8 @@ int Runner::RunMain(int argc, char *argv[]) {
...
@@ -551,6 +545,8 @@ int Runner::RunMain(int argc, char *argv[]) {
bool
is_sync
=
nsparams_
.
sync_pci
||
nsparams_
.
sync_eth
;
bool
is_sync
=
nsparams_
.
sync_pci
||
nsparams_
.
sync_eth
;
// to reduce the overhead, replace '*_block_logging' with statically allocated memory and
// employ another thread to log data into disks
std
::
vector
<
int64_t
>
host_block_logging
=
{
rdtsc_cycle
()};
std
::
vector
<
int64_t
>
host_block_logging
=
{
rdtsc_cycle
()};
std
::
vector
<
int64_t
>
net_block_logging
=
{
rdtsc_cycle
()};
std
::
vector
<
int64_t
>
net_block_logging
=
{
rdtsc_cycle
()};
...
@@ -621,19 +617,15 @@ int Runner::RunMain(int argc, char *argv[]) {
...
@@ -621,19 +617,15 @@ int Runner::RunMain(int argc, char *argv[]) {
(
double
)(
s_h2d_poll_sync
+
s_n2d_poll_sync
)
/
(
s_h2d_poll_suc
+
s_n2d_poll_suc
));
(
double
)(
s_h2d_poll_sync
+
s_n2d_poll_sync
)
/
(
s_h2d_poll_suc
+
s_n2d_poll_suc
));
#endif
#endif
std
::
clock_t
total
=
std
::
clock
();
std
::
string
pid
=
std
::
to_string
(
getpid
());
std
::
string
file_name
=
std
::
string
(
nsparams_
.
pci_socket_path
)
+
pid
+
std
::
string
(
"_nicbm_host_block_logging.npy"
);
std
::
string
file_name
=
std
::
string
(
nsparams_
.
pci_socket_path
)
+
std
::
string
(
"_nicbm_host_block_logging.txt"
);
long
unsigned
npy_shape
[
1
]
=
{
host_block_logging
.
size
()};
std
::
ofstream
output_file
(
file_name
);
npy
::
SaveArrayAsNumpy
(
file_name
,
false
,
1
,
npy_shape
,
host_block_logging
);
output_file
<<
"CLOCKS_PER_SEC: "
<<
CLOCKS_PER_SEC
<<
'\n'
;
output_file
<<
"Total clocks: "
<<
total
<<
'\n'
;
std
::
copy
(
host_block_logging
.
begin
(),
host_block_logging
.
end
(),
std
::
ostream_iterator
<
int64_t
>
(
output_file
,
"
\n
"
));
file_name
=
std
::
string
(
nsparams_
.
pci_socket_path
)
+
std
::
string
(
"_nicbm_net_block_logging.txt"
);
file_name
=
std
::
string
(
nsparams_
.
pci_socket_path
)
+
pid
+
std
::
string
(
"_nicbm_net_block_logging.npy"
);
npy_shape
[
0
]
=
net_block_logging
.
size
();
std
::
ofstream
output_file1
(
file_name
);
std
::
ofstream
output_file1
(
file_name
);
output_file1
<<
"CLOCKS_PER_SEC: "
<<
CLOCKS_PER_SEC
<<
'\n'
;
npy
::
SaveArrayAsNumpy
(
file_name
,
false
,
1
,
npy_shape
,
net_block_logging
);
output_file1
<<
"Total clocks: "
<<
total
<<
'\n'
;
std
::
copy
(
net_block_logging
.
begin
(),
net_block_logging
.
end
(),
std
::
ostream_iterator
<
int64_t
>
(
output_file1
,
"
\n
"
));
SimbricksNicIfCleanup
();
SimbricksNicIfCleanup
();
return
0
;
return
0
;
...
...
lib/simbricks/proto/npy.hpp
0 → 100644
View file @
c0a2a70a
This diff is collapsed.
Click to expand it.
gem5
@
4678052b
Compare
2a38119e
...
4678052b
Subproject commit
2a38119e6a46e871bb540f51557c3c72edc5a253
Subproject commit
4678052bc56b5b85fd4f8da4ced48323eff7e4f9
sims/net/switch/net_switch.cc
View file @
c0a2a70a
...
@@ -37,9 +37,8 @@
...
@@ -37,9 +37,8 @@
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <ctime>
#include <unistd.h>
#include <fstream>
#include <simbricks/proto/npy.hpp>
#include <iterator>
extern
"C"
{
extern
"C"
{
#include <simbricks/netif/netif.h>
#include <simbricks/netif/netif.h>
...
@@ -339,6 +338,8 @@ int main(int argc, char *argv[]) {
...
@@ -339,6 +338,8 @@ int main(int argc, char *argv[]) {
printf
(
"start polling
\n
"
);
printf
(
"start polling
\n
"
);
// to reduce the overhead, replace 'block_logging' with statically allocated memory and
// employ another thread to log data into disks
std
::
vector
<
int64_t
>
block_logging
=
{
rdtsc_cycle
()};
std
::
vector
<
int64_t
>
block_logging
=
{
rdtsc_cycle
()};
while
(
!
exiting
)
{
while
(
!
exiting
)
{
// Sync all interfaces
// Sync all interfaces
...
@@ -385,10 +386,10 @@ int main(int argc, char *argv[]) {
...
@@ -385,10 +386,10 @@ int main(int argc, char *argv[]) {
s_d2n_poll_sync
,
(
double
)
s_d2n_poll_sync
/
s_d2n_poll_suc
);
s_d2n_poll_sync
,
(
double
)
s_d2n_poll_sync
/
s_d2n_poll_suc
);
#endif
#endif
std
::
of
str
eam
output_file
(
"./net_switch_block_logging.txt"
);
std
::
str
ing
pid
=
std
::
to_string
(
getpid
()
);
output_file
<<
"CLOCKS_PER_SEC: "
<<
CLOCKS_PER_SEC
<<
'\n'
;
std
::
string
file_name
=
std
::
string
(
"net_switch_block_logging_"
)
+
pid
+
std
::
string
(
".npy"
)
;
output_file
<<
"Total clocks: "
<<
std
::
clock
()
<<
'\n'
;
const
long
unsigned
npy_shape
[
1
]
=
{
block_logging
.
size
()}
;
std
::
copy
(
block_logging
.
begin
(),
block_logging
.
end
(),
std
::
ostream_iterator
<
int64_t
>
(
output_file
,
"
\n
"
)
);
npy
::
SaveArrayAsNumpy
(
file_name
,
false
,
1
,
npy_shape
,
block_logging
);
return
0
;
return
0
;
}
}
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