Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
fc7e815a
Commit
fc7e815a
authored
7 years ago
by
Michael Kuron
Browse files
Options
Downloads
Patches
Plain Diff
Remove llvmlite dependency for walberla codegen
parent
e2a168b4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data_types.py
+24
-15
24 additions, 15 deletions
data_types.py
with
24 additions
and
15 deletions
data_types.py
+
24
−
15
View file @
fc7e815a
import
ctypes
import
sympy
as
sp
import
numpy
as
np
import
llvmlite.ir
as
ir
try
:
import
llvmlite.ir
as
ir
except
ImportError
as
e
:
ir
=
None
_ir_importerror
=
e
from
sympy.core.cache
import
cacheit
from
pystencils.cache
import
memorycache
...
...
@@ -170,6 +174,8 @@ toCtypes.map = {
def
ctypes_from_llvm
(
data_type
):
if
not
ir
:
raise
_ir_importerror
if
isinstance
(
data_type
,
ir
.
PointerType
):
ctype
=
ctypes_from_llvm
(
data_type
.
pointee
)
if
ctype
is
None
:
...
...
@@ -203,25 +209,28 @@ def to_llvm_type(data_type):
:param data_type: Subclass of Type
:return: llvmlite type object
"""
if
not
ir
:
raise
_ir_importerror
if
isinstance
(
data_type
,
PointerType
):
return
to_llvm_type
(
data_type
.
baseType
).
as_pointer
()
else
:
return
to_llvm_type
.
map
[
data_type
.
numpyDtype
]
to_llvm_type
.
map
=
{
np
.
dtype
(
np
.
int8
):
ir
.
IntType
(
8
),
np
.
dtype
(
np
.
int16
):
ir
.
IntType
(
16
),
np
.
dtype
(
np
.
int32
):
ir
.
IntType
(
32
),
np
.
dtype
(
np
.
int64
):
ir
.
IntType
(
64
),
np
.
dtype
(
np
.
uint8
):
ir
.
IntType
(
8
),
np
.
dtype
(
np
.
uint16
):
ir
.
IntType
(
16
),
np
.
dtype
(
np
.
uint32
):
ir
.
IntType
(
32
),
np
.
dtype
(
np
.
uint64
):
ir
.
IntType
(
64
),
np
.
dtype
(
np
.
float32
):
ir
.
FloatType
(),
np
.
dtype
(
np
.
float64
):
ir
.
DoubleType
(),
}
if
ir
:
to_llvm_type
.
map
=
{
np
.
dtype
(
np
.
int8
):
ir
.
IntType
(
8
),
np
.
dtype
(
np
.
int16
):
ir
.
IntType
(
16
),
np
.
dtype
(
np
.
int32
):
ir
.
IntType
(
32
),
np
.
dtype
(
np
.
int64
):
ir
.
IntType
(
64
),
np
.
dtype
(
np
.
uint8
):
ir
.
IntType
(
8
),
np
.
dtype
(
np
.
uint16
):
ir
.
IntType
(
16
),
np
.
dtype
(
np
.
uint32
):
ir
.
IntType
(
32
),
np
.
dtype
(
np
.
uint64
):
ir
.
IntType
(
64
),
np
.
dtype
(
np
.
float32
):
ir
.
FloatType
(),
np
.
dtype
(
np
.
float64
):
ir
.
DoubleType
(),
}
def
peelOffType
(
dtype
,
typeToPeelOff
):
while
type
(
dtype
)
is
typeToPeelOff
:
...
...
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