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
d82f9064
Commit
d82f9064
authored
13 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Allow platform/device blacklisting during test.
parent
6ac83ea3
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
doc/source/tools.rst
+21
-0
21 additions, 0 deletions
doc/source/tools.rst
pyopencl/tools.py
+30
-0
30 additions, 0 deletions
pyopencl/tools.py
with
51 additions
and
0 deletions
doc/source/tools.rst
+
21
−
0
View file @
d82f9064
...
...
@@ -90,3 +90,24 @@ Kernel Caching
all held reference contexts. If it is important to you that the
program detaches from its context, you might need to call this
function to free all remaining references to your context.
Testing
-------
.. function:: pytest_generate_tests_for_pyopencl(metafunc)
Using the line::
from pyopencl.tools import pytest_generate_tests_for_pyopencl \
as pytest_generate_tests
in your `py.test <http://pytest.org>`_ test scripts allows you to use the
arguments *ctx_factory*, *device*, or *platform* in your test functions,
and they will automatically be run for each OpenCL device/platform in the
system, as appropriate.
The following two environment variables are also supported to control
device/platform choice::
PYOPENCL_TEST_PLATFORM_BLACKLIST=nvidia,intel
PYOPENCL_TEST_DEVICE_BLACKLIST=nvidia:260,intel:i5
This diff is collapsed.
Click to expand it.
pyopencl/tools.py
+
30
−
0
View file @
d82f9064
...
...
@@ -110,6 +110,21 @@ def pytest_generate_tests_for_pyopencl(metafunc):
def
__str__
(
self
):
return
"
<context factory for %s>
"
%
self
.
device
platform_blacklist
=
[]
device_blacklist
=
[]
import
os
bl_string
=
os
.
environ
.
get
(
"
PYOPENCL_TEST_PLATFORM_BLACKLIST
"
,
""
)
if
bl_string
:
platform_blacklist
=
[
s
.
lower
()
for
s
in
bl_string
.
split
(
"
,
"
)]
bl_string
=
os
.
environ
.
get
(
"
PYOPENCL_TEST_DEVICE_BLACKLIST
"
,
""
)
if
bl_string
:
for
s
in
bl_string
.
split
(
"
,
"
):
vendor_name
,
device_name
=
s
.
split
(
"
:
"
)
device_blacklist
.
append
((
vendor_name
.
lower
(),
device_name
.
lower
()))
from
pytools
import
any
if
(
"
device
"
in
metafunc
.
funcargnames
or
"
ctx_factory
"
in
metafunc
.
funcargnames
or
"
ctx_getter
"
in
metafunc
.
funcargnames
):
...
...
@@ -119,7 +134,17 @@ def pytest_generate_tests_for_pyopencl(metafunc):
if
"
platform
"
in
metafunc
.
funcargnames
:
arg_dict
[
"
platform
"
]
=
platform
platform_ish
=
(
platform
.
name
+
'
'
+
platform
.
vendor
).
lower
()
if
any
(
bl_plat
in
platform_ish
for
bl_plat
in
platform_blacklist
):
continue
for
device
in
platform
.
get_devices
():
device_ish
=
(
device
.
name
+
'
'
+
platform
.
vendor
).
lower
()
if
any
(
bl_plat
in
platform_ish
and
bl_dev
in
device_ish
for
bl_plat
,
bl_dev
in
device_blacklist
):
continue
if
"
device
"
in
metafunc
.
funcargnames
:
arg_dict
[
"
device
"
]
=
device
...
...
@@ -138,6 +163,11 @@ def pytest_generate_tests_for_pyopencl(metafunc):
elif
"
platform
"
in
metafunc
.
funcargnames
:
for
platform
in
cl
.
get_platforms
():
platform_ish
=
(
platform
.
name
+
'
'
+
platform
.
vendor
).
lower
()
if
any
(
bl_plat
in
platform_ish
for
bl_plat
in
platform_blacklist
):
continue
metafunc
.
addcall
(
funcargs
=
dict
(
platform
=
platform
),
id
=
str
(
platform
))
...
...
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