Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Holzer
pystencils
Commits
1f9d65ed
Commit
1f9d65ed
authored
Feb 19, 2021
by
Markus Holzer
Browse files
Merge branch 'cxx17' into 'master'
fix aligned_alloc on windows See merge request
pycodegen/pystencils!215
parents
5f1e4f9f
0b72ca08
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
1f9d65ed
...
...
@@ -282,7 +282,15 @@ class CBackend:
np_dtype
=
node
.
symbol
.
dtype
.
base_type
.
numpy_dtype
required_size
=
np_dtype
.
itemsize
*
node
.
size
+
align
size
=
modulo_ceil
(
required_size
,
align
)
code
=
"{dtype} {name}=({dtype})aligned_alloc({align}, {size}) + {offset};"
code
=
"#if __cplusplus >= 201703L || __STDC_VERSION__ >= 201112L
\n
"
code
+=
"{dtype} {name}=({dtype})aligned_alloc({align}, {size}) + {offset};
\n
"
code
+=
"#elif defined(_MSC_VER)
\n
"
code
+=
"{dtype} {name}=({dtype})_aligned_malloc({size}, {align}) + {offset};
\n
"
code
+=
"#else
\n
"
code
+=
"{dtype} {name};
\n
"
code
+=
"posix_memalign((void**) &{name}, {align}, {size});
\n
"
code
+=
"{name} += {offset};
\n
"
code
+=
"#endif"
return
code
.
format
(
dtype
=
node
.
symbol
.
dtype
,
name
=
self
.
sympy_printer
.
doprint
(
node
.
symbol
.
name
),
size
=
self
.
sympy_printer
.
doprint
(
size
),
...
...
@@ -291,7 +299,12 @@ class CBackend:
def
_print_TemporaryMemoryFree
(
self
,
node
):
align
=
64
return
"free(%s - %d);"
%
(
self
.
sympy_printer
.
doprint
(
node
.
symbol
.
name
),
node
.
offset
(
align
))
code
=
"#if defined(_MSC_VER)
\n
"
code
+=
"_aligned_free(%s - %d);
\n
"
%
(
self
.
sympy_printer
.
doprint
(
node
.
symbol
.
name
),
node
.
offset
(
align
))
code
+=
"#else
\n
"
code
+=
"free(%s - %d);
\n
"
%
(
self
.
sympy_printer
.
doprint
(
node
.
symbol
.
name
),
node
.
offset
(
align
))
code
+=
"#endif"
return
code
def
_print_SkipIteration
(
self
,
_
):
return
"continue;"
...
...
pystencils/cpu/cpujit.py
View file @
1f9d65ed
...
...
@@ -160,7 +160,7 @@ def read_config():
(
'msvc_version'
,
'latest'
),
(
'llc_command'
,
get_llc_command
()
or
'llc'
),
(
'arch'
,
'x64'
),
(
'flags'
,
'/Ox /fp:fast /OpenMP /arch:avx
/std:c++17
'
),
(
'flags'
,
'/Ox /fp:fast /OpenMP /arch:avx'
),
(
'restrict_qualifier'
,
'__restrict'
)
])
elif
platform
.
system
().
lower
()
==
'darwin'
:
...
...
@@ -168,7 +168,7 @@ def read_config():
(
'os'
,
'darwin'
),
(
'command'
,
'clang++'
),
(
'llc_command'
,
get_llc_command
()
or
'llc'
),
(
'flags'
,
'-Ofast -DNDEBUG -fPIC -march=native -Xclang -fopenmp -std=c++1
7
'
),
(
'flags'
,
'-Ofast -DNDEBUG -fPIC -march=native -Xclang -fopenmp -std=c++1
1
'
),
(
'restrict_qualifier'
,
'__restrict__'
)
])
default_cache_config
=
OrderedDict
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment