Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
syscall-eval
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lehrstuhl für Informatik 4 (Systemsoftware)
manycore
syscall-eval
Commits
3bb12208
Commit
3bb12208
authored
3 years ago
by
Florian Fischer
Browse files
Options
Downloads
Patches
Plain Diff
use uint64_t for cycles and average calculation
parent
6e546000
No related branches found
No related tags found
1 merge request
!2
work work work
Pipeline
#66484
passed
3 years ago
Stage: test
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+3
-1
3 additions, 1 deletion
Makefile
bench.c
+7
-3
7 additions, 3 deletions
bench.c
stopwatch.c
+2
-2
2 additions, 2 deletions
stopwatch.c
stopwatch.h
+4
-4
4 additions, 4 deletions
stopwatch.h
with
16 additions
and
10 deletions
Makefile
+
3
−
1
View file @
3bb12208
...
@@ -8,7 +8,7 @@ LDFLAGS := -luring -pthread -lrt
...
@@ -8,7 +8,7 @@ LDFLAGS := -luring -pthread -lrt
CFLAGS
:=
-Werror
-Wall
-g
-O3
CFLAGS
:=
-Werror
-Wall
-g
-O3
# CFLAGS := -Werror -Wall -g -O0
# CFLAGS := -Werror -Wall -g -O0
.PHONY
:
all clean eval docker-eval
.PHONY
:
all clean eval docker-eval
check
eval
:
all
eval
:
all
@
for
syscall
in
$(
SYSCALLS
);
do
echo
-n
"
$$
syscall "
;
./bench-
$$
syscall
;
done
@
for
syscall
in
$(
SYSCALLS
);
do
echo
-n
"
$$
syscall "
;
./bench-
$$
syscall
;
done
...
@@ -28,6 +28,8 @@ $(foreach syscall,$(SYSCALLS),$(eval $(call generateTargets,$(syscall))))
...
@@ -28,6 +28,8 @@ $(foreach syscall,$(SYSCALLS),$(eval $(call generateTargets,$(syscall))))
clean
:
clean
:
rm
-f
$(
OBJ
)
rm
-f
$(
OBJ
)
check
:
tidy check-format
tidy
:
tidy
:
clang-tidy
*
.c
clang-tidy
*
.c
...
...
This diff is collapsed.
Click to expand it.
bench.c
+
7
−
3
View file @
3bb12208
...
@@ -42,8 +42,12 @@ int main() {
...
@@ -42,8 +42,12 @@ int main() {
errx
(
EXIT_FAILURE
,
"cycles overflowed at %ld"
,
i
);
errx
(
EXIT_FAILURE
,
"cycles overflowed at %ld"
,
i
);
}
}
double
avg_nanos
=
nanos_sum
/
(
double
)
iterations
;
// Since uint64_t <-> double conversion are not well defined
double
avg_cycles
=
cycles_sum
/
(
double
)
iterations
;
// and we use really small units (cycles and nanoseconds) I am willing
printf
(
"%lf ns, %lf cycles
\n
"
,
avg_nanos
,
avg_cycles
);
// to accept that we throw away anything after the decimal point.
uint64_t
avg_nanos
=
nanos_sum
/
iterations
;
uint64_t
avg_cycles
=
cycles_sum
/
iterations
;
printf
(
"%lu ns, %lu cycles
\n
"
,
avg_nanos
,
avg_cycles
);
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
stopwatch.c
+
2
−
2
View file @
3bb12208
#include
"stopwatch.h"
#include
"stopwatch.h"
int64_t
cycles_start
,
cycles_stop
;
u
int64_t
cycles_start
,
cycles_stop
;
struct
timespec
start
,
stop
;
struct
timespec
start
,
stop
;
int64_t
sec_to_nanos
(
int64_t
sec
)
{
return
sec
*
1000
*
1000
*
1000
;
}
int64_t
sec_to_nanos
(
int64_t
sec
)
{
return
sec
*
1000
*
1000
*
1000
;
}
...
@@ -13,4 +13,4 @@ int64_t clock_diff_nanos() {
...
@@ -13,4 +13,4 @@ int64_t clock_diff_nanos() {
return
nanos
;
return
nanos
;
}
}
int64_t
clock_diff_cycles
()
{
return
cycles_stop
-
cycles_start
;
}
u
int64_t
clock_diff_cycles
()
{
return
cycles_stop
-
cycles_start
;
}
This diff is collapsed.
Click to expand it.
stopwatch.h
+
4
−
4
View file @
3bb12208
...
@@ -3,17 +3,17 @@
...
@@ -3,17 +3,17 @@
#include
<stdint.h>
#include
<stdint.h>
#include
<time.h>
#include
<time.h>
extern
int64_t
cycles_start
,
cycles_stop
;
extern
u
int64_t
cycles_start
,
cycles_stop
;
extern
struct
timespec
start
,
stop
;
extern
struct
timespec
start
,
stop
;
static
__inline__
int64_t
rdtsc_s
(
void
)
{
static
__inline__
u
int64_t
rdtsc_s
(
void
)
{
unsigned
a
,
d
;
unsigned
a
,
d
;
asm
volatile
(
"cpuid"
:::
"%rax"
,
"%rbx"
,
"%rcx"
,
"%rdx"
);
asm
volatile
(
"cpuid"
:::
"%rax"
,
"%rbx"
,
"%rcx"
,
"%rdx"
);
asm
volatile
(
"rdtsc"
:
"=a"
(
a
),
"=d"
(
d
));
asm
volatile
(
"rdtsc"
:
"=a"
(
a
),
"=d"
(
d
));
return
((
unsigned
long
)
a
)
|
(((
unsigned
long
)
d
)
<<
32
);
return
((
unsigned
long
)
a
)
|
(((
unsigned
long
)
d
)
<<
32
);
}
}
static
__inline__
int64_t
rdtsc_e
(
void
)
{
static
__inline__
u
int64_t
rdtsc_e
(
void
)
{
unsigned
a
,
d
;
unsigned
a
,
d
;
asm
volatile
(
"rdtscp"
:
"=a"
(
a
),
"=d"
(
d
));
asm
volatile
(
"rdtscp"
:
"=a"
(
a
),
"=d"
(
d
));
asm
volatile
(
"cpuid"
:::
"%rax"
,
"%rbx"
,
"%rcx"
,
"%rdx"
);
asm
volatile
(
"cpuid"
:::
"%rax"
,
"%rbx"
,
"%rcx"
,
"%rdx"
);
...
@@ -30,7 +30,7 @@ static inline void stop_watch() {
...
@@ -30,7 +30,7 @@ static inline void stop_watch() {
clock_gettime
(
CLOCK_MONOTONIC
,
&
stop
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
stop
);
}
}
int64_t
clock_diff_cycles
();
u
int64_t
clock_diff_cycles
();
int64_t
clock_diff_nanos
();
int64_t
clock_diff_nanos
();
double
nanos_to_millis
(
int64_t
nanos
);
double
nanos_to_millis
(
int64_t
nanos
);
int64_t
sec_to_nanos
(
int64_t
sec
);
int64_t
sec_to_nanos
(
int64_t
sec
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment