diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ab06c9a..a2cd40fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,6 @@ repos: - id: check-symlinks - id: check-yaml - id: destroyed-symlinks - - id: double-quote-string-fixer - id: end-of-file-fixer - id: mixed-line-ending - id: trailing-whitespace @@ -37,7 +36,7 @@ repos: args: [--ignore-words-list, 'ist,yau,te,manuel', --check-filenames] - repo: https://github.com/pre-commit/mirrors-eslint - rev: v9.0.0-beta.1 + rev: v9.0.0-rc.0 hooks: - id: eslint types: [file] diff --git a/package.json b/package.json index 9a60d901..a79b228e 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,10 @@ "@iconify/svelte": "^3.1.6", "@rollup/plugin-yaml": "^4.1.2", "@sveltejs/adapter-static": "^3.0.1", - "@sveltejs/kit": "^2.5.1", + "@sveltejs/kit": "^2.5.5", "@sveltejs/vite-plugin-svelte": "^3.0.2", - "@typescript-eslint/eslint-plugin": "^7.0.2", - "@typescript-eslint/parser": "^7.0.2", + "@typescript-eslint/eslint-plugin": "^7.4.0", + "@typescript-eslint/parser": "^7.4.0", "devalue": "^4.3.2", "elementari": "^0.2.3", "eslint": "^8.57.0", @@ -41,22 +41,22 @@ "hast-util-select": "^6.0.2", "hastscript": "^9.0.0", "js-yaml": "^4.1.0", - "katex": "^0.16.9", + "katex": "^0.16.10", "mdsvex": "^0.11.0", "prettier": "^3.2.5", - "prettier-plugin-svelte": "^3.2.1", + "prettier-plugin-svelte": "^3.2.2", "rehype-autolink-headings": "^7.1.0", "rehype-katex-svelte": "^1.2.0", "rehype-slug": "^6.0.0", "remark-math": "3.0.0", "svelte": "^4.2.12", - "svelte-check": "^3.6.4", + "svelte-check": "^3.6.8", "svelte-multiselect": "^10.2.0", "svelte-preprocess": "^5.1.3", "svelte-preprocess-import-assets": "^1.1.0", "svelte-zoo": "^0.4.10", - "svelte2tsx": "^0.7.1", - "typescript": "^5.3.3", - "vite": "^5.1.4" + "svelte2tsx": "^0.7.5", + "typescript": "^5.4.3", + "vite": "^5.2.7" } } diff --git a/src/lib/oss.yml b/src/lib/oss.yml index d678c9d9..4a0297d0 100644 --- a/src/lib/oss.yml +++ b/src/lib/oss.yml @@ -9,8 +9,8 @@ projects: - Python - Cython - Jupyter Notebook - stars: 1266 - commits: 948 + stars: 1336 + commits: 979 - name: Matbench Discovery url: https://matbench-discovery.materialsproject.org logo: https://janosh.github.io/matbench-discovery/favicon.svg @@ -25,8 +25,8 @@ projects: - TypeScript - JavaScript - HTML - stars: 57 - commits: 315 + stars: 66 + commits: 318 - name: CHGNet url: https://chgnet.lbl.gov repo: https://github.com/CederGroupHub/chgnet @@ -43,8 +43,8 @@ projects: - HTML - JavaScript - TypeScript - stars: 174 - commits: 169 + stars: 184 + commits: 175 - name: MACE url: https://mace-docs.readthedocs.io repo: https://github.com/ACEsuit/mace @@ -52,7 +52,7 @@ projects: paper: riebesell_foundation_2023 description: Fast and accurate machine learning interatomic potentials with higher order equivariant message passing. logo: https://avatars.githubusercontent.com/u/68508620 - stars: 313 + stars: 345 commits: 21 languages: - Python @@ -68,7 +68,7 @@ projects: - Python - JavaScript - HTML - stars: 113 + stars: 118 commits: 174 - name: pymatviz url: https://pymatviz.janosh.dev @@ -82,8 +82,8 @@ projects: - TypeScript - HTML - JavaScript - stars: 104 - commits: 237 + stars: 111 + commits: 242 - name: Tensorboard Reducer repo: https://github.com/janosh/tensorboard-reducer logo: https://raw.githubusercontent.com/janosh/tensorboard-reducer/main/assets/tensorboard-reducer-square.svg @@ -92,7 +92,7 @@ projects: languages: - Python - TeX - stars: 61 + stars: 65 commits: 79 - name: Normalizing Flows repo: https://github.com/janosh/awesome-normalizing-flows @@ -100,7 +100,7 @@ projects: description: Curated list of resources for learning and using normalizing flows, a powerful tool in ML for modeling probability distributions. languages: - Python - stars: 1265 + stars: 1283 commits: 72 - name: atomate2 repo: https://github.com/materialsproject/atomate2 @@ -112,8 +112,8 @@ projects: potential-powered structure relaxation workflows. languages: - Python - stars: 116 - commits: 353 + stars: 119 + commits: 357 - name: jobflow repo: https://github.com/materialsproject/jobflow role: Maintainer @@ -124,8 +124,8 @@ projects: languages: - Python - TeX - stars: 81 - commits: 100 + stars: 83 + commits: 115 - name: Aviary repo: https://github.com/CompRhys/aviary role: Maintainer @@ -134,7 +134,7 @@ projects: pypi: https://pypi.org/project/tensorboard-reducer languages: - Python - stars: 38 + stars: 39 commits: 234 - name: MatCalc url: https://materialsvirtuallab.github.io/matcalc @@ -144,13 +144,13 @@ projects: description: A Python library for calculating materials properties from ML force field potential energy surfaces. languages: - Python - stars: 40 - commits: 68 + stars: 41 + commits: 72 - name: TikZ url: https://tikz.janosh.dev repo: https://github.com/janosh/tikz description: Collection TikZ figures for concepts in physics/chemistry/ML. - stars: 170 + stars: 174 commits: 187 languages: - TeX @@ -168,7 +168,7 @@ projects: logo: https://github.com/janosh/tikz/raw/main/assets/plate-capacitor/plate-capacitor.svg paper: riebesell_pushing_2024 stars: 7 - commits: 12 + commits: 14 languages: - Python - ReScript @@ -183,5 +183,5 @@ projects: - CSS - HTML - JavaScript - stars: 253 - commits: 270 + stars: 263 + commits: 271 diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 39fdf258..595622f5 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -42,7 +42,7 @@

- Interested in
+ I'm interested in
🔎 computational materials discovery  🤖 machine learning
💻 software engineering  diff --git a/src/routes/posts/compile-vasp-m1-mac/+page.md b/src/routes/posts/compiling-vasp-m1-mac/+page.md similarity index 58% rename from src/routes/posts/compile-vasp-m1-mac/+page.md rename to src/routes/posts/compiling-vasp-m1-mac/+page.md index af24c87d..83d6a0c5 100644 --- a/src/routes/posts/compile-vasp-m1-mac/+page.md +++ b/src/routes/posts/compiling-vasp-m1-mac/+page.md @@ -2,7 +2,7 @@ title: Compile VASP on M1 Mac date: 2022-03-28 cover: - img: compile-vasp-m1-mac.svg + img: compiling-vasp-m1-mac.svg tags: - Guide - Fortran @@ -12,48 +12,50 @@ tags: > This post started out [as a gist](https://gist.github.com/janosh/a484f3842b600b60cd575440e99455c0). There's some Q&A there that may be useful. -**Courtesy of Alex Ganose [@utf](https://github.com/utf) with additions from yours truly [@janosh](https://github.com/janosh).** +**Written by Alex Ganose [@utf](https://github.com/utf) and Janosh Riebesell [@janosh](https://github.com/janosh). Last updated on 2024-03-30.** -1. Install Xcode command line tools +Follow these steps to compile VASP on an M1 Mac: + +1. Install Xcode command line tools: ```sh xcode-select --install ``` -2. Install gcc, OpenMPI and OpenMP using homebrew +2. Install dependencies using Homebrew: ```sh brew install gcc openmpi scalapack fftw qd openblas ``` - Consider appending `hdf5` if you want to compile [VASP with HDF5 support][vasp-hdf5]. + Optionally, add `hdf5` for [HDF5 support in VASP][vasp-hdf5]. -3. Compile VASP +3. Compile VASP: - These instructions are for VASP 6.3.0; they should be transferable to other versions of VASP but the variable names may be different + These instructions are for VASP 6.4.1 but should work with minor adjustments for other versions. ```sh cd /path/to/vasp-6.x.y cp arch/makefile.include.gnu_omp makefile.include ``` - Then edit `makefile.include` as follows: + Edit `makefile.include` in the VASP `src` directory: - - Add the following to CPP_OPTIONS: + - Add to `CPP_OPTIONS`: ```make -D_OPENMP \ -Dqd_emulate ``` - - Change all instances of `gcc` to `gcc-11` and `g++` to `g++-11` + - Change all instances of `gcc` to `gcc-13` and `g++` to `g++-13` - - Add the following lines after `LLIBS = -lstdc++`. This is necessary to emulate quad precision. + - Add after `LLIBS = -lstdc++` to emulate quad precision: ```make - QD ?= /opt/homebrew/ - LLIBS += -L$(QD)/lib -lqdmod -lqd - INCS += -I$(QD)/include/qd + QD ?= /opt/homebrew/ + LLIBS += -L$(QD)/lib -lqdmod -lqd + INCS += -I$(QD)/include/qd ``` - Set `SCALAPACK_ROOT ?= /opt/homebrew` @@ -71,6 +73,45 @@ tags: INCS += -I$(HDF5_ROOT)/include ``` + - Append `getshmem.o` to `OBJECTS_LIB` in `makefile.include` ([VASP wiki](https://www.vasp.at/wiki/index.php/Shared_memory)) + + ```diff + - OBJECTS_LIB = linpack_double.o + + OBJECTS_LIB = linpack_double.o getshmem.o + ``` + + - In `src/parser/makefile`, change (as noted by [@zhuligs](https://gist.github.com/janosh/a484f3842b600b60cd575440e99455c0?permalink_comment_id=4323518#gistcomment-4323518)): + + ```diff + - 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](https://www.vasp.at/forum/viewtopic.php?t=15106)): + + ```c + /*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](https://www.vasp.at/forum/viewtopic.php?f=2&t=17477)): + + ```diff + # 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 + ``` + 4. Finally, run: ```sh @@ -81,9 +122,15 @@ tags: > Fatal Error: `string.mod` not found +If successful, the VASP binaries will be in `src/bin`. Test with `make test`. + +## Last Tested on 2024-03-30 + +Confirmed working with VASP 6.4.1 on M1 Pro with Sonoma 14.2.1 and `gcc@13.2.0`. + ## Resulting `makefile.include` with all modifications -See `makefile.include` below. +See [`makefile.include`](https://gist.github.com/janosh/a484f3842b600b60cd575440e99455c0#file-makefile-include). ## Benchmarking diff --git a/src/routes/posts/compile-vasp-m1-mac/compile-vasp-m1-mac.svg b/src/routes/posts/compiling-vasp-m1-mac/compiling-vasp-m1-mac.svg similarity index 100% rename from src/routes/posts/compile-vasp-m1-mac/compile-vasp-m1-mac.svg rename to src/routes/posts/compiling-vasp-m1-mac/compiling-vasp-m1-mac.svg diff --git a/src/routes/posts/compiling-vasp-m1-mac/makefile.include b/src/routes/posts/compiling-vasp-m1-mac/makefile.include new file mode 100644 index 00000000..f7588230 --- /dev/null +++ b/src/routes/posts/compiling-vasp-m1-mac/makefile.include @@ -0,0 +1,94 @@ +# Default precompiler options +CPP_OPTIONS = -DHOST=\"LinuxGNU\" \ + -DMPI -DMPI_BLOCK=8000 -Duse_collective \ + -DscaLAPACK \ + -DCACHE_SIZE=4000 \ + -Davoidalloc \ + -Dvasp6 \ + -Duse_bse_te \ + -Dtbdyn \ + -Dfock_dblbuf \ + -D_OPENMP \ + -Dqd_emulate + +CPP = gcc-13 -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS) + +FC = mpif90 -fopenmp +FCL = mpif90 -fopenmp + +FREE = -ffree-form -ffree-line-length-none + +FFLAGS = -w -ffpe-summary=invalid,zero,overflow -L /opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/13 + +OFLAG = -O2 +OFLAG_IN = $(OFLAG) +DEBUG = -O0 + +OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o +OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o +OBJECTS_O2 += fft3dlib.o + +# For what used to be vasp.5.lib +CPP_LIB = $(CPP) +FC_LIB = $(FC) +CC_LIB = gcc-13 +CFLAGS_LIB = -O +FFLAGS_LIB = -O1 +FREE_LIB = $(FREE) + +OBJECTS_LIB = linpack_double.o getshmem.o + +# For the parser library +CXX_PARS = g++-13 +LIBS += parser +LLIBS = -Lparser -lparser -lstdc++ +QD ?= /opt/homebrew +LLIBS += -L$(QD)/lib -lqdmod -lqd +INCS += -I$(QD)/include/qd + +## +## Customize as of this point! Of course you may change the preceding +## part of this file as well if you like, but it should rarely be +## necessary ... +## + +# When compiling on the target machine itself, change this to the +# relevant target when cross-compiling for another architecture +FFLAGS += -march=native + +# For gcc-10 and higher (comment out for older versions) +FFLAGS += -fallow-argument-mismatch + +# BLAS and LAPACK (mandatory) +OPENBLAS_ROOT ?= /opt/homebrew/Cellar/openblas/0.3.26 +BLASPACK = -L$(OPENBLAS_ROOT)/lib -lopenblas + +# scaLAPACK (mandatory) +SCALAPACK_ROOT ?= /opt/homebrew +SCALAPACK = -L$(SCALAPACK_ROOT)/lib -lscalapack + +LLIBS += $(SCALAPACK) $(BLASPACK) + +# FFTW (mandatory) +FFTW_ROOT ?= /opt/homebrew +LLIBS += -L$(FFTW_ROOT)/lib -lfftw3 -lfftw3_omp +INCS += -I$(FFTW_ROOT)/include + +# HDF5-support (optional but strongly recommended) +#CPP_OPTIONS+= -DVASP_HDF5 +#HDF5_ROOT ?= /path/to/your/hdf5/installation +#LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran +#INCS += -I$(HDF5_ROOT)/include + +# For the VASP-2-Wannier90 interface (optional) +#CPP_OPTIONS += -DVASP2WANNIER90 +#WANNIER90_ROOT ?= /path/to/your/wannier90/installation +#LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier + +# For the fftlib library (experimental) +#CPP_OPTIONS+= -Dsysv +#FCL += fftlib.o +#CXX_FFTLIB = g++-13 -fopenmp -std=c++11 -DFFTLIB_THREADSAFE +#INCS_FFTLIB = -I./include -I$(FFTW_ROOT)/include +#LIBS += fftlib +#LLIBS += -ldl diff --git a/src/routes/posts/compiling-vasp-m1-mac/vasp-perf-grid-search.py b/src/routes/posts/compiling-vasp-m1-mac/vasp-perf-grid-search.py new file mode 100644 index 00000000..39a119f1 --- /dev/null +++ b/src/routes/posts/compiling-vasp-m1-mac/vasp-perf-grid-search.py @@ -0,0 +1,72 @@ +"""This script grid-searches OMP_NUM_THREADS, NCORE and number of MPI processes for +minimal VASP runtime on a simple Si2 relaxation. + +It writes the results to CSV and copies +markdown table to clipboard. Requires Python 3.10. To keep a log, invoke with + +python vasp-perf-grid-search.py 2>&1 | tee Si-relax.log + +To install OpenMPI's mpiexec on macOS, use Homebrew: +brew install open-mpi +""" + +import os +import warnings +from itertools import product +from time import perf_counter, sleep + +import pandas as pd +from atomate2.vasp.jobs.core import RelaxMaker +from atomate2.vasp.powerups import update_user_incar_settings +from jobflow import run_locally +from pandas.io.clipboard import clipboard_set +from pymatgen.core import Structure + +warnings.filterwarnings("ignore") # hide pymatgen warnings clogging up the logs + +VASP_BIN = "/Users/janosh/dev/vasp/compiled/vasp_std_6.3.0_m1" +results: list[tuple[int, int, int, float]] = [] + +# construct an 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]], +) + +# grid-search OMP_NUM_THREADS, NCORE and number of MPI processes +try: + prod = list(product([1, 2, 4, 8], [1, 2], [2, 4])) + for idx, (n_proc, n_threads, n_core) in enumerate(prod, 1): + os.environ["OMP_NUM_THREADS"] = str(n_threads) + + print(f"Run {idx} / {len(prod)}") + + # make a relax job to optimize the structure + relax_job = RelaxMaker( + run_vasp_kwargs={"vasp_cmd": f"mpiexec -np {n_proc} {VASP_BIN}"}, + ).make(si_structure) + + relax_job = update_user_incar_settings(relax_job, {"NCORE": n_core}) + + start = perf_counter() + # run the job + run_locally(relax_job, create_folders=True, ensure_success=True) + + elapsed = perf_counter() - start + print( + f"run with {n_proc=}, {n_threads=}, {n_core=} took {elapsed:.1f} sec", + ) + results += [(n_proc, n_threads, n_core, elapsed)] + + print("Waiting 10 secs to cooldown...\n\n", flush=True) + sleep(10) # so every run is a bit more like the first + + +except KeyboardInterrupt: # exit gracefully on ctrl+c and write partial results + print("Job was interrupted") + + +df_perf = pd.DataFrame(results, columns=["n_proc", "n_threads", "n_core", "elapsed"]) +df_perf.round(2).to_csv("vasp-perf-results.csv") +clipboard_set(df_perf.to_markdown()) diff --git a/src/routes/posts/compiling-vasp-m1-mac/vasp-perf-results.csv b/src/routes/posts/compiling-vasp-m1-mac/vasp-perf-results.csv new file mode 100644 index 00000000..5452112e --- /dev/null +++ b/src/routes/posts/compiling-vasp-m1-mac/vasp-perf-results.csv @@ -0,0 +1,17 @@ +,n_proc,n_threads,n_core,elapsed +0,1,1,2,93.37 +1,1,1,4,92.82 +2,1,2,2,82.80 +3,1,2,4,82.78 +4,2,1,2,42.82 +5,2,1,4,42.90 +6,2,2,2,52.92 +7,2,2,4,52.79 +8,4,1,2,32.91 +9,4,1,4,32.93 +10,4,2,2,52.93 +11,4,2,4,53.02 +12,8,1,2,32.90 +13,8,1,4,22.82 +14,8,2,2,62.88 +15,8,2,4,62.98