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
2e6f3efe
Commit
2e6f3efe
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
llvm: Use addressspace 1 (global memory) for nvvm_target
parent
a526fe47
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!53
Compile CUDA using the LLVM backend
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pystencils/data_types.py
+2
-2
2 additions, 2 deletions
pystencils/data_types.py
pystencils/llvm/llvm.py
+4
-4
4 additions, 4 deletions
pystencils/llvm/llvm.py
pystencils/llvm/llvmjit.py
+1
-1
1 addition, 1 deletion
pystencils/llvm/llvmjit.py
with
7 additions
and
7 deletions
pystencils/data_types.py
+
2
−
2
View file @
2e6f3efe
...
@@ -300,7 +300,7 @@ def ctypes_from_llvm(data_type):
...
@@ -300,7 +300,7 @@ def ctypes_from_llvm(data_type):
raise
NotImplementedError
(
'
Data type %s of %s is not supported yet
'
%
(
type
(
data_type
),
data_type
))
raise
NotImplementedError
(
'
Data type %s of %s is not supported yet
'
%
(
type
(
data_type
),
data_type
))
def
to_llvm_type
(
data_type
):
def
to_llvm_type
(
data_type
,
nvvm_target
=
False
):
"""
"""
Transforms a given type into ctypes
Transforms a given type into ctypes
:param data_type: Subclass of Type
:param data_type: Subclass of Type
...
@@ -309,7 +309,7 @@ def to_llvm_type(data_type):
...
@@ -309,7 +309,7 @@ def to_llvm_type(data_type):
if
not
ir
:
if
not
ir
:
raise
_ir_importerror
raise
_ir_importerror
if
isinstance
(
data_type
,
PointerType
):
if
isinstance
(
data_type
,
PointerType
):
return
to_llvm_type
(
data_type
.
base_type
).
as_pointer
()
return
to_llvm_type
(
data_type
.
base_type
).
as_pointer
(
1
if
nvvm_target
else
0
)
else
:
else
:
return
to_llvm_type
.
map
[
data_type
.
numpy_dtype
]
return
to_llvm_type
.
map
[
data_type
.
numpy_dtype
]
...
...
This diff is collapsed.
Click to expand it.
pystencils/llvm/llvm.py
+
4
−
4
View file @
2e6f3efe
...
@@ -21,13 +21,13 @@ def _call_sreg(builder, name):
...
@@ -21,13 +21,13 @@ def _call_sreg(builder, name):
return
builder
.
call
(
fn
,
())
return
builder
.
call
(
fn
,
())
def
generate_llvm
(
ast_node
,
module
=
None
,
builder
=
None
):
def
generate_llvm
(
ast_node
,
module
=
None
,
builder
=
None
,
target
=
'
cpu
'
):
"""
Prints the ast as llvm code.
"""
"""
Prints the ast as llvm code.
"""
if
module
is
None
:
if
module
is
None
:
module
=
lc
.
Module
()
module
=
lc
.
Module
()
if
builder
is
None
:
if
builder
is
None
:
builder
=
ir
.
IRBuilder
()
builder
=
ir
.
IRBuilder
()
printer
=
LLVMPrinter
(
module
,
builder
)
printer
=
LLVMPrinter
(
module
,
builder
,
target
=
target
)
return
printer
.
_print
(
ast_node
)
return
printer
.
_print
(
ast_node
)
...
@@ -173,7 +173,7 @@ class LLVMPrinter(Printer):
...
@@ -173,7 +173,7 @@ class LLVMPrinter(Printer):
parameter_type
=
[]
parameter_type
=
[]
parameters
=
func
.
get_parameters
()
parameters
=
func
.
get_parameters
()
for
parameter
in
parameters
:
for
parameter
in
parameters
:
parameter_type
.
append
(
to_llvm_type
(
parameter
.
symbol
.
dtype
))
parameter_type
.
append
(
to_llvm_type
(
parameter
.
symbol
.
dtype
,
nvvm_target
=
self
.
target
==
'
gpu
'
))
func_type
=
ir
.
FunctionType
(
return_type
,
tuple
(
parameter_type
))
func_type
=
ir
.
FunctionType
(
return_type
,
tuple
(
parameter_type
))
name
=
func
.
function_name
name
=
func
.
function_name
fn
=
ir
.
Function
(
self
.
module
,
func_type
,
name
)
fn
=
ir
.
Function
(
self
.
module
,
func_type
,
name
)
...
@@ -307,7 +307,7 @@ class LLVMPrinter(Printer):
...
@@ -307,7 +307,7 @@ class LLVMPrinter(Printer):
self
.
builder
.
branch
(
after_block
)
self
.
builder
.
branch
(
after_block
)
self
.
builder
.
position_at_end
(
false_block
)
self
.
builder
.
position_at_end
(
false_block
)
phi
=
self
.
builder
.
phi
(
to_llvm_type
(
get_type_of_expression
(
piece
)))
phi
=
self
.
builder
.
phi
(
to_llvm_type
(
get_type_of_expression
(
piece
)
,
nvvm_target
=
self
.
target
==
'
gpu
'
))
for
(
val
,
block
)
in
phi_data
:
for
(
val
,
block
)
in
phi_data
:
phi
.
add_incoming
(
val
,
block
)
phi
.
add_incoming
(
val
,
block
)
return
phi
return
phi
...
...
This diff is collapsed.
Click to expand it.
pystencils/llvm/llvmjit.py
+
1
−
1
View file @
2e6f3efe
...
@@ -101,7 +101,7 @@ def make_python_function_incomplete_params(kernel_function_node, argument_dict,
...
@@ -101,7 +101,7 @@ def make_python_function_incomplete_params(kernel_function_node, argument_dict,
def
generate_and_jit
(
ast
):
def
generate_and_jit
(
ast
):
target
=
'
gpu
'
if
ast
.
_backend
==
'
llvm_gpu
'
else
'
cpu
'
target
=
'
gpu
'
if
ast
.
_backend
==
'
llvm_gpu
'
else
'
cpu
'
gen
=
generate_llvm
(
ast
)
gen
=
generate_llvm
(
ast
,
target
=
target
)
if
isinstance
(
gen
,
ir
.
Module
):
if
isinstance
(
gen
,
ir
.
Module
):
return
compile_llvm
(
gen
,
target
)
return
compile_llvm
(
gen
,
target
)
else
:
else
:
...
...
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