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
89662377
Commit
89662377
authored
10 years ago
by
Yichao Yu
Browse files
Options
Downloads
Patches
Plain Diff
use similar structure with master
parent
44b178a2
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
pyopencl/__init__.py
+5
-22
5 additions, 22 deletions
pyopencl/__init__.py
pyopencl/_pvt_struct.py
+50
-0
50 additions, 0 deletions
pyopencl/_pvt_struct.py
with
55 additions
and
22 deletions
pyopencl/__init__.py
+
5
−
22
View file @
89662377
...
...
@@ -514,17 +514,6 @@ def _add_functionality():
self
.
_arg_type_chars
=
arg_type_chars
_size_t_char
=
({
8
:
'
Q
'
,
4
:
'
L
'
,
2
:
'
H
'
,
1
:
'
B
'
,
})[
_cl
.
_ffi
.
sizeof
(
'
size_t
'
)]
_type_char_map
=
{
'
n
'
:
_size_t_char
.
lower
(),
'
N
'
:
_size_t_char
}
del
_size_t_char
def
kernel_set_args
(
self
,
*
args
):
assert
len
(
args
)
==
self
.
num_args
,
(
"
length of argument list (%d) and
"
...
...
@@ -539,20 +528,14 @@ def _add_functionality():
for
i
,
arg
in
enumerate
(
args
):
self
.
set_arg
(
i
,
arg
)
else
:
#
from pyopencl._pvt_struct import pack
from
struct
import
pack
from
pyopencl._pvt_struct
import
pack
for
i
,
(
arg
,
arg_type_char
)
in
enumerate
(
zip
(
args
,
arg_type_chars
)):
if
not
arg_type_char
or
arg_type_char
==
"
V
"
:
_arg
=
arg
elif
arg_type_char
==
"
F
"
:
_arg
=
pack
(
'
f
'
,
arg
.
real
)
+
pack
(
'
f
'
,
arg
.
imag
)
elif
arg_type_char
==
"
D
"
:
_arg
=
pack
(
'
d
'
,
arg
.
real
)
+
pack
(
'
d
'
,
arg
.
imag
)
if
arg_type_char
and
arg_type_char
!=
"
V
"
:
self
.
set_arg
(
i
,
pack
(
arg_type_char
,
arg
))
else
:
_arg
=
pack
(
_type_char_map
.
get
(
arg_type_char
,
arg_type_char
),
arg
)
self
.
set_arg
(
i
,
_arg
)
self
.
set_arg
(
i
,
arg
)
except
LogicError
,
e
:
if
i
is
not
None
:
advice
=
""
...
...
This diff is collapsed.
Click to expand it.
pyopencl/_pvt_struct.py
0 → 100644
+
50
−
0
View file @
89662377
from
__future__
import
division
__copyright__
=
"""
Copyright (C) 2013 Marko Bencun
Copyright (C) 2014 Andreas Kloeckner
Copyright (C) 2014 Yichao Yu
"""
__license__
=
"""
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the
"
Software
"
), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED
"
AS IS
"
, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
#import pyopencl._cl as _cl
import
pyopencl.cffi_cl
as
_cl
from
struct
import
pack
as
_pack
_size_t_char
=
({
8
:
'
Q
'
,
4
:
'
L
'
,
2
:
'
H
'
,
1
:
'
B
'
,
})[
_cl
.
_ffi
.
sizeof
(
'
size_t
'
)]
_type_char_map
=
{
'
n
'
:
_size_t_char
.
lower
(),
'
N
'
:
_size_t_char
}
del
_size_t_char
def
pack
(
type_char
,
obj
):
if
type_char
==
'
F
'
:
return
_pack
(
'
f
'
,
obj
.
real
)
+
_pack
(
'
f
'
,
obj
.
imag
)
elif
type_char
==
"
D
"
:
return
_pack
(
'
d
'
,
obj
.
real
)
+
_pack
(
'
d
'
,
obj
.
imag
)
else
:
return
_pack
(
_type_char_map
.
get
(
type_char
,
type_char
),
obj
)
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