Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
loopy
Commits
75f08116
Commit
75f08116
authored
9 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Track pyopencl's complex-as-struct change
parent
0627aa0e
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
loopy/target/c/codegen/expression.py
+20
-11
20 additions, 11 deletions
loopy/target/c/codegen/expression.py
loopy/version.py
+1
-1
1 addition, 1 deletion
loopy/version.py
with
21 additions
and
12 deletions
loopy/target/c/codegen/expression.py
+
20
−
11
View file @
75f08116
...
@@ -376,14 +376,14 @@ class LoopyCCodeMapper(RecursiveMapper):
...
@@ -376,14 +376,14 @@ class LoopyCCodeMapper(RecursiveMapper):
cast_type
=
"
cfloat_t
"
cast_type
=
"
cfloat_t
"
else
:
else
:
if
dtype
==
np
.
complex128
:
if
dtype
==
np
.
complex128
:
cast_type
=
"
cdouble
_t
"
cast_type
=
"
cdouble
"
elif
dtype
==
np
.
complex64
:
elif
dtype
==
np
.
complex64
:
cast_type
=
"
cfloat
_t
"
cast_type
=
"
cfloat
"
else
:
else
:
raise
RuntimeError
(
"
unsupported complex type in expression
"
raise
RuntimeError
(
"
unsupported complex type in expression
"
"
generation: %s
"
%
type
(
expr
))
"
generation: %s
"
%
type
(
expr
))
return
"
(
%s
)
(%s, %s)
"
%
(
cast_type
,
repr
(
expr
.
real
),
repr
(
expr
.
imag
))
return
"
%s
_new
(%s, %s)
"
%
(
cast_type
,
repr
(
expr
.
real
),
repr
(
expr
.
imag
))
else
:
else
:
if
type_context
==
"
f
"
:
if
type_context
==
"
f
"
:
return
repr
(
float
(
expr
))
+
"
f
"
return
repr
(
float
(
expr
))
+
"
f
"
...
@@ -490,11 +490,20 @@ class LoopyCCodeMapper(RecursiveMapper):
...
@@ -490,11 +490,20 @@ class LoopyCCodeMapper(RecursiveMapper):
if
'
c
'
==
self
.
infer_type
(
child
).
kind
]
if
'
c
'
==
self
.
infer_type
(
child
).
kind
]
real_sum
=
self
.
join_rec
(
"
+
"
,
reals
,
PREC_SUM
,
type_context
)
real_sum
=
self
.
join_rec
(
"
+
"
,
reals
,
PREC_SUM
,
type_context
)
complex_sum
=
self
.
join_rec
(
"
+
"
,
complexes
,
PREC_SUM
,
type_context
,
tgt_dtype
)
if
len
(
complexes
)
==
1
:
myprec
=
PREC_SUM
else
:
myprec
=
PREC_NONE
complex_sum
=
self
.
rec
(
complexes
[
0
],
myprec
,
type_context
,
tgt_dtype
)
for
child
in
complexes
[
1
:]:
complex_sum
=
"
%s_add(%s, %s)
"
%
(
tgt_name
,
complex_sum
,
self
.
rec
(
child
,
PREC_NONE
,
type_context
,
tgt_dtype
))
if
real_sum
:
if
real_sum
:
result
=
"
%s_
fromreal(%s) +
%s
"
%
(
tgt_name
,
real_sum
,
complex_sum
)
result
=
"
%s_
radd(%s,
%s
)
"
%
(
tgt_name
,
real_sum
,
complex_sum
)
else
:
else
:
result
=
complex_sum
result
=
complex_sum
...
@@ -545,8 +554,7 @@ class LoopyCCodeMapper(RecursiveMapper):
...
@@ -545,8 +554,7 @@ class LoopyCCodeMapper(RecursiveMapper):
self
.
rec
(
child
,
PREC_NONE
,
type_context
,
tgt_dtype
))
self
.
rec
(
child
,
PREC_NONE
,
type_context
,
tgt_dtype
))
if
real_prd
:
if
real_prd
:
# elementwise semantics are correct
result
=
"
%s_rmul(%s, %s)
"
%
(
tgt_name
,
real_prd
,
complex_prd
)
result
=
"
%s*%s
"
%
(
real_prd
,
complex_prd
)
else
:
else
:
result
=
complex_prd
result
=
complex_prd
...
@@ -591,9 +599,10 @@ class LoopyCCodeMapper(RecursiveMapper):
...
@@ -591,9 +599,10 @@ class LoopyCCodeMapper(RecursiveMapper):
if
not
(
n_complex
or
d_complex
):
if
not
(
n_complex
or
d_complex
):
return
base_impl
(
expr
,
enclosing_prec
,
type_context
)
return
base_impl
(
expr
,
enclosing_prec
,
type_context
)
elif
n_complex
and
not
d_complex
:
elif
n_complex
and
not
d_complex
:
# elementwise semantics are correct
return
"
%s_divider(%s, %s)
"
%
(
return
base_impl
(
expr
,
enclosing_prec
,
type_context
,
self
.
complex_type_name
(
tgt_dtype
),
num_tgt_dtype
=
tgt_dtype
)
self
.
rec
(
expr
.
numerator
,
PREC_NONE
,
type_context
,
tgt_dtype
),
self
.
rec
(
expr
.
denominator
,
PREC_NONE
,
type_context
))
elif
not
n_complex
and
d_complex
:
elif
not
n_complex
and
d_complex
:
return
"
%s_rdivide(%s, %s)
"
%
(
return
"
%s_rdivide(%s, %s)
"
%
(
self
.
complex_type_name
(
tgt_dtype
),
self
.
complex_type_name
(
tgt_dtype
),
...
...
This diff is collapsed.
Click to expand it.
loopy/version.py
+
1
−
1
View file @
75f08116
...
@@ -25,4 +25,4 @@ VERSION = (2014, 1)
...
@@ -25,4 +25,4 @@ VERSION = (2014, 1)
VERSION_STATUS
=
""
VERSION_STATUS
=
""
VERSION_TEXT
=
"
.
"
.
join
(
str
(
x
)
for
x
in
VERSION
)
+
VERSION_STATUS
VERSION_TEXT
=
"
.
"
.
join
(
str
(
x
)
for
x
in
VERSION
)
+
VERSION_STATUS
DATA_MODEL_VERSION
=
"
v
6
"
DATA_MODEL_VERSION
=
"
v
7
"
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