Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pipedream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GRUBER Fabian
pipedream
Commits
7b039b29
Commit
7b039b29
authored
4 years ago
by
Nicolas Derumigny
Browse files
Options
Downloads
Patches
Plain Diff
benchmark/common: correctly aligning argument of benchmark_kernel
parent
b5782fef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pipedream/benchmark/common.py
+32
-40
32 additions, 40 deletions
src/pipedream/benchmark/common.py
with
32 additions
and
40 deletions
src/pipedream/benchmark/common.py
+
32
−
40
View file @
7b039b29
...
...
@@ -1666,6 +1666,23 @@ class _Benchmark_Runner:
benchmarks
=
benchmark_functions
,
)
# Assign and pre-fil with random values an array
@staticmethod
def
aligned_alloc_byte_array
(
length
,
align
:
int
,
rand_values
=
False
):
buf
=
(
ctypes
.
c_byte
*
(
length
+
align
-
1
))()
if
rand_values
:
random
.
seed
(
42
)
for
i
in
range
(
length
+
align
-
1
):
buf
[
i
]
=
random
.
getrandbits
(
8
)
addr
=
ctypes
.
addressof
(
buf
)
offset
=
(
align
-
(
addr
%
align
))
%
align
assert
(
addr
+
offset
)
%
align
==
0
buf
=
(
ctypes
.
c_byte
*
length
).
from_buffer
(
buf
,
offset
)
addr
=
ctypes
.
addressof
(
buf
)
assert
addr
%
align
==
0
return
buf
def
_run_benchmark
(
self
,
*
,
...
...
@@ -1737,45 +1754,20 @@ class _Benchmark_Runner:
result_array
.
fill
(
42
)
## values used to initialise vector registers
## align on one page, because we are never too cautious
ALIGNEMENT
=
benchmark
.
arch
.
max_vector_size
init_values
=
numpy
.
ndarray
(
shape
=
[
benchmark
.
arch
.
nb_vector_reg
*
ALIGNEMENT
-
1
,
benchmark
.
arch
.
max_vector_size
,
],
dtype
=
ctypes
.
c_byte
,
order
=
"
C
"
,
## align on max_vector_size * 2, we are never too cautious
ALIGNMENT
=
benchmark
.
arch
.
max_vector_size
init_values
=
self
.
aligned_alloc_byte_array
(
benchmark
.
arch
.
nb_vector_reg
*
benchmark
.
arch
.
max_vector_size
,
ALIGNMENT
,
rand_values
=
True
,
)
load_area
=
numpy
.
ndarray
(
shape
=
[
self
.
memory_size
(
benchmark
),
1
,
],
dtype
=
ctypes
.
c_byte
,
order
=
"
C
"
,
)
store_area
=
numpy
.
ndarray
(
shape
=
[
self
.
memory_size
(
benchmark
),
1
,
],
dtype
=
ctypes
.
c_byte
,
order
=
"
C
"
,
load_area
=
self
.
aligned_alloc_byte_array
(
self
.
memory_size
(
benchmark
),
ALIGNMENT
,
)
random
.
seed
(
42
)
for
i
in
range
(
benchmark
.
arch
.
nb_vector_reg
*
ALIGNEMENT
-
1
):
for
j
in
range
(
benchmark
.
arch
.
max_vector_size
):
init_values
[
i
,
j
]
=
random
.
getrandbits
(
8
)
data
=
init_values
.
ctypes
.
data_as
(
ctypes
.
POINTER
(
ctypes
.
c_byte
))
load_area_data
=
load_area
.
ctypes
.
data_as
(
ctypes
.
POINTER
(
ctypes
.
c_byte
))
store_area_data
=
store_area
.
ctypes
.
data_as
(
ctypes
.
POINTER
(
ctypes
.
c_byte
))
addr
=
ctypes
.
addressof
(
data
)
offset
=
0
if
addr
%
ALIGNEMENT
==
0
else
ALIGNEMENT
-
(
addr
%
ALIGNEMENT
)
aligned_init_values
=
ctypes
.
POINTER
(
ctypes
.
c_byte
).
from_address
(
addr
+
offset
store_area
=
self
.
aligned_alloc_byte_array
(
self
.
memory_size
(
benchmark
),
ALIGNMENT
,
)
time_before
=
time
.
perf_counter
()
...
...
@@ -1783,9 +1775,9 @@ class _Benchmark_Runner:
event_set_id
,
num_events
,
result_array
.
ctypes
.
data_as
(
ctypes
.
POINTER
(
ctypes
.
c_longlong
)),
aligned_
init_values
,
load_area
_data
,
store_area
_data
,
init_values
,
load_area
,
store_area
,
)
time_after
=
time
.
perf_counter
()
...
...
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