Skip to content

Commit

Permalink
Adding action for macos arm (#127)
Browse files Browse the repository at this point in the history
* Adding action for macos arm

* Trying to fix github action

* Putting back the config matrix

* Adding arm to update function

* Only arm

* Adding macos and linux

* Fixing cache?

* Fixing action ?

* testing cache

* matrix.os name ?

* checking compiler version

* Checking path

* Checking path

* Updating path

* Trying with alias

* Trying with alias + path

* More logging

* Trying to link to /opt/homebrew/bin/

* Searching for symlink

* Splitting intel and arm macos configurations

* Checking voro++ compiler

* Only compiling libvoro++.a

* Only compiling libvoro++.a

* Only compiling libvoro++.a

* Adding sudo

* Presrving env in sudo

* Trying without sudo

* Trying without sudo

* Trying new compiling flags

* Trying -Wl -ld_classic compiling flags

* Adding test on arch in Makefile

* Trying to fix benchmark and test-suite
  • Loading branch information
cpinte authored Jul 21, 2024
1 parent fce48e3 commit 631fd78
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
23 changes: 18 additions & 5 deletions .github/actions/dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,28 @@ runs:
echo "INTEL_PATH=/home/runner/intel/oneapi" >> "$GITHUB_ENV"
sudo chown root /bin/tar && sudo chmod u+s /bin/tar # tar needs to run as root to extract when restoring the cache
- name: fix gcc issue on the runner (GNU / macos)
if: matrix.compiler == 'gfortran' && matrix.os == 'macos'
- name: fix gcc issue on the runner (GNU / macos intel)
if: matrix.compiler == 'gfortran' && matrix.os == 'macos-intel'
shell: bash
run: |
brew reinstall gcc@13
ln -s /usr/local/bin/gcc-13 /usr/local/bin/gcc
ln -s /usr/local/bin/g++-13 /usr/local/bin/g++
ln -s /usr/local/bin/gfortran-13 /usr/local/bin/gfortran
- name: fix gcc issue on the runner (GNU / macos arm)
if: matrix.compiler == 'gfortran' && matrix.os == 'macos-arm'
shell: bash
run: |
sudo chown -R $(whoami) /usr/local
brew reinstall gcc@13
ln -s /opt/homebrew/bin/gcc-13 /usr/local/bin/gcc
ln -s /opt/homebrew/bin/g++-13 /usr/local/bin/g++
ln -s /opt/homebrew/bin/gfortran-13 /usr/local/bin/gfortran
export PATH=/usr/local/bin:${PATH}
- name: install intel compilers (intel / macos)
if: matrix.compiler == 'ifort' && matrix.os == 'macos'
if: matrix.compiler == 'ifort' && matrix.os == 'macos-intel'
shell: bash
run: |
wget -nv https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2fbce033-15f4-4e13-8d14-f5a2016541ce/m_fortran-compiler-classic_p_2023.2.0.49001_offline.dmg &
Expand All @@ -57,7 +68,7 @@ runs:
path: |
${{ env.MCFOST_INSTALL }}/include
${{ env.MCFOST_INSTALL }}/lib/${{ matrix.compiler }}
key: mcfost-deps-${{ runner.os }}-${{ matrix.compiler }}-${{ hashFiles('lib/install.sh') }}
key: mcfost-TEST-deps-${{ matrix.os }}-${{ matrix.compiler }}-${{ hashFiles('lib/install.sh') }}

- name: unset setuid bit for tar if cache not found
if: matrix.compiler == 'ifort' && matrix.os == 'linux' && steps.cache-deps.outputs.cache-hit != 'true'
Expand All @@ -71,5 +82,7 @@ runs:
working-directory: lib
run: |
[ ! "$SETVARS_COMPLETED" == 1 ] && test -f "$INTEL_PATH"/setvars.sh && . "$INTEL_PATH"/setvars.sh
sudo chmod o+w /usr/local/include /usr/local/lib
sudo chown -R $(whoami) /usr/local
mkdir -p /usr/local/include /usr/local/lib
chmod o+wr /usr/local/include /usr/local/lib
./install.sh
23 changes: 18 additions & 5 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [linux, macos]
os: [macos-arm, macos-intel, linux]
compiler: [gfortran, ifort]
openmp: [yes, no]
release: [yes, no]
Expand All @@ -30,15 +30,21 @@ jobs:
# Associate specific os versions with our os tags
- os: linux
os-version: ubuntu-22.04
- os: macos
- os: macos-intel
os-version: macos-12
- os: macos-arm
os-version: macos-14

# macos needs null container to avoid loading docker; set linux containers as desired
- container: null
- os: linux
compiler: gfortran
container: "quay.io/pypa/manylinux_2_28_x86_64"

exclude:
- os: macos-arm
compiler: ifort

name: build+test (${{ matrix.os }}, ${{ matrix.compiler }}, openmp=${{ matrix.openmp }}, release=${{ matrix.release }})
runs-on: ${{ matrix.os-version }}
container: ${{ matrix.container }}
Expand Down Expand Up @@ -92,7 +98,7 @@ jobs:
- name: restore binary artifact
uses: actions/download-artifact@v4
with:
name: mcfost-binary-macos-${{ matrix.compiler }}
name: mcfost-binary-macos-intel-${{ matrix.compiler }}
path: src/

- name: benchmark
Expand All @@ -107,14 +113,16 @@ jobs:
needs: build-and-test
strategy:
matrix:
os: [linux, macos]
os: [linux, macos-intel, macos-arm]

include:
# Associate specific os versions with our os tags
- os: linux
os-version: ubuntu-22.04
- os: macos
- os: macos-intel
os-version: macos-12
- os: macos-arm
os-version: macos-14

runs-on: ${{ matrix.os-version }}
if: ${{ github.event_name == 'release' }}
Expand All @@ -123,6 +131,11 @@ jobs:
- uses: actions/checkout@v4

- name: restore binary artifact
uses: actions/download-artifact@v4
with:
name: mcfost-binary-${{ matrix.os }}-${{ matrix.os == 'macos-arm' && 'gfortran' || 'ifort' }}
path: src/

uses: actions/download-artifact@v4
with:
name: mcfost-binary-${{ matrix.os }}-ifort # use ifort for binary release
Expand Down
7 changes: 5 additions & 2 deletions lib/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ echo "Done"
#-------------------------------------------
# Voro++
#-------------------------------------------
echo "Compiling Voro++ ..."
echo "Compiling Voro++ library ..."
if [ "$SYSTEM" = "ifort" ]; then
\cp -f ifort/config.mk voro
elif [ "$SYSTEM" = "ifx" ]; then
Expand All @@ -201,7 +201,10 @@ fi
cd voro
# Allowing for up to 1e8 particles (1e7 by default)
\cp -f ../voro++/config.hh src/
make
cd src
pwd
make libvoro++.a
cd -
\cp src/libvoro++.a ../lib
mkdir -p ../include/voro++
\cp src/*.hh ../include/voro++/
Expand Down
12 changes: 10 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#------------------------------------------------------------------------------#

IS_DARWIN := $(shell uname | tr '[a-z]' '[A-Z]' 2>&1 | grep -c DARWIN)
cpu = $(shell uname -m)

KNOWN_SYSTEM=no

Expand Down Expand Up @@ -142,7 +143,11 @@ ifeq ($(SYSTEM), gfortran)
CXX= g++
CCFLAGS= -Wall -pedantic -m64 -O3 -funroll-loops -ffinite-math-only -fno-trapping-math
COMPFLAGS= -fopenmp
LIBCXX= -lstdc++
ifeq ($(cpu),arm64)
LIBCXX= -lstdc++ -Wl,-ld_classic # for github action
else
LIBCXX= -lstdc++
endif
ifneq ($(shell $(CC) -v 2>&1 | grep -c "clang"), 0)
LIBCXX= -lc++
endif
Expand Down Expand Up @@ -306,9 +311,12 @@ endif

operating_system.f90 : sha.o
printf "module os\n implicit none\n" > operating_system.f90
uname | awk \
uname -s | awk \
'{print " character(len=7), parameter :: operating_system = \""$$1"\""}' \
>> operating_system.f90
uname -m | awk \
'{print " character(len=7), parameter :: architecture = \""$$1"\""}' \
>> operating_system.f90
printf "end module os\n" >> operating_system.f90

mcfost2prodimo : mcfost mcfost2prodimo.o
Expand Down
9 changes: 7 additions & 2 deletions src/utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,13 @@ function mcfost_update(lforce_update, lmanual, n_days)
url = trim(webpage)//"mcfost_Linux-X64.tar.gz"
url_sha1 = trim(webpage)//"mcfost_Linux-X64.sha1"
else if (operating_system=="Darwin") then
url = trim(webpage)//"mcfost_macOS-X64.tar.gz"
url_sha1 = trim(webpage)//"mcfost_macOS-X64.sha1"
if (architecture == "arm64") then
url = trim(webpage)//"mcfost_macOS-ARM64.tar.gz"
url_sha1 = trim(webpage)//"mcfost_macOS-ARM64.sha1"
else
url = trim(webpage)//"mcfost_macOS-X64.tar.gz"
url_sha1 = trim(webpage)//"mcfost_macOS-X64.sha1"
endif
else
write(*,*) "Unknown operating system : error 2"
write(*,*) "Cannot download new binary"
Expand Down

0 comments on commit 631fd78

Please sign in to comment.