Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .ci/install.itensor
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/env bash

set -e
set -x

# Directory containing this script (i.e. .ci/)
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Install ITensor v3 dependencies
sudo apt-get install -y libopenblas-dev libhdf5-dev

ITENSOR_VERSION=3.2.0
ITENSOR_INSTALL_DIR="$HOME/opt/itensor"

cd "$(mktemp -dt plumed.XXXXXX)"

wget https://github.com/ITensor/ITensor/archive/refs/tags/v${ITENSOR_VERSION}.tar.gz
tar xzf v${ITENSOR_VERSION}.tar.gz
cd ITensor-${ITENSOR_VERSION}

# Use the CI-specific options.mk (OpenBLAS + system HDF5)
cp "$CI_DIR/options.mk.itensor" options.mk

make

# Copy the built library and headers to the install directory
mkdir -p "$ITENSOR_INSTALL_DIR"
cp -r lib "$ITENSOR_INSTALL_DIR/"
cp -r itensor "$ITENSOR_INSTALL_DIR/"
79 changes: 79 additions & 0 deletions .ci/options.mk.itensor
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
### CI-specific options.mk for ITensor v3
### Uses OpenBLAS and system HDF5 (installed via apt on ubuntu-22.04).
### Copy this file to the ITensor source directory as options.mk before building.

## Compiler
CCCOM=g++ -m64 -std=c++17 -fconcepts -fPIC

## BLAS/LAPACK: use OpenBLAS (apt install libopenblas-dev)
PLATFORM=lapack
BLAS_LAPACK_LIBFLAGS=-lpthread -lopenblas

## HDF5
HDF5_CFLAGS := $(shell pkg-config --cflags hdf5-serial 2>/dev/null || pkg-config --cflags hdf5 2>/dev/null)
HDF5_LDFLAGS := $(shell pkg-config --libs-only-L hdf5-serial 2>/dev/null || pkg-config --libs-only-L hdf5 2>/dev/null)

## OpenMP multithreading
ITENSOR_USE_OMP=1

## Optimization flags
OPTIMIZATIONS=-O2 -DNDEBUG -Wall -Wno-unknown-pragmas

## Debug flags
DEBUGFLAGS=-DDEBUG -g -Wall -Wno-unknown-pragmas -pedantic

## Do not build dynamic libraries (static linking is simpler in CI)
ITENSOR_MAKE_DYLIB=0

###
### Remaining variables are derived; no need to modify below.
###

PREFIX=$(THIS_DIR)

ITENSOR_LIBDIR=$(PREFIX)/lib
ITENSOR_INCLUDEDIR=$(PREFIX)

ITENSOR_LIBNAMES=itensor
ITENSOR_LIBFLAGS=$(patsubst %,-l%, $(ITENSOR_LIBNAMES))
ITENSOR_LIBFLAGS+= $(BLAS_LAPACK_LIBFLAGS)
ITENSOR_LIBGFLAGS=$(patsubst %,-l%-g, $(ITENSOR_LIBNAMES))
ITENSOR_LIBGFLAGS+= $(BLAS_LAPACK_LIBFLAGS)
ITENSOR_LIBS=$(patsubst %,$(ITENSOR_LIBDIR)/lib%.a, $(ITENSOR_LIBNAMES))
ITENSOR_GLIBS=$(patsubst %,$(ITENSOR_LIBDIR)/lib%-g.a, $(ITENSOR_LIBNAMES))

ITENSOR_INCLUDEFLAGS=-I'$(ITENSOR_INCLUDEDIR)' $(BLAS_LAPACK_INCLUDEFLAGS)

ifneq ($(strip $(HDF5_CFLAGS)),)
ITENSOR_USE_HDF5 = 1
# -DH5_USE_110_API: use HDF5 1.10-compatible API on HDF5 >= 1.12, which changed
# H5Oget_info_by_name to a 5-argument form incompatible with ITensor's h5 utility code.
ITENSOR_INCLUDEFLAGS += $(HDF5_CFLAGS) -DITENSOR_USE_HDF5 -DH5_USE_110_API
ITENSOR_LIBFLAGS += $(HDF5_LDFLAGS) -lhdf5 -lhdf5_hl
ITENSOR_LIBGFLAGS += $(HDF5_LDFLAGS) -lhdf5 -lhdf5_hl
endif

ifndef CCCOM
$(error Makefile variable CCCOM not defined in options.mk; please define it.)
endif

ifdef ITENSOR_USE_OMP
ITENSOR_INCLUDEFLAGS += -DITENSOR_USE_OMP -fopenmp
ITENSOR_LIBFLAGS += -fopenmp
ITENSOR_LIBGFLAGS += -fopenmp
endif

CCFLAGS=-I. $(ITENSOR_INCLUDEFLAGS) $(OPTIMIZATIONS) -Wno-unused-variable
CCGFLAGS=-I. $(ITENSOR_INCLUDEFLAGS) $(DEBUGFLAGS)
LIBFLAGS=-L'$(ITENSOR_LIBDIR)' $(ITENSOR_LIBFLAGS)
LIBGFLAGS=-L'$(ITENSOR_LIBDIR)' $(ITENSOR_LIBGFLAGS)

## Determine shared library extension
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
DYLIB_EXT ?= dylib
DYLIB_FLAGS ?= -dynamiclib
else
DYLIB_EXT ?= so
DYLIB_FLAGS ?= -shared
endif
17 changes: 17 additions & 0 deletions .github/workflows/linuxWF.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ jobs:

# the flags above enable the use of both libmetatomic and libtorch
echo "PLUMED_CONFIG=$PLUMED_CONFIG --enable-libmetatomic --enable-libtorch" >> $GITHUB_ENV
- name: Install ITensor
if: ${{ contains( matrix.variant, '-mpi-' ) }}
run: |
.ci/install.itensor
- name: Configure ITensor
# exclude debug builds: _GLIBCXX_DEBUG changes the STL ABI and is incompatible
# with libitensor.a (built without that flag), causing compilation errors in
# ITensor headers and runtime corruption. The #ifdef __PLUMED_HAS_LIBITENSOR
# guards in ttsketch ensure safe compilation when ITensor is not configured.
if: ${{ contains( matrix.variant, '-mpi-' ) && ! contains( matrix.variant, '-debug-' ) }}
run: |
ITENSOR_DIR="$HOME/opt/itensor"
HDF5_CFLAGS=$(pkg-config --cflags hdf5-serial 2>/dev/null || pkg-config --cflags hdf5 2>/dev/null || echo "-I/usr/include/hdf5/serial")
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")
echo "LDFLAGS=$LDFLAGS -L${ITENSOR_DIR}/lib ${HDF5_LIBDIR}" >> $GITHUB_ENV
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
echo "PLUMED_CONFIG=$PLUMED_CONFIG --enable-libitensor" >> $GITHUB_ENV
- name: Install tools for setting up the manuals
if: contains( matrix.variant, '-doc-' )
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ makefile.dep
__pycache__
#to not export personal pyenv settings
.python-version

.vscode
.claude
Loading
Loading