Written by Alex Ganose @utf and Janosh Riebesell @janosh. Published 2022-03-28. Last updated 2024-03-30.
-
Install Xcode command line tools:
xcode-select --install
-
Install dependencies using Homebrew:
brew install gcc openmpi scalapack fftw qd openblas
Optionally, add
hdf5
for HDF5 support in VASP. -
Compile VASP:
These instructions are for VASP 6.4.1 but should work with minor adjustments for other versions.
cd /path/to/vasp-6.x.y cp arch/makefile.include.gnu_omp makefile.include
Edit
makefile.include
in the VASPsrc
directory:-
Add to
CPP_OPTIONS
:-D_OPENMP \ -Dqd_emulate
-
Change all instances of
gcc
togcc-13
andg++
tog++-13
-
Add after
LLIBS = -lstdc++
to emulate quad precision:QD ?= /opt/homebrew/ LLIBS += -L$(QD)/lib -lqdmod -lqd INCS += -I$(QD)/include/qd
-
Set
SCALAPACK_ROOT ?= /opt/homebrew
-
Set
OPENBLAS_ROOT ?= /opt/homebrew/Cellar/openblas/0.3.20
(Double check this is the path on your system) -
Set
FFTW_ROOT ?= /opt/homebrew
-
(optional but recommended by VASP) For HDF5 support, add
CPP_OPTIONS+= -DVASP_HDF5 HDF5_ROOT ?= /opt/homebrew/ LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran INCS += -I$(HDF5_ROOT)/include
-
Append
getshmem.o
toOBJECTS_LIB
inmakefile.include
(VASP wiki)- OBJECTS_LIB = linpack_double.o + OBJECTS_LIB = linpack_double.o getshmem.o
-
In
src/parser/makefile
, change (as noted by @zhuligs):- ar vq libparser.a $(CPPOBJ_PARS) $(COBJ_PARS) locproj.tab.h + ar vq libparser.a $(CPPOBJ_PARS) $(COBJ_PARS)
Do not replace the tab at the beginning of the line with spaces!
-
In
src/lib/getshmem.c
, add the line#define SHM_NORESERVE 0
(VASP forum):/*output: shmem id */ #define SHM_NORESERVE 0 // this line was added void getshmem_C(size_t _size, int *_id)
-
In
makefile.include
, update the parser section (VASP forum):# For the parser library CXX_PARS = g++-13 - LLIBS = -lstdc++ + LIBS += parser + LLIBS = -Lparser -lparser -lstdc++ QD ?= /opt/homebrew LLIBS += -L$(QD)/lib -lqdmod -lqd INCS += -I$(QD)/include/qd
-
-
Finally, run:
make all
If a previous compilation failed, remember to run
make veryclean
to start from a clean slate. Fixesgfortran
errors likeFatal Error:
string.mod
not found
If successful, the VASP binaries will be in src/bin
. Test with make test
.
Confirmed working with VASP 6.4.1 on M1 Pro with Sonoma 14.2.1 and [email protected]
.
See makefile.include
.
Initial performance testing suggests optimal parameters for the M1 Pro chip with 8 performance, 2 efficiency cores and 16" MBP cooling are
export OMP_NUM_THREADS=1 # important
mpiexec -np 8 vasp_std
NCORE = 4 # in INCAR
n_proc | n_threads | n_core | elapsed (sec) | |
---|---|---|---|---|
0 | 1 | 1 | 2 | 93.3 |
1 | 1 | 1 | 4 | 92.8 |
2 | 1 | 2 | 2 | 82.8 |
3 | 1 | 2 | 4 | 82.7 |
4 | 2 | 1 | 2 | 42.8 |
5 | 2 | 1 | 4 | 42.9 |
6 | 2 | 2 | 2 | 52.9 |
7 | 2 | 2 | 4 | 52.7 |
8 | 4 | 1 | 2 | 32.9 |
9 | 4 | 1 | 4 | 32.9 |
10 | 4 | 2 | 2 | 52.9 |
11 | 4 | 2 | 4 | 53.0 |
12 | 8 | 1 | 2 | 32.8 |
13 | 8 | 1 | 4 | 22.8 |
14 | 8 | 2 | 2 | 62.8 |
15 | 8 | 2 | 4 | 62.9 |
Brings wall time for this Si2 relaxation down to 23 sec.
from time import perf_counter
from atomate2.vasp.jobs.core import RelaxMaker
from atomate2.vasp.powerups import update_user_incar_settings
from jobflow import run_locally
from pymatgen.core import Structure
start = perf_counter()
# FCC silicon structure
si_structure = Structure(
lattice=[[0, 2.73, 2.73], [2.73, 0, 2.73], [2.73, 2.73, 0]],
species=["Si", "Si"],
coords=[[0, 0, 0], [0.25, 0.25, 0.25]],
)
# relax job to optimize structure
relax_job = RelaxMaker().make(si_structure)
relax_job = update_user_incar_settings(relax_job, {"NCORE": 4})
# run job
run_locally(relax_job, create_folders=True, ensure_success=True)
print(f"Si relaxation took {perf_counter() - start:.3f} sec")
Thanks @janosh for these instructions on my M2 Pro Macbook, running macOS Ventura. I tried using them to compile VASP 5.4.4. I made just two tiny tweaks to your makefile.include for newer versions brew gave me for gcc and openblas, i.e. gcc-11 -> gcc-13 and openblas 0.3.20 -> 0.3.23. Things go ok up to the link stage, but then I get an Undefined symbols for architecture arm64 error, see command line output below. Have you (or anyone else compiling VASP on Apple Silicon) ever come across these errors, and would you have any idea how to fix them?
Kind regards,
Peter
mpif90 -fopenmp -o vasp c2f_interface.o base.o profiling.o openmp.o mpi.o mpi_shmem.o smart_allocate.o xml.o constant.o jacobi.o main_mpi.o scala.o asa.o lattice.o poscar.o ini.o mgrid.o xclib.o vdw_nl.o xclib_grad.o radial.o pseudo.o gridq.o ebs.o mkpoints.o wave.o wave_mpi.o wave_high.o bext.o spinsym.o symlib.o symmetry.o lattlib.o random.o nonl.o nonlr.o nonl_high.o dfast.o choleski2.o mix.o hamil.o xcgrad.o xcspin.o potex1.o potex2.o constrmag.o cl_shift.o relativistic.o LDApU.o paw_base.o metagga.o egrad.o pawsym.o pawfock.o pawlhf.o rhfatm.o hyperfine.o paw.o mkpoints_full.o charge.o Lebedev-Laikov.o stockholder.o dipol.o solvation.o pot.o dos.o elf.o tet.o tetweight.o hamil_rot.o chain.o dyna.o k-proj.o sphpro.o us.o core_rel.o aedens.o wavpre.o wavpre_noio.o broyden.o dynbr.o reader.o writer.o tutor.o xml_writer.o brent.o stufak.o fileio.o opergrid.o stepver.o chgloc.o fast_aug.o fock_multipole.o fock.o fock_dbl.o mkpoints_change.o subrot_cluster.o sym_grad.o mymath.o npt_dynamics.o subdftd3.o internals.o dynconstr.o dimer_heyden.o dvvtrajectory.o vdwforcefield.o hamil_high.o nmr.o pead.o subrot.o subrot_scf.o paircorrection.o rpa_force.o force.o pwlhf.o gw_model.o optreal.o steep.o rmm-diis.o davidson.o david_inner.o lcao_bare.o locproj.o electron.o rot.o electron_all.o shm.o pardens.o optics.o constr_cell_relax.o stm.o finite_diff.o elpol.o hamil_lr.o rmm-diis_lr.o subrot_lr.o lr_helper.o hamil_lrf.o elinear_response.o ilinear_response.o linear_optics.o setlocalpp.o wannier.o electron_OEP.o electron_lhf.o twoelectron4o.o gauss_quad.o m_unirnk.o varpro.o minimax.o mlwf.o wnpr.o ratpol.o pade_fit.o screened_2e.o wave_cacher.o crpa.o chi_base.o wpot.o local_field.o ump2.o ump2kpar.o fcidump.o ump2no.o bse_te.o bse.o acfdt.o chi.o sydmat.o rmm-diis_mlr.o linear_response_NMR.o wannier_interpol.o linear_response.o dmft.o auger.o dmatrix.o elphon.o fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o main.o -Llib -ldmy -lstdc++ -L/opt/homebrew/lib -lqdmod -lqd -L/opt/homebrew/lib -lscalapack -L/opt/homebrew/Cellar/openblas/0.3.23/lib -lopenblas -L/opt/homebrew/lib -lfftw3 -lfftw3_omp
Undefined symbols for architecture arm64:
"_attachshmem_C", referenced from:
___mpi_shmem_MOD_shmem_alloc_r_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_1d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_1d in mpi_shmem.o
"_destroyshmem_C", referenced from:
___mpi_shmem_MOD_shmem_alloc_r_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_1d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_1d in mpi_shmem.o
"_detachshmem_C", referenced from:
___mpi_shmem_MOD_shmem_dealloc_r_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_dealloc_r_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_dealloc_r_1d in mpi_shmem.o
___mpi_shmem_MOD_shmem_dealloc_c_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_dealloc_c_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_dealloc_c_1d in mpi_shmem.o
"_fill_basis_info_C", referenced from:
___locproj_MOD_lprj_reader in locproj.o
"_free_parser_C", referenced fro "_free_parser_C", referenced fro "_free_parser_C", referenced from:
___locproj_MOD_lprj_reader in locproj.o
"_getshmem_C", referenced from:
___mpi_shmem_MOD_shmem_alloc_r_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_1d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_1d in mpi_shmem.o
"_getshmem_error_C", referenced from:
___mpi_shmem_MOD_shmem_alloc_r_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_r_1d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_3d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_2d in mpi_shmem.o
___mpi_shmem_MOD_shmem_alloc_c_1d in mpi_shmem.o
"_parse_file_C", referenced from:
___locproj_MOD_lprj_reader in locproj.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make[2]: *** [vasp] Error 1
cp: vasp: No such file or directory
make[1]: *** [all] Error 1
make: *** [std] Error 2
bash-3.2$
bash-3.2$