Skip to content

Commit

Permalink
The below merge includes commits made on the model_trainer branch, lo…
Browse files Browse the repository at this point in the history
…gs below

Merge github.com:cyclops-community/ctf into model_training_no_log

    fully get rid of active switch

    fix a few minor memory leaks

    extract unused code from model and get mode_trainer working for non power of 2 processor counts

    address compiler warning

    disable folding for sparse * dense contraction with a Hadamard index, which corrects behavior for that case. Broaden the amount of information given by print_map()

    work on merging, including formatting fixes, separating out new code under ifdef TUNE. Normal execution seems to work, model_trainer build with -DTUNE crashes though

    Merge branch 'master' into model_training
  • Loading branch information
solomonik committed Jun 13, 2018
2 parents afdb6b0 + 9d7eb1e commit 5168ef3
Show file tree
Hide file tree
Showing 160 changed files with 12,621 additions and 2,943 deletions.
14 changes: 10 additions & 4 deletions .gitignore
@@ -1,9 +1,15 @@
# Build directories
*.o
lib
lib_shared
lib_python
obj
obj_ext
obj_shared
bin

# Autogenerated in first invocation of configure
config.mk
setup.py
how-did-i-configure

# Ignore the .DS_Store
.DS_Store
.*.swp
.*.swo
58 changes: 36 additions & 22 deletions .travis.yml
@@ -1,43 +1,57 @@
sudo: false
language: cpp
os:
- linux
# - osx
compiler:
- gcc
- clang
#env:
#matrix:
os: linux
language: python
python:
- "2.7"
- "3.5"
- "3.6"
env:
- CTF_CXX=clang++
- CTF_CXX=g++

addons:
apt:
sources:
- ubuntu-toolchain-r-test
#- llvm-toolchain-precise-3.7
packages:
- gcc-5
- g++-5
- gfortran-5
- libopenmpi-dev
- libgfortran-5-dev
- libblas-dev
- liblapack-dev
- mpich2
- libmpich2-dev
- cmake
before_install:
- pwd
- export TRAVIS_HOME=$PWD
- export PATH=$TRAVIS_HOME/deps/bin:$PATH
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]] || [[ "$TRAVIS_PYTHON_VERSION" == "2.6" ]] ; then
export PYTHONMAJORV=2;
else
export PYTHONMAJORV=3;
fi
- wget https://repo.continuum.io/miniconda/Miniconda${PYTHONMAJORV}-latest-Linux-x86_64.sh
- bash Miniconda${PYTHONMAJORV}-latest-Linux-x86_64.sh -b
- export PATH=$HOME/miniconda${PYTHONMAJORV}/bin:$PATH
- conda create -y -n mypy python=$TRAVIS_PYTHON_VERSION
- source activate mypy
- conda install -y cython
- conda install -y numpy
install:
- mkdir -p $TRAVIS_HOME/deps
- sh ./travis/install-mpi.sh $TRAVIS_HOME/deps mpich
before_script:
- which mpicxx ; mpicxx -v
- ./configure CXX=mpicxx
- $CTF_CXX --version
- FC=gfortran-5 ./configure CXX="mpicxx -cxx=$CTF_CXX" --build-hptt --build-scalapack
- make -j2
- make python -j2
script:
- make
- make test
- make test2
#after_failure:
- make python_test
- make python_test2
after_failure:
notifications:
email:
recipients:
- jeff.science@gmail.com
- solomon2@illinois.edu
on_success: change
on_failure: always


198 changes: 160 additions & 38 deletions Makefile
Expand Up @@ -4,25 +4,50 @@ ifeq (,${BDIR})
endif
export BDIR
export ODIR=$(BDIR)/obj
export OEDIR=$(BDIR)/obj_ext
include $(BDIR)/config.mk
export FCXX
export OFFLOAD_CXX
export LIBS

all: $(BDIR)/lib/libctf.a
all: $(BDIR)/lib/libctf.a $(BDIR)/lib_shared/libctf.so


EXAMPLES = algebraic_multigrid apsp bitonic_sort btwn_central ccsd checkpoint dft_3D fft force_integration force_integration_sparse jacobi matmul neural_network particle_interaction qinformatics recursive_matmul scan sparse_mp3 sparse_permuted_slice spectral_element spmv sssp strassen trace mis mis2 ao_mo_transf
TESTS = bivar_function bivar_transform ccsdt_map_test ccsdt_t3_to_t2 dft diag_ctr diag_sym endomorphism_cust endomorphism_cust_sp endomorphism gemm_4D multi_tsr_sym permute_multiworld readall_test readwrite_test repack scalar speye sptensor_sum subworld_gemm sy_times_ns test_suite univar_function weigh_4D
.PHONY: install
install: $(INSTALL_DIR)/lib/libctf.so

BENCHMARKS = bench_contraction bench_nosym_transp bench_redistribution model_trainer
$(INSTALL_DIR)/lib/libctf.so: $(BDIR)/lib/libctf.a $(BDIR)/lib_shared/libctf.so
if [ -d hptt ]; then \
echo "WARNING: detected HPTT installation in hptt/, you might need to also install it manually separately."; \
fi
if [ -d scalapack ]; then \
echo "WARNING: detected ScaLAPACK installation in scalapack/, you might need to also install it manually separately."; \
fi
cp $(BDIR)/lib/libctf.a $(INSTALL_DIR)/lib
cp $(BDIR)/lib_shared/libctf.so $(INSTALL_DIR)/lib
cd src/scripts && bash ./expand_includes.sh && cd ..
mv include/ctf_all.hpp $(INSTALL_DIR)/include/ctf.hpp

SCALAPACK_TESTS = nonsq_pgemm_test nonsq_pgemm_bench
.PHONY: uninstall
uninstall:
rm $(INSTALL_DIR)/lib/libctf.a
rm $(INSTALL_DIR)/lib/libctf.so
rm $(INSTALL_DIR)/include/ctf.hpp


EXAMPLES = algebraic_multigrid apsp bitonic_sort btwn_central ccsd checkpoint dft_3D fft force_integration force_integration_sparse jacobi matmul neural_network particle_interaction qinformatics recursive_matmul scan sparse_mp3 sparse_permuted_slice spectral_element spmv sssp strassen trace mis mis2 ao_mo_transf block_sparse
TESTS = bivar_function bivar_transform ccsdt_map_test ccsdt_t3_to_t2 dft diag_ctr diag_sym endomorphism_cust endomorphism_cust_sp endomorphism gemm_4D multi_tsr_sym permute_multiworld readall_test readwrite_test repack scalar speye sptensor_sum subworld_gemm sy_times_ns test_suite univar_function weigh_4D reduce_bcast


BENCHMARKS = bench_contraction bench_nosym_transp bench_redistribution model_trainer

SCALAPACK_TESTS = nonsq_pgemm_test nonsq_pgemm_bench hosvd qr svd

STUDIES = fast_diagram fast_3mm fast_sym fast_sym_4D \
fast_tensor_ctr fast_sy_as_as_tensor_ctr fast_as_as_sy_tensor_ctr

EXECUTABLES = $(EXAMPLES) $(TESTS) $(BENCHMARKS) $(SCALAPACK_TESTS) $(STUDIES)
EXECUTABLES = $(EXAMPLES) $(TESTS) $(BENCHMARKS) $(SCALAPACK_TESTS) $(STUDIES)


export EXAMPLES
export TESTS
Expand All @@ -32,7 +57,6 @@ export STUDIES




.PHONY: executables
executables: $(EXECUTABLES)
$(EXECUTABLES): $(BDIR)/lib/libctf.a
Expand All @@ -53,8 +77,6 @@ scalapack_tests: $(SCALAPACK_TESTS)
$(SCALAPACK_TESTS):
$(MAKE) $@ -C scalapack_tests



.PHONY: bench
bench: $(BENCHMARKS)
$(BENCHMARKS):
Expand All @@ -73,55 +95,153 @@ ctf_objs:
ctflib: ctf_objs
$(AR) -crs $(BDIR)/lib/libctf.a $(ODIR)/*.o;

ctf_ext_objs:
$(MAKE) ctf_ext_objs -C src_python;

.PHONY: shared
shared: ctflibso
.PHONY: ctflibso
ctflibso: export FCXX+=-fPIC
ctflibso: export OFFLOAD_CXX+=-fPIC
ctflibso: export ODIR=$(BDIR)/obj_shared
ctflibso: ctf_objs
$(FCXX) -shared -o $(BDIR)/lib_shared/libctf.so $(ODIR)/*.o;
ctflibso: ctf_objs ctf_ext_objs
$(FCXX) -shared -o $(BDIR)/lib_shared/libctf.so $(ODIR)/*.o $(OEDIR)/*.o $(SO_LIB_PATH) $(SO_LIB_FILES) $(LDFLAGS)


PYTHON_SRC_FILES=src_python/ctf/core.pyx src_python/ctf/random.pyx

.PHONY: python
python: pylib
.PHONY: pylib
pylib: lib_py/ctf.so
lib_py/ctf.so: ctflibso src_python/ctf.pyx
LDFLAGS="-L./lib_shared" python setup_wrapper.py build_ext --inplace && mv ctf.so lib_py/
python: $(BDIR)/lib_python/ctf/core.o

$(BDIR)/lib_python/ctf/core.o: $(BDIR)/setup.py $(BDIR)/lib_shared/libctf.so $(PYTHON_SRC_FILES)
cd src_python; \
ln -sf $(BDIR)/setup.py setup.py; \
mkdir -p $(BDIR)/lib_python/ctf && cp ctf/__init__.py $(BDIR)/lib_python/ctf/; \
LDFLAGS="-L$(BDIR)/lib_shared" python setup.py build_ext --force -b $(BDIR)/lib_python/ -t $(BDIR)/lib_python/; \
rm setup.py; \
cd ..;


.PHONY: python_install
python_install: $(INSTALL_DIR)/lib/libctf.so pip
.PHONY: pip
pip: $(BDIR)/setup.py $(BDIR)/lib_shared/libctf.so $(PYTHON_SRC_FILES)
cd src_python; \
ln -sf $(BDIR)/setup.py setup.py; \
mkdir -p $(BDIR)/lib_python/ctf && cp ctf/__init__.py $(BDIR)/lib_python/ctf/; \
pip install --force -b $(BDIR)/lib_python/ . --upgrade; \
rm setup.py; \
cd ..;

.PHONY: python_uninstall
python_uninstall:
pip uninstall ctf

.PHONY: python_test
.NOTPARALLEL: python_test
ifneq (,$(findstring USE_SCALAPACK,$(DEFS)))
python_test: python_base_test python_fancyindex_test python_einsum_test python_ufunc_test python_dot_test python_la_test
echo "Cyclops Python tests completed."
else
python_test: python_base_test python_fancyindex_test python_einsum_test python_ufunc_test python_dot_test
echo "Cyclops Python tests completed."
endif

.PHONY: python_test%
.NOTPARALLEL: python_test%
ifneq (,$(findstring USE_SCALAPACK,$(DEFS)))
python_test%: python_base_test% python_fancyindex_test% python_einsum_test% python_ufunc_test% python_dot_test% python_la_test%
echo "Cyclops Python tests completed."
else
python_test%: python_base_test% python_fancyindex_test% python_einsum_test% python_ufunc_test% python_dot_test%
echo "Cyclops Python tests completed."
endif

.PHONY: python_einsum_test
python_einsum_test: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" python ./test/python/test_einsum.py

.PHONY: test_python
test_python: lib_py/ctf.so
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):./lib_shared" PYTHONPATH="./lib_py" python ./test/python/test_wrapper.py
.PHONY: python_einsum_test%
python_einsum_test%: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" mpirun -np $* python ./test/python/test_einsum.py

$(BDIR)/lib/libctf.a: src/*/*.cu src/*/*.cxx src/*/*.h Makefile src/Makefile src/*/Makefile $(BDIR)/config.mk
.PHONY: python_ufunc_test
python_ufunc_test: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" python ./test/python/test_ufunc.py

.PHONY: python_ufunc_test%
python_ufunc_test%: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" mpirun -np $* python ./test/python/test_ufunc.py

.PHONY: python_fancyindex_test
python_fancyindex_test: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" python ./test/python/test_fancyindex.py

.PHONY: python_fancyindex_test%
python_fancyindex_test%: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" mpirun -np $* python ./test/python/test_fancyindex.py

.PHONY: python_base_test
python_base_test: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" python ./test/python/test_base.py

.PHONY: python_base_test%
python_base_test%: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" mpirun -np $* python ./test/python/test_base.py

.PHONY: python_la_test
python_la_test: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" python ./test/python/test_la.py;

.PHONY: python_la_test%
python_la_test%: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" mpirun -np $* python ./test/python/test_la.py;

.PHONY: python_dot_test
python_dot_test: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" python ./test/python/test_dot.py;

.PHONY: python_dot_test%
python_dot_test%: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" mpirun -np $* python ./test/python/test_dot.py;


.PHONY: test_live
test_live: $(BDIR)/lib_python/ctf/core.o
LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(BDIR)/lib_shared:$(BDIR)/lib_python:$(LD_LIB_PATH)" PYTHONPATH="$(PYTHONPATH):$(BDIR)/lib_python" ipython -i -c "import numpy as np; import ctf"


$(BDIR)/lib/libctf.a: src/*/*.cu src/*/*.cxx src/*/*.h src/Makefile src/*/Makefile $(BDIR)/config.mk src_python/ctf_ext.cxx src_python/ctf_ext.h
$(MAKE) ctflib

$(BDIR)/lib/libctf.so: src/*/*.cu src/*/*.cxx src/*/*.h Makefile src/Makefile src/*/Makefile $(BDIR)/config.mk
$(BDIR)/lib_shared/libctf.so: src/*/*.cu src/*/*.cxx src/*/*.h src/Makefile src/*/Makefile $(BDIR)/config.mk src_python/ctf_ext.cxx src_python/ctf_ext.h
$(MAKE) ctflibso

clean: clean_bin clean_lib clean_obj


test: test_suite
$(BDIR)/bin/test_suite

test2: test_suite
mpirun -np 2 $(BDIR)/bin/test_suite

test3: test_suite
mpirun -np 3 $(BDIR)/bin/test_suite
.PHONY: test%
test%: test_suite
mpirun -np $* $(BDIR)/bin/test_suite

test4: test_suite
mpirun -np 4 $(BDIR)/bin/test_suite

test6: test_suite
mpirun -np 6 $(BDIR)/bin/test_suite
clean: clean_bin clean_lib clean_obj clean_py

test7: test_suite
mpirun -np 7 $(BDIR)/bin/test_suite
clean_py:
rm -f $(BDIR)/src_python/ctf/core.*so
rm -f $(BDIR)/src_python/ctf/random.*so
rm -f $(BDIR)/bin/test_suite
rm -f $(BDIR)/src_python/ctf/core.cpp
rm -f $(BDIR)/src_python/ctf/random.cpp
rm -rf $(BDIR)/src_python/build
rm -rf $(BDIR)/src_python/__pycache__
rm -rf $(BDIR)/src_python/ctf/__pycache__
rm -f $(BDIR)/lib_python/ctf/core.o
rm -f $(BDIR)/lib_python/ctf/random.o
rm -f $(BDIR)/lib_python/ctf/core.*so
rm -f $(BDIR)/lib_python/ctf/random.*so
rm -rf $(BDIR)/lib_python/ctf/__pycache__

test8: test_suite
mpirun -np 8 $(BDIR)/bin/test_suite

clean_bin:
for comp in $(EXECUTABLES) ; do \
Expand All @@ -131,9 +251,11 @@ clean_bin:
clean_lib:
rm -f $(BDIR)/lib/libctf.a
rm -f $(BDIR)/lib_shared/libctf.so
rm -f $(BDIR)/lib_py/ctf.so
rm -f $(BDIR)/lib_shared/libctf_ext.so

clean_obj:
rm -f $(BDIR)/obj/*.o
rm -f $(BDIR)/obj_ext/*.o
rm -f $(BDIR)/obj_shared/*.o
rm -rf $(BDIR)/obj_shared/ctf/
rm -f $(BDIR)/build/*/*/*.o

0 comments on commit 5168ef3

Please sign in to comment.