Skip to content

Commit

Permalink
ENH: add SIMD everywhere for non-x86 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Nov 21, 2020
1 parent 2b3fada commit e7e9fbf
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "simde"]
path = simde
url = https://github.com/nemequ/simde-no-tests
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,8 @@

* Update hdmedians package to a version which doesn't require an initial manual numpy install.

* Now buildable on non-x86 platforms due to use of the [SIMD Everywhere](https://github.com/nemequ/simde) library.

## Version 0.5.6

### Features
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Expand Up @@ -10,6 +10,7 @@ include RELEASE.md
include REVIEWING.md
include checklist.py
include asv.conf.json
recursive-include simde *.h COPYING *.md

graft assets
graft ci
Expand All @@ -26,3 +27,5 @@ global-exclude *.pyo
global-exclude *.so
global-exclude .*.swp
global-exclude .coverage

exclude .gitmodules
36 changes: 33 additions & 3 deletions setup.py
Expand Up @@ -13,6 +13,8 @@
import re
import ast
import sys
import sysconfig
import subprocess

from setuptools import find_packages, setup
from setuptools.extension import Extension
Expand All @@ -24,6 +26,29 @@
sys.exit("scikit-bio can only be used with Python 3. You are currently "
"running Python %d." % sys.version_info.major)

clang = False
icc = False
try:
if os.environ['CC'] == "clang":
clang = True
except KeyError:
pass

if not clang:
try:
if subprocess.check_output(
["gcc", "--version"], text=True).find("clang") != -1:
clang = True
except subprocess.CalledProcessError:
pass


try:
if os.environ['CC'] == "icc":
icc = True
except KeyError:
pass

# version parsing from __init__ pulled from Flask's setup.py
# https://github.com/mitsuhiko/flask/blob/master/setup.py
_version_re = re.compile(r'__version__\s+=\s+(.*)')
Expand Down Expand Up @@ -65,9 +90,14 @@
# the compilation of the interpreter. See http://bugs.python.org/issue21121 for
# details. This acts as a workaround until the next Python 3 release -- thanks
# Wolfgang Maier (wolma) for the workaround!
ssw_extra_compile_args = ['-Wno-error=declaration-after-statement']
if sys.platform == 'win32':
ssw_extra_compile_args = []
ssw_extra_compile_args = ['-I.']
if sys.platform != 'win32':
ssw_extra_compile_args.append('-Wno-error=declaration-after-statement')

if icc or sysconfig.get_config_vars()['CC'] == 'icc':
ssw_extra_compile_args.extend(['-qopenmp-simd', '-DSIMDE_ENABLE_OPENMP'])
elif not (clang or sysconfig.get_config_vars()['CC'] == 'clang'):
ssw_extra_compile_args.extend(['-fopenmp-simd', '-DSIMDE_ENABLE_OPENMP'])

# Users with i686 architectures have reported that adding this flag allows
# SSW to be compiled. See https://github.com/biocore/scikit-bio/issues/409 and
Expand Down
1 change: 1 addition & 0 deletions simde
Submodule simde added at d6c751
3 changes: 2 additions & 1 deletion skbio/alignment/_lib/ssw.c
Expand Up @@ -35,7 +35,8 @@
*
*/

#include <emmintrin.h>
#define SIMDE_ENABLE_NATIVE_ALIASES
#include "simde/x86/sse2.h"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
5 changes: 3 additions & 2 deletions skbio/alignment/_lib/ssw.h
Expand Up @@ -14,7 +14,8 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <emmintrin.h>
#define SIMDE_ENABLE_NATIVE_ALIASES
#include "simde/x86/sse2.h"

/*! @typedef structure of the query profile */
struct _profile;
Expand Down Expand Up @@ -127,4 +128,4 @@ void align_destroy (s_align* a);
}
#endif // __cplusplus

#endif // SSW_H
#endif // SSW_H

0 comments on commit e7e9fbf

Please sign in to comment.