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
aa1ac13b
Commit
aa1ac13b
authored
11 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
PEP8 test_wrapper
parent
676ac0ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_wrapper.py
+10
-8
10 additions, 8 deletions
test/test_wrapper.py
with
10 additions
and
8 deletions
test/test_wrapper.py
+
10
−
8
View file @
aa1ac13b
...
@@ -454,26 +454,26 @@ def test_mempool(ctx_factory):
...
@@ -454,26 +454,26 @@ def test_mempool(ctx_factory):
context
=
ctx_factory
()
context
=
ctx_factory
()
pool
=
MemoryPool
(
CLAllocator
(
context
))
pool
=
MemoryPool
(
CLAllocator
(
context
))
maxlen
=
10
queue
=
[]
queue
=
[]
e0
=
12
e0
=
12
for
e
in
range
(
e0
-
6
,
e0
-
4
):
for
e
in
range
(
e0
-
6
,
e0
-
4
):
for
i
in
range
(
100
):
for
i
in
range
(
100
):
queue
.
append
(
pool
.
allocate
(
1
<<
e
))
queue
.
append
(
pool
.
allocate
(
1
<<
e
))
if
len
(
queue
)
>
10
:
if
len
(
queue
)
>
10
:
queue
.
pop
(
0
)
queue
.
pop
(
0
)
del
queue
del
queue
pool
.
stop_holding
()
pool
.
stop_holding
()
@pytools.test.mark_test.opencl
@pytools.test.mark_test.opencl
def
test_mempool_2
():
def
test_mempool_2
():
from
pyopencl.tools
import
MemoryPool
from
pyopencl.tools
import
MemoryPool
from
random
import
randrange
from
random
import
randrange
for
i
in
range
(
2000
):
for
i
in
range
(
2000
):
s
=
randrange
(
1
<<
31
)
>>
randrange
(
32
)
s
=
randrange
(
1
<<
31
)
>>
randrange
(
32
)
bin_nr
=
MemoryPool
.
bin_number
(
s
)
bin_nr
=
MemoryPool
.
bin_number
(
s
)
asize
=
MemoryPool
.
alloc_size
(
bin_nr
)
asize
=
MemoryPool
.
alloc_size
(
bin_nr
)
...
@@ -481,6 +481,7 @@ def test_mempool_2():
...
@@ -481,6 +481,7 @@ def test_mempool_2():
assert
MemoryPool
.
bin_number
(
asize
)
==
bin_nr
,
s
assert
MemoryPool
.
bin_number
(
asize
)
==
bin_nr
,
s
assert
asize
<
asize
*
(
1
+
1
/
8
)
assert
asize
<
asize
*
(
1
+
1
/
8
)
@pytools.test.mark_test.opencl
@pytools.test.mark_test.opencl
def
test_vector_args
(
ctx_factory
):
def
test_vector_args
(
ctx_factory
):
context
=
ctx_factory
()
context
=
ctx_factory
()
...
@@ -491,7 +492,7 @@ def test_vector_args(ctx_factory):
...
@@ -491,7 +492,7 @@ def test_vector_args(ctx_factory):
{ dest[get_global_id(0)] = x; }
{ dest[get_global_id(0)] = x; }
"""
).
build
()
"""
).
build
()
x
=
cl_array
.
vec
.
make_float4
(
1
,
2
,
3
,
4
)
x
=
cl_array
.
vec
.
make_float4
(
1
,
2
,
3
,
4
)
dest
=
np
.
empty
(
50000
,
cl_array
.
vec
.
float4
)
dest
=
np
.
empty
(
50000
,
cl_array
.
vec
.
float4
)
mf
=
cl
.
mem_flags
mf
=
cl
.
mem_flags
dest_buf
=
cl
.
Buffer
(
context
,
mf
.
READ_WRITE
|
mf
.
COPY_HOST_PTR
,
hostbuf
=
dest
)
dest_buf
=
cl
.
Buffer
(
context
,
mf
.
READ_WRITE
|
mf
.
COPY_HOST_PTR
,
hostbuf
=
dest
)
...
@@ -502,12 +503,13 @@ def test_vector_args(ctx_factory):
...
@@ -502,12 +503,13 @@ def test_vector_args(ctx_factory):
assert
(
dest
==
x
).
all
()
assert
(
dest
==
x
).
all
()
@pytools.test.mark_test.opencl
@pytools.test.mark_test.opencl
def
test_header_dep_handling
(
ctx_factory
):
def
test_header_dep_handling
(
ctx_factory
):
context
=
ctx_factory
()
context
=
ctx_factory
()
from
os.path
import
exists
from
os.path
import
exists
assert
exists
(
"
empty-header.h
"
)
# if this fails, change dir to pyopencl/test
assert
exists
(
"
empty-header.h
"
)
# if this fails, change dir to pyopencl/test
kernel_src
=
"""
kernel_src
=
"""
#include <empty-header.h>
#include <empty-header.h>
...
@@ -522,6 +524,7 @@ def test_header_dep_handling(ctx_factory):
...
@@ -522,6 +524,7 @@ def test_header_dep_handling(ctx_factory):
cl
.
Program
(
context
,
kernel_src
).
build
([
"
-I
"
,
os
.
getcwd
()])
cl
.
Program
(
context
,
kernel_src
).
build
([
"
-I
"
,
os
.
getcwd
()])
cl
.
Program
(
context
,
kernel_src
).
build
([
"
-I
"
,
os
.
getcwd
()])
cl
.
Program
(
context
,
kernel_src
).
build
([
"
-I
"
,
os
.
getcwd
()])
@pytools.test.mark_test.opencl
@pytools.test.mark_test.opencl
def
test_context_dep_memoize
(
ctx_factory
):
def
test_context_dep_memoize
(
ctx_factory
):
context
=
ctx_factory
()
context
=
ctx_factory
()
...
@@ -539,6 +542,7 @@ def test_context_dep_memoize(ctx_factory):
...
@@ -539,6 +542,7 @@ def test_context_dep_memoize(ctx_factory):
assert
counter
[
0
]
==
1
assert
counter
[
0
]
==
1
@pytools.test.mark_test.opencl
@pytools.test.mark_test.opencl
def
test_can_build_binary
(
ctx_factory
):
def
test_can_build_binary
(
ctx_factory
):
ctx
=
ctx_factory
()
ctx
=
ctx_factory
()
...
@@ -556,11 +560,9 @@ def test_can_build_binary(ctx_factory):
...
@@ -556,11 +560,9 @@ def test_can_build_binary(ctx_factory):
foo
.
build
()
foo
.
build
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
# make sure that import failures get reported, instead of skipping the tests.
# make sure that import failures get reported, instead of skipping the tests.
import
pyopencl
import
pyopencl
# noqa
import
sys
import
sys
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
...
...
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