#------------------------------------------------------------------------------- # SPEX/Tcov/Makefile: compile and run SPEX test coverage #------------------------------------------------------------------------------- # SPEX: (c) 2019-2024, Chris Lourenco, Jinhao Chen, # Lorena Mejia Domenzain, Erick Moreno-Centeno, and Timothy A. Davis. # All Rights Reserved. # SPDX-License-Identifier: GPL-2.0-or-later or LGPL-3.0-or-later #------------------------------------------------------------------------------- default: cov SUITESPARSE ?= $(realpath $(CURDIR)/../..) ################################################################################ # configured by CMake: INC = @SPEX_INCS@ LIBS = ../../SuiteSparse_config/build/libsuitesparseconfig.so \ ../../AMD/build/libamd.so \ ../../COLAMD/build/libcolamd.so \ @SPEX_LIBS@ SUITESPARSE_CONFIG_PATH = @SUITESPARSE_CONFIG_PATH@ COLAMD_PATH = @COLAMD_PATH@ AMD_PATH = @AMD_PATH@ GMP_PATH = @GMP_PATH@ MPFR_PATH = @MPFR_PATH@ ################################################################################ # use 8 jobs by default JOBS ?= 8 LDFLAGS = --coverage LDFLAGS += -Wl,-rpath=$(SUITESPARSE_CONFIG_PATH):$(AMD_PATH):$(COLAMD_PATH):$(GMP_PATH):$(MPFR_PATH) # remove object files, but keep compiled libraries via 'make clean' CLEAN = *.o *.obj *.ln *.bb *.bbg *.da *.tcov *.gcov gmon.out *.bak *.d \ *.gcda *.gcno *.aux *.bbl *.blg *.log *.toc *.dvi *.lof *.lot # also remove compiled libraries, via 'make distclean' PURGE = *.so* *.a *.dll *.dylib *.dSYM ################################################################################ # select the thread-safety mechanism to test: none, openmp, etc # none: # THREADS = # opemp: # THREADS = -fopenmp # __thread keyword (gcc and many compilers): THREADS = -DHAVE_KEYWORD__THREAD # Linux test coverage (gcc is required for test coverage) CC = gcc CFLAGS = -g -fprofile-arcs -ftest-coverage \ -Wall -W -Wshadow -Wmissing-prototypes -Wstrict-prototypes \ -Wredundant-decls -Wnested-externs -Wdisabled-optimization -std=c99 \ -Wno-unused-parameter \ $(INC) -I../Demo \ -DSPEX_GMP_LIST_INIT=2 -DSPEX_GMP_TEST_COVERAGE $(THREADS) # run all statement coverage tests, and then check for 100% coverage cov: runtests ./covall all: tcov_for_lu spex_demo_lu_extended tcov_for_cholesky tcov_for_lu2 \ tcov_for_other #------------------------------------------------------------------------------- # compile .c file in this folder OBJ_Tcov = tcov_utilities.o $(OBJ_Tcov): tcov_utilities.h #------------------------------------------------------------------------------- # link and compile each .c file in SPEX_Utilities/Source OBJ_Util = \ SPEX_version.o \ SPEX_calloc.o \ spex_cast_array.o \ spex_cast_matrix.o \ SPEX_create_default_options.o \ spex_create_mpfr_array.o \ spex_create_mpq_array.o \ spex_create_mpz_array.o \ spex_free_mpfr_array.o \ spex_free_mpq_array.o \ spex_free_mpz_array.o \ spex_cumsum.o \ spex_expand_double_array.o \ spex_expand_mpfr_array.o \ spex_expand_mpq_array.o \ SPEX_finalize.o \ SPEX_free.o \ SPEX_gmp.o \ SPEX_initialize.o \ SPEX_initialize_expert.o \ SPEX_malloc.o \ SPEX_matrix_allocate.o \ SPEX_matrix_check.o \ SPEX_matrix_copy.o \ SPEX_matrix_free.o \ spex_matrix_mul.o \ SPEX_matrix_nnz.o \ spex_permute_dense_matrix.o \ SPEX_realloc.o \ spex_sparse_collapse.o \ spex_sparse_realloc.o \ SPEX_symbolic_analysis_free.o \ SPEX_factorization_free.o \ SPEX_determine_symmetry.o \ SPEX_transpose.o \ spex_amd.o \ spex_colamd.o $(OBJ_Util): ../Include/SPEX.h ../SPEX_Utilities/Source/spex_util_internal.h .PRECIOUS: SPEX_%.c spex_%.c SPEX_%.c: - ln -s ../SPEX_Utilities/Source/$@ spex_%.c: - ln -s ../SPEX_Utilities/Source/$@ #------------------------------------------------------------------------------- # link and compile each .c file in SPEX_LU/Source OBJ_LU = \ SPEX_lu_analyze.o \ SPEX_lu_backslash.o \ spex_left_lu_back_sub.o \ spex_left_lu_dfs.o \ SPEX_lu_factorize.o \ spex_left_lu_forward_sub.o \ spex_left_lu_get_largest_pivot.o \ spex_left_lu_get_nonzero_pivot.o \ spex_left_lu_get_pivot.o \ spex_left_lu_get_smallest_pivot.o \ spex_left_lu_reach.o \ spex_left_lu_ref_triangular_solve.o \ SPEX_lu_solve.o .PRECIOUS: SPEX_lu_%.c SPEX_lu_%.c spex_left_lu_%.c SPEX_lu_%.c: - ln -s ../SPEX_LU/Source/$@ SPEX_lu_%.c: - ln -s ../SPEX_LU/Source/$@ spex_left_lu_%.c: - ln -s ../SPEX_LU/Source/$@ #------------------------------------------------------------------------------- # compile each .c file in Demo/Utilities DEMO_SRC = \ ../Demo/Utilities/spex_demo_check_solution.c \ ../Demo/Utilities/spex_demo_determine_error.c \ ../Demo/Utilities/spex_demo_process_command_line.c \ ../Demo/Utilities/spex_demo_read_dense.c \ ../Demo/Utilities/spex_demo_tripread.c #------------------------------------------------------------------------------- # link and compile each .c file in SPEX_Cholesky/Source OBJ_Cholesky = \ SPEX_cholesky_analyze.o \ SPEX_cholesky_backslash.o \ spex_cholesky_backward_sub.o \ spex_cholesky_counts.o \ spex_cholesky_ereach.o \ spex_cholesky_etree.o \ spex_cholesky_factor.o \ SPEX_cholesky_factorize.o \ spex_cholesky_forward_sub.o \ spex_cholesky_leaf.o \ spex_cholesky_left_factor.o \ spex_cholesky_left_triangular_solve.o \ spex_cholesky_permute_A.o \ spex_cholesky_post.o \ spex_cholesky_pre_left_factor.o \ spex_cholesky_preorder.o \ SPEX_cholesky_solve.o \ spex_cholesky_symbolic_analysis.o \ spex_cholesky_tdfs.o \ spex_cholesky_up_factor.o \ spex_cholesky_up_triangular_solve.o $(OBJ_Cholesky): ../Include/SPEX.h .PRECIOUS: SPEX_cholesky_%.c spex_cholesky_%.c SPEX_cholesky_%.c: - ln -s ../SPEX_Cholesky/Source/$@ spex_cholesky_%.c: - ln -s ../SPEX_Cholesky/Source/$@ #chol_demos.c: # - ln -s ../SPEX_Cholesky/Demo/$@ #------------------------------------------------------------------------------- tcov_for_lu: $(OBJ_Tcov) $(OBJ_Util) $(OBJ_LU) tcov_for_lu.c $(CC) $(LDFLAGS) tcov_for_lu.c $(CFLAGS) -o tcov_for_lu $(OBJ_Tcov) $(OBJ_Util) $(OBJ_LU) $(LIBS) tcov_for_lu2: $(OBJ_Tcov) $(OBJ_Util) $(OBJ_Cholesky) tcov_for_lu2.c simple_rand.c simple_rand.h $(DEMO_SRC) $(CC) $(LDFLAGS) $(CFLAGS) tcov_for_lu2.c simple_rand.c $(DEMO_SRC) -o tcov_for_lu2 $(OBJ_Tcov) $(OBJ_Util) $(OBJ_LU) $(LIBS) spex_demo_lu_extended: $(OBJ_Util) $(OBJ_LU) ../Demo/spex_demo_lu_extended.c $(DEMO_SRC) ../Demo/spex_demos.h $(CC) $(LDFLAGS) ../Demo/spex_demo_lu_extended.c $(DEMO_SRC) $(CFLAGS) -o spex_demo_lu_extended $(OBJ_Tcov) $(OBJ_Util) $(OBJ_LU) $(LIBS) tcov_for_cholesky: $(OBJ_Tcov) $(OBJ_Util) $(OBJ_Cholesky) tcov_for_cholesky.c simple_rand.c simple_rand.h $(DEMO_SRC) $(CC) $(LDFLAGS) $(CFLAGS) tcov_for_cholesky.c simple_rand.c $(DEMO_SRC) -o tcov_for_cholesky $(OBJ_Tcov) $(OBJ_Util) $(OBJ_Cholesky) $(LIBS) tcov_for_other: $(OBJ_Tcov) $(OBJ_Util) $(OBJ_LU) tcov_for_other.c $(CC) $(LDFLAGS) tcov_for_other.c $(CFLAGS) -o tcov_for_other $(OBJ_Tcov) $(OBJ_Util) $(OBJ_LU) $(LIBS) #------------------------------------------------------------------------------- # run all statement coverage tests runtests: runtests4llu runtests4chol # only run test for SPEX_LU runtests4llu: all ./tcov_for_other ./spex_demo_lu_extended q 1 f ../ExampleMats/10teams.mat.txt ../ExampleMats/10teams.rhs.txt > lu1.out ./spex_demo_lu_extended q 2 o 1 f ../ExampleMats/10teams.mat.txt ../ExampleMats/10teams.rhs.txt > lu2.out ./spex_demo_lu_extended q 3 o 1 f ../ExampleMats/test.mat.txt ../ExampleMats/test.rhs.txt > lu3.out ./spex_demo_lu_extended f ../ExampleMats/10teams.mat.txt ../ExampleMats/10teams.rhs.txt > lu4.out ./tcov_for_lu > test_for_lu.out ./tcov_for_lu 0 1 1 > lu5.out ./tcov_for_lu2 ../ExampleMats/Trefethen_500.mat.txt ../ExampleMats/Trefethen_500.rhs.txt > test_for_lu2.out # only run test for SPEX_Cholesky runtests4chol: all ./tcov_for_cholesky ../ExampleMats/mesh1e1.mat.txt ../ExampleMats/mesh1e1.rhs.txt > test_for_cholesky.out #------------------------------------------------------------------------------- # To run with valgrind: # V = valgrind V = valgrind --leak-check=full --show-leak-kinds=all # run all statement coverage tests but with valgrind vtests: vtests4llu vtests4chol # run test for SPEX_LU with valgrind vtests4llu: all $(V) ./tcov_for_other $(V) ./spex_demo_lu_extended q 1 f ../ExampleMats/10teams.mat.txt ../ExampleMats/10teams.rhs.txt > lu1.out $(V) ./spex_demo_lu_extended q 2 o 1 f ../ExampleMats/10teams.mat.txt ../ExampleMats/10teams.rhs.txt > lu2.out $(V) ./spex_demo_lu_extended q 3 o 1 f ../ExampleMats/test.mat.txt ../ExampleMats/test.rhs.txt > lu3.out $(V) ./spex_demo_lu_extended f ../ExampleMats/10teams.mat.txt ../ExampleMats/10teams.rhs.txt > lu4.out $(V) ./tcov_for_lu > test_for_lu.out $(V) ./tcov_for_lu 0 1 1 > lu5.out $(V) ./tcov_for_lu2 ../ExampleMats/Trefethen_500.mat.txt ../ExampleMats/Trefethen_500.rhs.txt > test_for_lu2.out vtest2: all $(V) ./tcov_for_lu2 ../ExampleMats/Trefethen_500.mat.txt ../ExampleMats/Trefethen_500.rhs.txt > test_for_lu2.out # run test for SPEX_Cholesky with valgrind vtests4chol: all $(V) ./tcov_for_cholesky ../ExampleMats/mesh1e1.mat.txt ../ExampleMats/mesh1e1.rhs.txt > test_for_cholesky.out #------------------------------------------------------------------------------- # remove all files not in the original distribution, including symbolic links clean: - $(RM) *.o *.bbg *.da *.gcov *.gcda *gcno - $(RM) tcov_for_lu spex_demo_lu_extended *.out *.a out tcov_for_lu2 tcov_for_other - $(RM) -r SPEX_*.c spex_*.c *.dSYM - $(RM) -r tcov_for_cholesky purge: distclean distclean: clean