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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Sebastian Bindgen
pystencils
Commits
ed8b7430
Commit
ed8b7430
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed print Function in CUDA Backend
parent
9ded23ce
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
pystencils/backends/cuda_backend.py
+13
-7
13 additions, 7 deletions
pystencils/backends/cuda_backend.py
with
14 additions
and
8 deletions
README.md
+
1
−
1
View file @
ed8b7430
...
...
@@ -52,7 +52,7 @@ pip install pystencils[interactive]
Without
`[interactive]`
you get a minimal version with very little dependencies.
All options:
-
`gpu`
: use this if an N
vidia
GPU is available and CUDA is installed
-
`gpu`
: use this if an N
VIDIA
GPU is available and CUDA is installed
-
`opencl`
: basic OpenCL support (experimental)
-
`alltrafos`
: pulls in additional dependencies for loop simplification e.g. libisl
-
`bench_db`
: functionality to store benchmark result in object databases
...
...
This diff is collapsed.
Click to expand it.
pystencils/backends/cuda_backend.py
+
13
−
7
View file @
ed8b7430
...
...
@@ -33,10 +33,11 @@ class CudaBackend(CBackend):
super
().
__init__
(
sympy_printer
,
signature_only
,
dialect
=
'
cuda
'
)
def
_print_SharedMemoryAllocation
(
self
,
node
):
code
=
"
__shared__ {dtype} {name}[{num_elements}];
"
return
code
.
format
(
dtype
=
node
.
symbol
.
dtype
,
name
=
self
.
sympy_printer
.
doprint
(
node
.
symbol
.
name
),
num_elements
=
'
*
'
.
join
([
str
(
s
)
for
s
in
node
.
shared_mem
.
shape
]))
dtype
=
node
.
symbol
.
dtype
name
=
self
.
sympy_printer
.
doprint
(
node
.
symbol
.
name
)
num_elements
=
'
*
'
.
join
([
str
(
s
)
for
s
in
node
.
shared_mem
.
shape
])
code
=
f
"
__shared__
{
dtype
}
{
name
}
[
{
num_elements
}
];
"
return
code
@staticmethod
def
_print_ThreadBlockSynchronization
(
node
):
...
...
@@ -45,6 +46,7 @@ class CudaBackend(CBackend):
def
_print_TextureDeclaration
(
self
,
node
):
# TODO: use fStrings here
if
node
.
texture
.
field
.
dtype
.
numpy_dtype
.
itemsize
>
4
:
code
=
"
texture<fp_tex_%s, cudaTextureType%iD, cudaReadModeElementType> %s;
"
%
(
str
(
node
.
texture
.
field
.
dtype
),
...
...
@@ -96,9 +98,13 @@ class CudaSympyPrinter(CustomSympyPrinter):
def
_print_Function
(
self
,
expr
):
if
isinstance
(
expr
,
fast_division
):
return
"
__fdividef(%s, %s)
"
%
tuple
(
self
.
_print
(
a
)
for
a
in
expr
.
args
)
assert
len
(
expr
.
args
)
==
2
,
f
"
__fdividef has two arguments, but
{
len
(
expr
.
args
)
}
where given
"
return
f
"
__fdividef(
{
self
.
_print
(
expr
.
args
[
0
])
}
,
{
self
.
_print
(
expr
.
args
[
1
])
}
)
"
elif
isinstance
(
expr
,
fast_sqrt
):
return
"
__fsqrt_rn(%s)
"
%
tuple
(
self
.
_print
(
a
)
for
a
in
expr
.
args
)
assert
len
(
expr
.
args
)
==
1
,
f
"
__fsqrt_rn has one argument, but
{
len
(
expr
.
args
)
}
where given
"
return
f
"
__fsqrt_rn(
{
self
.
_print
(
expr
.
args
[
0
])
}
)
"
elif
isinstance
(
expr
,
fast_inv_sqrt
):
return
"
__frsqrt_rn(%s)
"
%
tuple
(
self
.
_print
(
a
)
for
a
in
expr
.
args
)
print
(
len
(
expr
.
args
)
==
1
)
assert
len
(
expr
.
args
)
==
1
,
f
"
__frsqrt_rn has one argument, but
{
len
(
expr
.
args
)
}
where given
"
return
f
"
__frsqrt_rn(
{
self
.
_print
(
expr
.
args
[
0
])
}
)
"
return
super
().
_print_Function
(
expr
)
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