Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyopencl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
pyopencl
Commits
2f5711a4
Commit
2f5711a4
authored
11 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Add cl.enable_debugging()
parent
4d3cf9be
No related branches found
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
pyopencl/__init__.py
+43
-10
43 additions, 10 deletions
pyopencl/__init__.py
with
43 additions
and
10 deletions
pyopencl/__init__.py
+
43
−
10
View file @
2f5711a4
...
@@ -61,8 +61,46 @@ def compiler_output(text):
...
@@ -61,8 +61,46 @@ def compiler_output(text):
"
to see more.
"
,
CompilerWarning
)
"
to see more.
"
,
CompilerWarning
)
# {{{ find pyopencl shipped source code
def
_find_pyopencl_include_path
():
from
pkg_resources
import
Requirement
,
resource_filename
return
resource_filename
(
Requirement
.
parse
(
"
pyopencl
"
),
"
pyopencl/cl
"
)
# }}}
# {{{ Program (including caching support)
# {{{ Program (including caching support)
_DEFAULT_BUILD_OPTIONS
=
[]
_DEFAULT_INCLUDE_OPTIONS
=
[
"
-I
"
,
_find_pyopencl_include_path
()]
# map of platform.name to build options list
_PLAT_BUILD_OPTIONS
=
{}
def
enable_debugging
(
platform_or_context
):
"""
Enables debugging for all code subsequently compiled by
PyOpenCL on the passed *platform*. Alternatively, a context
may be passed.
"""
if
isinstance
(
platform_or_context
,
Context
):
platform
=
platform_or_context
.
devices
[
0
].
platform
else
:
platform
=
platform_or_context
if
"
AMD Accelerated
"
in
platform
.
name
:
_PLAT_BUILD_OPTIONS
.
setdefault
(
platform
.
name
,
[]).
extend
(
[
"
-g
"
,
"
-O0
"
])
import
os
os
.
environ
[
"
CPU_MAX_COMPUTE_UNITS
"
]
=
"
1
"
else
:
from
warnings
import
warn
warn
(
"
do not know how to enable debugging on
'
%s
'"
%
platform
.
name
)
class
Program
(
object
):
class
Program
(
object
):
def
__init__
(
self
,
arg1
,
arg2
=
None
,
arg3
=
None
):
def
__init__
(
self
,
arg1
,
arg2
=
None
,
arg3
=
None
):
if
arg2
is
None
:
if
arg2
is
None
:
...
@@ -138,7 +176,11 @@ class Program(object):
...
@@ -138,7 +176,11 @@ class Program(object):
if
isinstance
(
options
,
str
):
if
isinstance
(
options
,
str
):
options
=
[
options
]
options
=
[
options
]
options
=
options
+
[
"
-I
"
,
_find_pyopencl_include_path
()]
options
=
(
options
+
_DEFAULT_BUILD_OPTIONS
+
_DEFAULT_INCLUDE_OPTIONS
+
_PLAT_BUILD_OPTIONS
.
get
(
self
.
_context
.
devices
[
0
].
platform
.
name
,
[]))
import
os
import
os
forced_options
=
os
.
environ
.
get
(
"
PYOPENCL_BUILD_OPTIONS
"
)
forced_options
=
os
.
environ
.
get
(
"
PYOPENCL_BUILD_OPTIONS
"
)
...
@@ -716,15 +758,6 @@ def _add_functionality():
...
@@ -716,15 +758,6 @@ def _add_functionality():
_add_functionality
()
_add_functionality
()
# {{{ find pyopencl shipped source code
def
_find_pyopencl_include_path
():
from
pkg_resources
import
Requirement
,
resource_filename
return
resource_filename
(
Requirement
.
parse
(
"
pyopencl
"
),
"
pyopencl/cl
"
)
# }}}
# {{{ convenience
# {{{ convenience
def
create_some_context
(
interactive
=
True
,
answers
=
None
):
def
create_some_context
(
interactive
=
True
,
answers
=
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