Skip to content

Commit

Permalink
Add platform-specific flags for NEON.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Jul 21, 2018
1 parent 4ce56d5 commit 563742c
Showing 1 changed file with 26 additions and 1 deletion.
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

0 comments on commit 563742c

Please sign in to comment.