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
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
Andreas Klöckner
loopy
Commits
15db4bae
Commit
15db4bae
authored
4 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Add matmul driver example for floopy
parent
d3cf3941
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#21941
passed
4 years ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/fortran/matmul-driver.py
+35
-0
35 additions, 0 deletions
examples/fortran/matmul-driver.py
with
35 additions
and
0 deletions
examples/fortran/matmul-driver.py
0 → 100644
+
35
−
0
View file @
15db4bae
import
numpy
as
np
import
numpy.linalg
as
la
import
pyopencl
as
cl
import
pyopencl.array
import
pyopencl.clrandom
import
loopy
as
lp
def
main
():
fn
=
"
matmul.floopy
"
with
open
(
fn
,
"
r
"
)
as
inf
:
source
=
inf
.
read
()
dgemm
,
=
lp
.
parse_transformed_fortran
(
source
,
filename
=
fn
)
ctx
=
cl
.
create_some_context
()
queue
=
cl
.
CommandQueue
(
ctx
)
n
=
2048
a
=
cl
.
array
.
empty
(
queue
,
(
n
,
n
),
dtype
=
np
.
float64
,
order
=
"
F
"
)
b
=
cl
.
array
.
empty
(
queue
,
(
n
,
n
),
dtype
=
np
.
float64
,
order
=
"
F
"
)
c
=
cl
.
array
.
zeros
(
queue
,
(
n
,
n
),
dtype
=
np
.
float64
,
order
=
"
F
"
)
cl
.
clrandom
.
fill_rand
(
a
)
cl
.
clrandom
.
fill_rand
(
b
)
dgemm
=
lp
.
set_options
(
dgemm
,
write_code
=
True
)
dgemm
(
queue
,
a
=
a
,
b
=
b
,
alpha
=
1
,
c
=
c
)
c_ref
=
(
a
.
get
()
@
b
.
get
())
assert
la
.
norm
(
c_ref
-
c
.
get
())
/
la
.
norm
(
c_ref
)
<
1e-10
if
__name__
==
"
__main__
"
:
main
()
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