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
d8072b06
Commit
d8072b06
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Generated C Code only once
parent
1593e3f2
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
+7
-3
7 additions, 3 deletions
pystencils/cpu/cpujit.py
with
7 additions
and
3 deletions
pystencils/cpu/cpujit.py
+
7
−
3
View file @
d8072b06
...
...
@@ -494,12 +494,13 @@ def run_compile_step(command):
class
ExtensionModuleCode
:
def
__init__
(
self
,
module_name
=
'
generated
'
,
custom_backend
=
None
):
def
__init__
(
self
,
module_name
=
'
generated
'
,
custom_backend
=
None
,
generated_code
=
None
):
self
.
module_name
=
module_name
self
.
_ast_nodes
=
[]
self
.
_function_names
=
[]
self
.
_custom_backend
=
custom_backend
self
.
_generated_code
=
generated_code
def
add_function
(
self
,
ast
,
name
=
None
):
self
.
_ast_nodes
.
append
(
ast
)
...
...
@@ -523,7 +524,10 @@ class ExtensionModuleCode:
for
ast
,
name
in
zip
(
self
.
_ast_nodes
,
self
.
_function_names
):
old_name
=
ast
.
function_name
ast
.
function_name
=
"
kernel_
"
+
name
print
(
generate_c
(
ast
,
custom_backend
=
self
.
_custom_backend
),
file
=
file
)
if
self
.
_generated_code
:
print
(
self
.
_generated_code
,
file
=
file
)
else
:
print
(
generate_c
(
ast
,
custom_backend
=
self
.
_custom_backend
),
file
=
file
)
print
(
create_function_boilerplate_code
(
ast
.
get_parameters
(),
name
,
ast
),
file
=
file
)
ast
.
function_name
=
old_name
print
(
create_module_boilerplate_code
(
self
.
module_name
,
self
.
_function_names
),
file
=
file
)
...
...
@@ -590,7 +594,7 @@ def compile_and_load(ast, custom_backend=None):
# Also the information 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
)
code
=
ExtensionModuleCode
(
module_name
=
code_hash_str
,
custom_backend
=
custom_backend
,
generated_code
=
generated_code
)
code
.
add_function
(
ast
,
ast
.
function_name
)
if
cache_config
[
'
object_cache
'
]
is
False
:
...
...
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