Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add platform-specific flags for NEON. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
sources = [
'pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.cpp',
'pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD_internal.cpp',
'pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD_neon.cpp',
'pyfastnoisesimd/wrapper.cpp'
]
inc_dirs = [get_include(), 'pyfastnoisesimd', 'pyfastnoisesimd/fastnoisesimd/']
Expand Down Expand Up @@ -73,6 +72,14 @@
'/arch:AVX2',
]
}
neon = {
'sources': [
'pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD_neon.cpp',
],
'cflags': [
'/Oi',
],
}

if platform.machine() == 'AMD64': # 64-bit windows
#`/arch:SSE2` doesn't exist on Windows x64 builds, and generates a needless warnings
Expand Down Expand Up @@ -146,13 +153,27 @@
'-msse2',
],
}
neon = {
'sources': [
'pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD_neon.cpp',
],
'cflags': [
'-std=c++11',
'-mfpu=neon',
],
}
if platform.machine() == 'aarch64':
# Flag is not supported, but NEON is always available.
neon['cflags'].remove('-mfpu=neon')

fma_flags = ['-mfma']

clibs = [
('avx512', avx512),
('avx2', avx2),
('sse41', sse41),
('sse2', sse2),
('neon', neon),
]


Expand All @@ -162,6 +183,7 @@ class build(_build):
('with-avx2=', None, 'Use AVX2 instructions: auto|yes|no'),
('with-sse41=', None, 'Use SSE4.1 instructions: auto|yes|no'),
('with-sse2=', None, 'Use SSE2 instructions: auto|yes|no'),
('with-neon=', None, 'Use NEON instructions: auto|yes|no'),
('with-fma=', None, 'Use FMA instructions: auto|yes|no'),
]

Expand All @@ -171,6 +193,7 @@ def initialize_options(self):
self.with_avx2 = 'auto'
self.with_sse41 = 'auto'
self.with_sse2 = 'auto'
self.with_neon = 'auto'
self.with_fma = 'auto'

def finalize_options(self):
Expand Down Expand Up @@ -207,6 +230,8 @@ def finalize_options(self):
disabled_libraries.append('avx512')
if msc_version < 1900:
disabled_libraries.append('avx2')
if not platform.machine().startswith('arm'):
disabled_libraries.append('neon')
# End of SIMD limits

for name, lib in self.distribution.libraries:
Expand Down