Skip to content

Commit df08667

Browse files
Merge pull request #1385 from strandn/ttsketch
TT-MetaD
2 parents 4d7da4b + 91c8da9 commit df08667

28 files changed

Lines changed: 3210 additions & 1 deletion

.ci/install.itensor

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /usr/bin/env bash
2+
3+
set -e
4+
set -x
5+
6+
# Directory containing this script (i.e. .ci/)
7+
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
9+
# Install ITensor v3 dependencies
10+
sudo apt-get install -y libopenblas-dev libhdf5-dev
11+
12+
ITENSOR_VERSION=3.2.0
13+
ITENSOR_INSTALL_DIR="$HOME/opt/itensor"
14+
15+
cd "$(mktemp -dt plumed.XXXXXX)"
16+
17+
wget https://github.com/ITensor/ITensor/archive/refs/tags/v${ITENSOR_VERSION}.tar.gz
18+
tar xzf v${ITENSOR_VERSION}.tar.gz
19+
cd ITensor-${ITENSOR_VERSION}
20+
21+
# Use the CI-specific options.mk (OpenBLAS + system HDF5)
22+
cp "$CI_DIR/options.mk.itensor" options.mk
23+
24+
make
25+
26+
# Copy the built library and headers to the install directory
27+
mkdir -p "$ITENSOR_INSTALL_DIR"
28+
cp -r lib "$ITENSOR_INSTALL_DIR/"
29+
cp -r itensor "$ITENSOR_INSTALL_DIR/"

.ci/options.mk.itensor

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
### CI-specific options.mk for ITensor v3
2+
### Uses OpenBLAS and system HDF5 (installed via apt on ubuntu-22.04).
3+
### Copy this file to the ITensor source directory as options.mk before building.
4+
5+
## Compiler
6+
CCCOM=g++ -m64 -std=c++17 -fconcepts -fPIC
7+
8+
## BLAS/LAPACK: use OpenBLAS (apt install libopenblas-dev)
9+
PLATFORM=lapack
10+
BLAS_LAPACK_LIBFLAGS=-lpthread -lopenblas
11+
12+
## HDF5
13+
HDF5_CFLAGS := $(shell pkg-config --cflags hdf5-serial 2>/dev/null || pkg-config --cflags hdf5 2>/dev/null)
14+
HDF5_LDFLAGS := $(shell pkg-config --libs-only-L hdf5-serial 2>/dev/null || pkg-config --libs-only-L hdf5 2>/dev/null)
15+
16+
## OpenMP multithreading
17+
ITENSOR_USE_OMP=1
18+
19+
## Optimization flags
20+
OPTIMIZATIONS=-O2 -DNDEBUG -Wall -Wno-unknown-pragmas
21+
22+
## Debug flags
23+
DEBUGFLAGS=-DDEBUG -g -Wall -Wno-unknown-pragmas -pedantic
24+
25+
## Do not build dynamic libraries (static linking is simpler in CI)
26+
ITENSOR_MAKE_DYLIB=0
27+
28+
###
29+
### Remaining variables are derived; no need to modify below.
30+
###
31+
32+
PREFIX=$(THIS_DIR)
33+
34+
ITENSOR_LIBDIR=$(PREFIX)/lib
35+
ITENSOR_INCLUDEDIR=$(PREFIX)
36+
37+
ITENSOR_LIBNAMES=itensor
38+
ITENSOR_LIBFLAGS=$(patsubst %,-l%, $(ITENSOR_LIBNAMES))
39+
ITENSOR_LIBFLAGS+= $(BLAS_LAPACK_LIBFLAGS)
40+
ITENSOR_LIBGFLAGS=$(patsubst %,-l%-g, $(ITENSOR_LIBNAMES))
41+
ITENSOR_LIBGFLAGS+= $(BLAS_LAPACK_LIBFLAGS)
42+
ITENSOR_LIBS=$(patsubst %,$(ITENSOR_LIBDIR)/lib%.a, $(ITENSOR_LIBNAMES))
43+
ITENSOR_GLIBS=$(patsubst %,$(ITENSOR_LIBDIR)/lib%-g.a, $(ITENSOR_LIBNAMES))
44+
45+
ITENSOR_INCLUDEFLAGS=-I'$(ITENSOR_INCLUDEDIR)' $(BLAS_LAPACK_INCLUDEFLAGS)
46+
47+
ifneq ($(strip $(HDF5_CFLAGS)),)
48+
ITENSOR_USE_HDF5 = 1
49+
# -DH5_USE_110_API: use HDF5 1.10-compatible API on HDF5 >= 1.12, which changed
50+
# H5Oget_info_by_name to a 5-argument form incompatible with ITensor's h5 utility code.
51+
ITENSOR_INCLUDEFLAGS += $(HDF5_CFLAGS) -DITENSOR_USE_HDF5 -DH5_USE_110_API
52+
ITENSOR_LIBFLAGS += $(HDF5_LDFLAGS) -lhdf5 -lhdf5_hl
53+
ITENSOR_LIBGFLAGS += $(HDF5_LDFLAGS) -lhdf5 -lhdf5_hl
54+
endif
55+
56+
ifndef CCCOM
57+
$(error Makefile variable CCCOM not defined in options.mk; please define it.)
58+
endif
59+
60+
ifdef ITENSOR_USE_OMP
61+
ITENSOR_INCLUDEFLAGS += -DITENSOR_USE_OMP -fopenmp
62+
ITENSOR_LIBFLAGS += -fopenmp
63+
ITENSOR_LIBGFLAGS += -fopenmp
64+
endif
65+
66+
CCFLAGS=-I. $(ITENSOR_INCLUDEFLAGS) $(OPTIMIZATIONS) -Wno-unused-variable
67+
CCGFLAGS=-I. $(ITENSOR_INCLUDEFLAGS) $(DEBUGFLAGS)
68+
LIBFLAGS=-L'$(ITENSOR_LIBDIR)' $(ITENSOR_LIBFLAGS)
69+
LIBGFLAGS=-L'$(ITENSOR_LIBDIR)' $(ITENSOR_LIBGFLAGS)
70+
71+
## Determine shared library extension
72+
UNAME_S := $(shell uname -s)
73+
ifeq ($(UNAME_S),Darwin)
74+
DYLIB_EXT ?= dylib
75+
DYLIB_FLAGS ?= -dynamiclib
76+
else
77+
DYLIB_EXT ?= so
78+
DYLIB_FLAGS ?= -shared
79+
endif

.github/workflows/linuxWF.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ jobs:
6868
6969
# the flags above enable the use of both libmetatomic and libtorch
7070
echo "PLUMED_CONFIG=$PLUMED_CONFIG --enable-libmetatomic --enable-libtorch" >> $GITHUB_ENV
71+
- name: Install ITensor
72+
if: ${{ contains( matrix.variant, '-mpi-' ) && ! contains( matrix.variant, '-debug-' ) }}
73+
run: |
74+
.ci/install.itensor
75+
- name: Configure ITensor
76+
# exclude debug builds: _GLIBCXX_DEBUG changes the STL ABI and is incompatible
77+
# with libitensor.a (built without that flag), causing compilation errors in
78+
# ITensor headers and runtime corruption. The #ifdef __PLUMED_HAS_LIBITENSOR
79+
# guards in ttsketch ensure safe compilation when ITensor is not configured.
80+
if: ${{ contains( matrix.variant, '-mpi-' ) && ! contains( matrix.variant, '-debug-' ) && ! contains( matrix.variant, '-nvhpc-' ) }}
81+
run: |
82+
ITENSOR_DIR="$HOME/opt/itensor"
83+
HDF5_CFLAGS=$(pkg-config --cflags hdf5-serial 2>/dev/null || pkg-config --cflags hdf5 2>/dev/null || echo "-I/usr/include/hdf5/serial")
84+
HDF5_LIBDIR=$(pkg-config hdf5-serial --libs-only-L 2>/dev/null || pkg-config hdf5 --libs-only-L 2>/dev/null || echo "-L/usr/lib/x86_64-linux-gnu/hdf5/serial")
85+
echo "LDFLAGS=$LDFLAGS -L${ITENSOR_DIR}/lib ${HDF5_LIBDIR}" >> $GITHUB_ENV
86+
echo "CPPFLAGS=$CPPFLAGS -I${ITENSOR_DIR} ${HDF5_CFLAGS} -DITENSOR_USE_HDF5 -DITENSOR_USE_OMP -D__ITENSOR_LAPACK_WRAP_h -DH5_USE_110_API" >> $GITHUB_ENV
87+
echo "PLUMED_CONFIG=$PLUMED_CONFIG --enable-libitensor" >> $GITHUB_ENV
7188
- name: Install tools for setting up the manuals
7289
if: contains( matrix.variant, '-doc-' )
7390
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ makefile.dep
2727
__pycache__
2828
#to not export personal pyenv settings
2929
.python-version
30-
30+
.vscode
31+
.claude

0 commit comments

Comments
 (0)