Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Ben Sepanski
loopy
Commits
fb3a9f2c
Commit
fb3a9f2c
authored
9 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
ISPC stream harness seems to get ICC performance (fingers crossed :)
parent
fe922f94
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/python/ispc-harness.py
+35
-15
35 additions, 15 deletions
examples/python/ispc-harness.py
examples/python/run-ispc-harness.sh
+3
-0
3 additions, 0 deletions
examples/python/run-ispc-harness.sh
with
38 additions
and
15 deletions
examples/python/ispc-harness.py
+
35
−
15
View file @
fb3a9f2c
...
@@ -116,14 +116,16 @@ def main():
...
@@ -116,14 +116,16 @@ def main():
with
open
(
"
tasksys.cpp
"
,
"
r
"
)
as
ts_file
:
with
open
(
"
tasksys.cpp
"
,
"
r
"
)
as
ts_file
:
tasksys_source
=
ts_file
.
read
()
tasksys_source
=
ts_file
.
read
()
from
loopy.target.ispc
import
ISPCTarget
stream_knl
=
lp
.
make_kernel
(
"
{[i,j]: 0<=i<n and 0<=j<4}
"
,
"
z[i] = a*x[i] + y[i] {inames=i:j}
"
,
target
=
ISPCTarget
())
stream_dtype
=
np
.
float64
stream_dtype
=
np
.
float64
stream_ctype
=
ctypes
.
c_double
stream_ctype
=
ctypes
.
c_double
index_dtype
=
np
.
int32
from
loopy.target.ispc
import
ISPCTarget
stream_knl
=
lp
.
make_kernel
(
"
{[i,j]: 0<=i<n}
"
,
"
z[i] = a*x[i] + y[i] {inames=i}
"
,
target
=
ISPCTarget
(),
index_dtype
=
index_dtype
)
stream_knl
=
lp
.
add_and_infer_dtypes
(
stream_knl
,
{
stream_knl
=
lp
.
add_and_infer_dtypes
(
stream_knl
,
{
"
a
"
:
stream_dtype
,
"
a
"
:
stream_dtype
,
...
@@ -141,39 +143,57 @@ def main():
...
@@ -141,39 +143,57 @@ def main():
ispc_code
,
arg_info
=
lp
.
generate_code
(
stream_knl
)
ispc_code
,
arg_info
=
lp
.
generate_code
(
stream_knl
)
with
TemporaryDirectory
()
as
tmpdir
:
with
TemporaryDirectory
()
as
tmpdir
:
print
(
ispc_code
)
build_ispc_shared_lib
(
build_ispc_shared_lib
(
tmpdir
,
tmpdir
,
[(
"
stream.ispc
"
,
ispc_code
)],
[(
"
stream.ispc
"
,
ispc_code
)],
[(
"
tasksys.cpp
"
,
tasksys_source
)],
[(
"
tasksys.cpp
"
,
tasksys_source
)],
cxx_options
=
[
"
-g
"
,
"
-fopenmp
"
,
"
-DISPC_USE_OMP
"
],
cxx_options
=
[
"
-g
"
,
"
-fopenmp
"
,
"
-DISPC_USE_OMP
"
],
ispc_options
=
[
ispc_options
=
(
[
#
"-g", "--no-omit-frame-pointer",
"
-g
"
,
"
--no-omit-frame-pointer
"
,
"
--target=avx2-i32x8
"
,
"
--target=avx2-i32x8
"
,
"
--opt=force-aligned-memory
"
,
"
--opt=force-aligned-memory
"
,
],
]
+
[
"
--addressing=64
"
]
if
index_dtype
==
np
.
int64
else
[]
),
ispc_bin
=
"
/home/andreask/pack/ispc-v1.9.0-linux/ispc
"
,
ispc_bin
=
"
/home/andreask/pack/ispc-v1.9.0-linux/ispc
"
,
quiet
=
False
)
quiet
=
False
,
)
print
(
ispc_code
)
knl_lib
=
ctypes
.
cdll
.
LoadLibrary
(
os
.
path
.
join
(
tmpdir
,
"
shared.so
"
))
knl_lib
=
ctypes
.
cdll
.
LoadLibrary
(
os
.
path
.
join
(
tmpdir
,
"
shared.so
"
))
n
=
2
**
2
8
n
=
2
**
2
7
a
=
5
a
=
5
x
=
empty_aligned
(
n
,
dtype
=
stream_dtype
)
x
=
empty_aligned
(
n
,
dtype
=
stream_dtype
)
y
=
empty_aligned
(
n
,
dtype
=
stream_dtype
)
y
=
empty_aligned
(
n
,
dtype
=
stream_dtype
)
z
=
empty_aligned
(
n
,
dtype
=
stream_dtype
)
z
=
empty_aligned
(
n
,
dtype
=
stream_dtype
)
nruns
=
10
assert
address_from_numpy
(
x
)
%
64
==
0
assert
address_from_numpy
(
y
)
%
64
==
0
assert
address_from_numpy
(
z
)
%
64
==
0
nruns
=
20
start_time
=
time
()
start_time
=
time
()
for
irun
in
range
(
nruns
):
def
call_kernel
():
knl_lib
.
loopy_kernel
(
knl_lib
.
loopy_kernel
(
ctypes
.
c_int
(
n
),
stream_ctype
(
a
),
ctypes
.
c_int
(
n
),
stream_ctype
(
a
),
cptr_from_numpy
(
x
),
cptr_from_numpy
(
x
),
cptr_from_numpy
(
y
),
cptr_from_numpy
(
y
),
cptr_from_numpy
(
z
))
cptr_from_numpy
(
z
))
call_kernel
()
call_kernel
()
for
irun
in
range
(
nruns
):
call_kernel
()
elapsed
=
time
()
-
start_time
elapsed
=
time
()
-
start_time
print
(
1e-9
*
3
*
x
.
nbytes
*
nruns
/
elapsed
*
4
,
"
GB/s
"
)
print
(
elapsed
/
nruns
)
print
(
1e-9
*
3
*
x
.
nbytes
*
nruns
/
elapsed
,
"
GB/s
"
)
assert
la
.
norm
(
z
-
a
*
x
+
y
)
<
1e-10
assert
la
.
norm
(
z
-
a
*
x
+
y
)
<
1e-10
...
...
This diff is collapsed.
Click to expand it.
examples/python/run-ispc-harness.sh
0 → 100755
+
3
−
0
View file @
fb3a9f2c
#! /bin/sh
OMP_PLACES
=
cores
OMP_DISPLAY_ENV
=
true
OMP_SCHEDULE
=
static python ispc-harness.py
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