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
0c27034e
Commit
0c27034e
authored
13 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Allow better control over what devices tests get run on.
parent
66793498
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/source/tools.rst
+1
-2
1 addition, 2 deletions
doc/source/tools.rst
pyopencl/tools.py
+44
-30
44 additions, 30 deletions
pyopencl/tools.py
with
45 additions
and
32 deletions
doc/source/tools.rst
+
1
−
2
View file @
0c27034e
...
...
@@ -98,8 +98,7 @@ Testing
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
PYOPENCL_TEST=0:0,1;intel=i5,i7
Device Characterization
-----------------------
...
...
This diff is collapsed.
Click to expand it.
pyopencl/tools.py
+
44
−
30
View file @
0c27034e
...
...
@@ -126,41 +126,60 @@ 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
()))
dev_string
=
os
.
environ
.
get
(
"
PYOPENCL_TEST
"
,
None
)
def
find_cl_obj
(
objs
,
identifier
):
try
:
num
=
int
(
identifier
)
except
Exception
:
pass
else
:
return
objs
[
num
]
found
=
False
for
obj
in
objs
:
if
identifier
.
lower
()
in
(
obj
.
name
+
'
'
+
obj
.
vendor
).
lower
():
return
obj
if
not
found
:
raise
RuntimeError
(
"
object
'
%s
'
not found
"
%
identifier
)
if
dev_string
:
# PYOPENCL_TEST=0:0,1;intel:i5
test_plat_and_dev
=
[]
# list of tuples (platform, [device, device, ...])
for
entry
in
dev_string
.
split
(
"
;
"
):
lhsrhs
=
entry
.
split
(
"
:
"
)
from
pytools
import
any
if
len
(
lhsrhs
)
==
1
:
platform
=
find_cl_obj
(
cl
.
get_platforms
(),
lhsrhs
[
0
])
test_plat_and_dev
.
append
((
platform
,
platform
.
get_devices
()))
elif
len
(
lhsrhs
)
!=
2
:
raise
RuntimeError
(
"
invalid syntax of PYOPENCL_TEST
"
)
else
:
plat_str
,
dev_strs
=
lhsrhs
platform
=
find_cl_obj
(
cl
.
get_platforms
(),
plat_str
)
devs
=
platform
.
get_devices
()
test_plat_and_dev
.
append
(
(
platform
,
[
find_cl_obj
(
devs
,
dev_id
)
for
dev_id
in
dev_strs
.
split
(
"
,
"
)]))
else
:
test_plat_and_dev
=
[
(
platform
,
platform
.
get_devices
())
for
platform
in
cl
.
get_platforms
()]
if
(
"
device
"
in
metafunc
.
funcargnames
or
"
ctx_factory
"
in
metafunc
.
funcargnames
or
"
ctx_getter
"
in
metafunc
.
funcargnames
):
arg_dict
=
{}
for
platform
in
cl
.
get_platforms
()
:
for
platform
,
plat_devs
in
test_plat_and_dev
:
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
for
device
in
plat_devs
:
if
"
device
"
in
metafunc
.
funcargnames
:
arg_dict
[
"
device
"
]
=
device
...
...
@@ -178,12 +197,7 @@ def pytest_generate_tests_for_pyopencl(metafunc):
for
arg
,
value
in
arg_dict
.
iteritems
()))
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
for
platform
,
plat_devs
in
test_plat_and_dev
:
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