Skip to content

Commit

Permalink
Merge pull request #90 from t20100/pr89
Browse files Browse the repository at this point in the history
enable SIMD on power9 for bitshuffle filter
  • Loading branch information
kif authored Oct 1, 2020
2 parents a4d8e22 + c16ab9c commit f50e6c6
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def get_cpu_sse2_avx2():
:returns: (is SSE2 available, is AVX2 available)
:rtype: List(bool)
"""
if platform.machine() == "ppc64le":
return True, False
try:
import cpuinfo
except ImportError as e:
Expand Down Expand Up @@ -168,6 +170,8 @@ def finalize_options(self):
if self.sse2:
if compiler.compiler_type == 'msvc':
self.sse2 = sys.version_info[0] >= 3
elif platform.machine() == 'ppc64le':
self.sse2 = True
else:
self.sse2 = check_compile_flag(compiler, '-msse2')
if not self.sse2:
Expand All @@ -176,6 +180,8 @@ def finalize_options(self):
if self.avx2:
if compiler.compiler_type == 'msvc':
self.avx2 = sys.version_info[:2] >= (3, 5)
elif platform.machine() == 'ppc64le':
self.avx2 = False
else:
self.avx2 = check_compile_flag(compiler, '-mavx2')
if not self.avx2:
Expand Down Expand Up @@ -251,7 +257,11 @@ def build_extensions(self):

# Enable SSE2/AVX2 if available and add corresponding resources
if build_cmd.sse2:
e.extra_compile_args += ['-msse2'] # /arch:SSE2 is on by default
if platform.machine() == 'ppc64le':
# Power9 way of enabling SSE2 support
e.extra_compile_args += ['-DNO_WARN_X86_INTRINSICS']
else:
e.extra_compile_args += ['-msse2'] # /arch:SSE2 is on by default
for name, value in e.sse2.items():
attribute = getattr(e, name)
attribute += value
Expand Down Expand Up @@ -345,6 +355,11 @@ def prefix(directory, files):
# Set compile args for both MSVC and others, list is stripped at build time
extra_compile_args = ['-O3', '-ffast-math', '-std=c99', '-fopenmp']
extra_compile_args += ['/Ox', '/fp:fast', '/openmp']
if platform.machine() == "ppc64le":
# Required on ppc64le
sse2_options = {'extra_compile_args': ['-DUSESSE2'] }
else:
sse2_options = {}
extra_link_args = ['-fopenmp', '/openmp']

bithsuffle_plugin = HDF5PluginExtension(
Expand All @@ -360,6 +375,7 @@ def prefix(directory, files):
include_dirs=prefix(bithsuffle_dir, ['src/', 'lz4/']),
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
sse2=sse2_options,
)


Expand All @@ -376,10 +392,14 @@ def prefix(directory, files):
include_dirs = [blosc_dir, blosc_dir + 'blosc']
define_macros = []

sse2_kwargs = {
'sources': [f for f in glob(blosc_dir + 'blosc/*.c') if 'sse2' in f],
'define_macros': [('SHUFFLE_SSE2_ENABLED', 1)],
}
if platform.machine() == 'ppc64le':
# SSE2 support in blosc uses x86 assembly code in shuffle
sse2_kwargs = {}
else:
sse2_kwargs = {
'sources': [f for f in glob(blosc_dir + 'blosc/*.c') if 'sse2' in f],
'define_macros': [('SHUFFLE_SSE2_ENABLED', 1)],
}

avx2_kwargs = {
'sources': [f for f in glob(blosc_dir + 'blosc/*.c') if 'avx2' in f],
Expand Down

0 comments on commit f50e6c6

Please sign in to comment.