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
25e62569
Commit
25e62569
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Test for alignmet
parent
5db18203
No related branches found
No related tags found
1 merge request
!226
Fix field size
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/cpu/cpujit.py
+8
-4
8 additions, 4 deletions
pystencils/cpu/cpujit.py
with
8 additions
and
4 deletions
pystencils/cpu/cpujit.py
+
8
−
4
View file @
25e62569
...
...
@@ -59,6 +59,7 @@ from appdirs import user_cache_dir, user_config_dir
from
pystencils
import
FieldType
from
pystencils.backends.cbackend
import
generate_c
,
get_headers
from
pystencils.data_types
import
cast_func
,
VectorType
from
pystencils.include
import
get_pystencils_include_path
from
pystencils.kernel_wrapper
import
KernelWrapper
from
pystencils.utils
import
atomic_file_write
,
file_handle_for_atomic_write
,
recursive_dict_update
...
...
@@ -374,14 +375,17 @@ def create_function_boilerplate_code(parameter_info, name, ast_node, insert_chec
np_dtype
=
field
.
dtype
.
numpy_dtype
item_size
=
np_dtype
.
itemsize
if
ast_node
.
instruction_set
:
aligned
=
any
([
a
.
lhs
.
args
[
2
]
for
a
in
ast_node
.
assignments
if
isinstance
(
a
.
lhs
,
cast_func
)
and
isinstance
(
a
.
lhs
.
dtype
,
VectorType
)])
if
ast_node
.
instruction_set
and
aligned
:
byte_width
=
ast_node
.
instruction_set
[
'
width
'
]
*
item_size
offset
=
max
(
max
(
ast_node
.
ghost_layers
))
*
item_size
offset_cond
=
f
"
(((uintptr_t) buffer_
{
field
.
name
}
.buf) +
{
offset
}
) %
{
byte_width
}
== 0
"
message
=
str
(
offset
)
+
"
. This is probably due to a different number of ghost_layers chosen for
"
\
"
the arrays and the kernel creation. If the number of ghost layers for
the
"
\
"
kernel creation is not specified it will choose a suitable value
"
\
"
the arrays and the kernel creation. If the number of ghost layers for
"
\
"
the
kernel creation is not specified it will choose a suitable value
"
\
"
automatically. This value might not
"
\
"
be compatible with the allocated arrays.
"
pre_call_code
+=
template_check_array
.
format
(
cond
=
offset_cond
,
what
=
"
offset
"
,
name
=
field
.
name
,
...
...
@@ -580,7 +584,7 @@ def compile_and_load(ast, custom_backend=None):
generated_code
=
generate_c
(
ast
,
dialect
=
'
c
'
,
custom_backend
=
custom_backend
)
fields_accessed
=
str
(
ast
.
fields_accessed
)
# Also
di
e
I
nformation of the field size should be contained in the hash string. Due to padding the generated code
# Also
th
e
i
nformation of the field size should be contained in the hash string. Due to padding the generated code
# can look similar for different field sizes.
code_hash_str
=
"
mod_
"
+
hashlib
.
sha256
((
generated_code
+
fields_accessed
).
encode
()).
hexdigest
()
code
=
ExtensionModuleCode
(
module_name
=
code_hash_str
,
custom_backend
=
custom_backend
)
...
...
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