User Tools

Site Tools


howto:compile_on_macos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howto:compile_on_macos [2023/12/01 13:26] krackhowto:compile_on_macos [2024/01/24 13:35] (current) – Add check krack
Line 2: Line 2:
  
 This page describes how CP2K can be installed under [[https://en.wikipedia.org/wiki/MacOS|macOS]] ([[https://en.wikipedia.org/wiki/MacOS_Monterey|Monterey]], [[https://en.wikipedia.org/wiki/MacOS_Ventura|Ventura]], and [[https://en.wikipedia.org/wiki/MacOS_Sonoma|Sonoma]] This page describes how CP2K can be installed under [[https://en.wikipedia.org/wiki/MacOS|macOS]] ([[https://en.wikipedia.org/wiki/MacOS_Monterey|Monterey]], [[https://en.wikipedia.org/wiki/MacOS_Ventura|Ventura]], and [[https://en.wikipedia.org/wiki/MacOS_Sonoma|Sonoma]]
-). This howto has last been tested on an Apple M1 under macOS Sonoma 14.1.1 (Darwin Kernel Version 23.1.0, Homebrew 4.1.22). For further details check the corresponding Darwin-gnu-arm64 [[https://github.com/cp2k/cp2k/blob/master/arch/Darwin-gnu-arm64.psmp|arch file]] and [[https://dashboard.cp2k.org/archive/darwin-gnu-arm64-psmp/index.html|regression tester]]. This howto assumes that your default shell is ''bash''.+). This howto has last been tested on an Apple M1 under macOS Sonoma 14.(Darwin Kernel Version 23.3.0, Homebrew 4.2.5). For further details check the corresponding Darwin-gnu-arm64 [[https://github.com/cp2k/cp2k/blob/master/arch/Darwin-gnu-arm64.psmp|arch file]] and [[https://dashboard.cp2k.org/archive/darwin-gnu-arm64-psmp/index.html|regression tester]]. This howto assumes that your default shell is ''bash''.
  
 ==== 1. Install Homebrew ==== ==== 1. Install Homebrew ====
Line 10: Line 10:
 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
 </code> </code>
-which will install the latest Homebrew version. This howto was tested with Homebrew 3.6.11 as well as with newer versions up to 4.0.19.+which will install the latest Homebrew version. This howto was tested with Homebrew 3.6.11 as well as with newer versions up to 4.2.5.
  
 === a) The easy way === === a) The easy way ===
Line 22: Line 22:
 === b) Compile CP2K under macOS from scratch === === b) Compile CP2K under macOS from scratch ===
  
-If you installed CP2K with ''brew'' in the previous step, then make sure that you first uninstall ''cp2k'' and unlink its dependencies ''open-mpi'' and ''scalapack'',+For best performance or code development, it is recommended to install CP2K from scratch. If you installed already CP2K with ''brew'' as described in the previous section, then make sure that you first uninstall ''cp2k'' and unlink its dependencies ''open-mpi'' and ''scalapack'',
 e.g. with e.g. with
 <code> <code>
Line 36: Line 36:
 ln -s /opt/homebrew/bin/gfortran-13 /opt/homebrew/bin/gfortran ln -s /opt/homebrew/bin/gfortran-13 /opt/homebrew/bin/gfortran
 </code> </code>
-to make Homebrew's latest ''gcc'' and ''g++'' compilers the default instead of the clang versions in ''/usr/bin''.+to make Homebrew's latest ''gcc'' and ''g++'' compilers the default instead of the clang versions in ''/usr/bin''. Check with 
 +<code> 
 +gcc -v 
 +</code> 
 +if that is the case.
  
 ==== 2. Obtain CP2K ==== ==== 2. Obtain CP2K ====
Line 131: Line 135:
 will use 4 MPI ranks with 2 OpenMP threads each (i.e. it will consume 8 CPU cores) to run the input file ''H2O-32.inp'' which can be found in  the cp2k folder ''benchmarks/QS''. will use 4 MPI ranks with 2 OpenMP threads each (i.e. it will consume 8 CPU cores) to run the input file ''H2O-32.inp'' which can be found in  the cp2k folder ''benchmarks/QS''.
  
-The ''cp2k.popt'' binary is only MPI parallel and will run just one thread per MPI rank automatically (like ''cp2k.sopt'') which is usually the most efficient usage of CP2K performance-wise if no memory limitation per MPI rank come into play.+The ''cp2k.popt'' binary is only MPI parallel and will run just one thread per MPI rank automatically (like ''cp2k.sopt'') which is usually the most efficient usage of CP2K performance-wise if no memory limitation per MPI rank come into play. Therefore, the following commands 
 +<code> 
 +mpiexec -n 4 -genv OMP_NUM_THREADS=1 cp2k.psmp H2O-32.inp 
 +mpiexec -n 4                         cp2k.popt H2O-32.inp 
 +</code> 
 +are basically equivalent.
  
 **Enjoy CP2K under macOS!** **Enjoy CP2K under macOS!**
howto/compile_on_macos.1701437181.txt.gz · Last modified: 2023/12/01 13:26 by krack