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
8dc0ea33
Commit
8dc0ea33
authored
9 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Support choosing target from the command line
parent
c4c1b6d3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/loopy
+18
-4
18 additions, 4 deletions
bin/loopy
loopy/__init__.py
+27
-0
27 additions, 0 deletions
loopy/__init__.py
loopy/kernel/creation.py
+3
-9
3 additions, 9 deletions
loopy/kernel/creation.py
with
48 additions
and
13 deletions
bin/loopy
+
18
−
4
View file @
8dc0ea33
...
...
@@ -63,7 +63,8 @@ def main():
parser
.
add_argument
(
"
outfile
"
,
default
=
"
-
"
,
metavar
=
"
OUTPUT_FILE
"
,
help
=
"
Defaults to stdout (
'
-
'
).
"
,
nargs
=
'
?
'
)
parser
.
add_argument
(
"
--lang
"
,
metavar
=
"
LANGUAGE
"
,
help
=
"
loopy|fortran
"
)
parser
.
add_argument
(
"
--target
"
)
parser
.
add_argument
(
"
--target
"
,
choices
=
(
"
opencl
"
,
"
ispc
"
,
"
c
"
,
"
cuda
"
),
default
=
"
opencl
"
)
parser
.
add_argument
(
"
--name
"
)
parser
.
add_argument
(
"
--transform
"
)
parser
.
add_argument
(
"
--edit-code
"
,
action
=
"
store_true
"
)
...
...
@@ -72,9 +73,22 @@ def main():
parser
.
add_argument
(
"
--print-ir
"
,
action
=
"
store_true
"
)
args
=
parser
.
parse_args
()
if
args
.
target
is
not
None
:
from
warnings
import
warn
warn
(
"
--target option is deprecated and ignored
"
)
if
args
.
target
==
"
opencl
"
:
from
loopy.target.opencl
import
OpenCLTarget
target
=
OpenCLTarget
()
elif
args
.
target
==
"
ispc
"
:
from
loopy.target.ispc
import
ISPCTarget
target
=
ISPCTarget
()
elif
args
.
target
==
"
c
"
:
from
loopy.target.c
import
CTarget
target
=
CTarget
()
elif
args
.
target
==
"
cuda
"
:
from
loopy.target.cuda
import
CudaTarget
target
=
CudaTarget
()
else
:
raise
ValueError
(
"
unknown target: %s
"
%
target
)
lp
.
set_default_target
(
target
)
lang
=
None
if
args
.
infile
==
"
-
"
:
...
...
This diff is collapsed.
Click to expand it.
loopy/__init__.py
+
27
−
0
View file @
8dc0ea33
...
...
@@ -354,4 +354,31 @@ def make_copy_kernel(new_dim_tags, old_dim_tags=None):
# }}}
# {{{ default target
_DEFAULT_TARGET
=
None
def
_set_up_default_target
():
try
:
import
pyopencl
# noqa
except
ImportError
:
from
loopy.target.opencl
import
OpenCLTarget
target
=
OpenCLTarget
()
else
:
from
loopy.target.pyopencl
import
PyOpenCLTarget
target
=
PyOpenCLTarget
()
set_default_target
(
target
)
def
set_default_target
(
target
):
# deliberately undocumented for now
global
_DEFAULT_TARGET
_DEFAULT_TARGET
=
target
# }}}
# vim: foldmethod=marker
This diff is collapsed.
Click to expand it.
loopy/kernel/creation.py
+
3
−
9
View file @
8dc0ea33
...
...
@@ -1071,7 +1071,7 @@ def make_kernel(domains, instructions, kernel_data=["..."], **kwargs):
:arg options: an instance of :class:`loopy.Options` or an equivalent
string representation
:arg target: an instance of :class:`loopy.target.TargetBase`, or *None*,
to use
an OpenCL
target
.
to use
the default target. (see :func:`loopy.set_default_
target
`)
"""
defines
=
kwargs
.
pop
(
"
defines
"
,
{})
...
...
@@ -1083,14 +1083,8 @@ def make_kernel(domains, instructions, kernel_data=["..."], **kwargs):
target
=
kwargs
.
pop
(
"
target
"
,
None
)
if
target
is
None
:
try
:
import
pyopencl
# noqa
except
ImportError
:
from
loopy.target.opencl
import
OpenCLTarget
target
=
OpenCLTarget
()
else
:
from
loopy.target.pyopencl
import
PyOpenCLTarget
target
=
PyOpenCLTarget
()
from
loopy
import
_DEFAULT_TARGET
target
=
_DEFAULT_TARGET
if
flags
is
not
None
:
if
options
is
not
None
:
...
...
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