Skip to content

Commit 076a827

Browse files
authored
Merge pull request #26 from alimanfoo/noavx2
Add setup.py hooks to disable AVX2, SSE2 or C extensions altogether. Resolves #24.
2 parents 38d9914 + c494a04 commit 076a827

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

docs/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Intel Haswell, Broadwell or Skylake) then installing via pip is preferable,
3030
because this will compile the Blosc library from source with optimisations
3131
for AVX2.
3232

33+
Note that if you compile the C extensions on a machine with AVX2 support
34+
you probably then cannot use the same binaries on a machine without AVX2.
35+
To disable compilation with AVX2 support regardless of the machine
36+
architecture:
37+
38+
$ export DISABLE_NUMCODECS_AVX2=
39+
$ pip install numcodecs
40+
3341
To work with Numcodecs source code in development, install from GitHub::
3442

3543
$ git clone --recursive https://github.com/alimanfoo/numcodecs.git

docs/release.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ Other new features:
5353
help with understanding the shuffle option
5454
(`#4 <https://github.com/alimanfoo/numcodecs/issues/4>`_,
5555
`#19 <https://github.com/alimanfoo/numcodecs/issues/19>`_).
56+
* Options have been added to manually control how the C extensions are built regardless of the
57+
architecture of the system on which the build is run. To disable support for AVX2 set the
58+
environment variable "DISABLE_NUMCODECS_AVX2". To disable support for SSE2 set the environment
59+
variable "DISABLE_NUMCODECS_SSE2". To disable C extensions altogether set the environment variable
60+
"DISABLE_NUMCODECS_CEXT"
61+
(`#24 <https://github.com/alimanfoo/numcodecs/issues/24>`_,
62+
`#26 <https://github.com/alimanfoo/numcodecs/issues/26>`_).
5663

5764
Maintenance work:
5865

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def blosc_extension():
6565
cpu_info = cpuinfo.get_cpu_info()
6666

6767
# SSE2
68-
if 'sse2' in cpu_info['flags']:
69-
info('SSE2 detected')
68+
if 'sse2' in cpu_info['flags'] and 'DISABLE_NUMCODECS_SSE2' not in os.environ:
69+
info('building with SSE2 support')
7070
extra_compile_args.append('-DSHUFFLE_SSE2_ENABLED')
7171
blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'sse2' in f]
7272
if os.name == 'posix':
@@ -75,8 +75,8 @@ def blosc_extension():
7575
define_macros += [('__SSE2__', 1)]
7676

7777
# AVX2
78-
if 'avx2' in cpu_info['flags']:
79-
info('AVX2 detected')
78+
if 'avx2' in cpu_info['flags'] and 'DISABLE_NUMCODECS_AVX2' not in os.environ:
79+
info('building with AVX2 support')
8080
extra_compile_args.append('-DSHUFFLE_AVX2_ENABLED')
8181
blosc_sources += [f for f in glob('c-blosc/blosc/*.c') if 'avx2' in f]
8282
if os.name == 'posix':
@@ -308,12 +308,13 @@ def run_setup(with_extensions):
308308

309309
if __name__ == '__main__':
310310
is_pypy = hasattr(sys, 'pypy_translation_info')
311+
with_extensions = not is_pypy and 'DISABLE_NUMCODECS_CEXT' not in os.environ
311312

312313
try:
313-
run_setup(not is_pypy)
314+
run_setup(with_extensions)
314315
except BuildFailed:
315316
error('*' * 75)
316-
error('compilation of the Blosc C extension failed.')
317+
error('compilation of C extensions failed.')
317318
error('retrying installation without C extensions...')
318319
error('*' * 75)
319320
run_setup(False)

0 commit comments

Comments
 (0)