|
| 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 |
0 commit comments