Skip to content

Commit 7d722b4

Browse files
authored
Merge pull request #50 from fabinsch/arm-support
Support ARM64 architecture
2 parents e047643 + 3e06f29 commit 7d722b4

File tree

4 files changed

+112
-26
lines changed

4 files changed

+112
-26
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI - OSX ARM64 - Conda
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
PYTHONPATH: ${CONDA_PREFIX}/lib/python3.8/site-packages/
9+
10+
jobs:
11+
build-with-conda:
12+
name: '[conda:${{ matrix.os }}:${{ matrix.build_type }}]'
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
build_type: [Release, Debug]
18+
name: [macos-m1]
19+
20+
include:
21+
- name: macos-m1
22+
os: self-hosted-arm64
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
# not working due to The node12 is not supported on macOS ARM64 platform. Use node16 instead.
28+
# open issue https://github.com/conda-incubator/setup-miniconda/issues/247
29+
# - uses: conda-incubator/setup-miniconda@v2
30+
# with:
31+
# activate-environment: proxarm
32+
33+
- name: Environment
34+
shell: bash -l {0}
35+
run: |
36+
echo $CONDA_PREFIX
37+
conda info
38+
conda list
39+
env
40+
41+
- name: Configure
42+
shell: bash -l {0}
43+
run: |
44+
cd $GITHUB_WORKSPACE
45+
git submodule update --init
46+
mkdir build
47+
cd build
48+
cmake .. -GNinja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_PYTHON_INTERFACE:BOOL=ON -DBUILD_WITH_VECTORIZATION_SUPPORT:BOOL=OFF -DPYTHON_SITELIB=${CONDA_PREFIX}/Lib/site-packages -DPYTHON_EXECUTABLE=${CONDA_PYTHON_EXE} -DINSTALL_DOCUMENTATION:BOOL=ON -DTEST_JULIA_INTERFACE:BOOL=OFF
49+
50+
- name: Build
51+
shell: bash -l {0}
52+
run: |
53+
cd $GITHUB_WORKSPACE/build
54+
cmake --build . --config ${{ matrix.build_type }} -v
55+
56+
- name: Install
57+
shell: bash -l {0}
58+
run: |
59+
cd $GITHUB_WORKSPACE/build
60+
cmake --install . --config ${{ matrix.build_type }}
61+
62+
63+
- name: Test
64+
shell: bash -l {0}
65+
run: |
66+
cd $GITHUB_WORKSPACE/build
67+
ctest --output-on-failure -C ${{ matrix.build_type }}
68+
69+
70+
- name: Uninstall [Conda]
71+
shell: bash -l {0}
72+
run: |
73+
cd $GITHUB_WORKSPACE/build
74+
cmake --build . --config ${{ matrix.build_type }} --target uninstall

bindings/python/CMakeLists.txt

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,28 @@ add_custom_target(python)
1616

1717
# Collect files
1818
file(GLOB_RECURSE PYWRAP_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.hpp)
19-
2019
file(GLOB_RECURSE PYWRAP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
2120

22-
# Add simd feature detectors for current CPU
23-
python3_add_library(instructionset MODULE helpers/instruction-set.cpp)
24-
add_dependencies(python instructionset)
25-
target_link_libraries(instructionset PRIVATE proxsuite pybind11::module)
26-
set_target_properties(
27-
instructionset
28-
PROPERTIES OUTPUT_NAME instructionset
29-
LIBRARY_OUTPUT_DIRECTORY
30-
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
31-
if(UNIX AND NOT APPLE)
32-
set_target_properties(instructionset PROPERTIES INSTALL_RPATH
33-
"\$ORIGIN/../../..")
21+
# Add simd feature detectors for current intel CPU
22+
message("-- CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
23+
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
24+
python3_add_library(instructionset MODULE helpers/instruction-set.cpp)
25+
add_dependencies(python instructionset)
26+
target_link_libraries(instructionset PRIVATE proxsuite pybind11::module)
27+
set_target_properties(
28+
instructionset
29+
PROPERTIES OUTPUT_NAME instructionset
30+
LIBRARY_OUTPUT_DIRECTORY
31+
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
32+
if(UNIX AND NOT APPLE)
33+
set_target_properties(instructionset PROPERTIES INSTALL_RPATH
34+
"\$ORIGIN/../../..")
35+
endif()
36+
install(
37+
TARGETS instructionset
38+
EXPORT ${TARGETS_EXPORT_NAME}
39+
DESTINATION ${${PYWRAP}_INSTALL_DIR})
3440
endif()
35-
install(
36-
TARGETS instructionset
37-
EXPORT ${TARGETS_EXPORT_NAME}
38-
DESTINATION ${${PYWRAP}_INSTALL_DIR})
3941

4042
function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
4143
python3_add_library(${target_name} MODULE ${PYWRAP_SOURCES} ${PYWRAP_HEADERS})
@@ -46,7 +48,6 @@ function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
4648
target_link_libraries(${target_name} PRIVATE proxsuite pybind11::module)
4749
target_compile_definitions(${target_name}
4850
PRIVATE PYTHON_MODULE_NAME=${target_name})
49-
5051
set_target_properties(
5152
${target_name}
5253
PROPERTIES OUTPUT_NAME ${target_name}
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
from . import instructionset
1+
import platform
2+
3+
if (
4+
"i386" in platform.processor()
5+
or "x86_64" in platform.processor()
6+
or "Intel64" in platform.processor()
7+
):
8+
from . import instructionset
29

310

411
def load_main_module(globals):
@@ -13,17 +20,19 @@ def load_module(main_module_name):
1320
except ModuleNotFoundError:
1421
return False
1522

16-
all_modules = [
17-
("proxsuite_pywrap_avx512", instructionset.has_AVX512F),
18-
("proxsuite_pywrap_avx2", instructionset.has_AVX2),
19-
]
23+
if "arm" not in platform.processor():
24+
all_modules = [
25+
("proxsuite_pywrap_avx512", instructionset.has_AVX512F),
26+
("proxsuite_pywrap_avx2", instructionset.has_AVX2),
27+
]
2028

21-
for module_name, checker in all_modules:
22-
if checker() and load_module(module_name):
23-
return
29+
for module_name, checker in all_modules:
30+
if checker() and load_module(module_name):
31+
return
2432

2533
assert load_module("proxsuite_pywrap") == True
2634

2735

2836
load_main_module(globals=globals())
2937
del load_main_module
38+
del platform

include/proxsuite/linalg/dense/core.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include <proxsuite/linalg/veg/util/assert.hpp>
1010
#include <proxsuite/linalg/veg/memory/dynamic_stack.hpp>
1111

12+
#ifndef __aarch64__
1213
#include <immintrin.h>
14+
#endif
1315

1416
#ifdef PROXSUITE_VECTORIZE
1517
#include <cmath> // to avoid error of the type no member named 'isnan' in namespace 'std';

0 commit comments

Comments
 (0)