diff --git a/Makefile b/Makefile index a829df788..8b017c55a 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ check-env check-env-config check-env-fragments \ flat-headers \ test \ - install-headers install-libs install-lib-symlinks \ - clean cleanmk cleanh cleanlib cleanleaves distclean \ + install-headers install-libs install-lib-symlinks install-netlib-tests\ + clean cleanmk cleanh cleanlib cleanleaves distclean clean-netlib-tests \ install \ uninstall-libs uninstall-lib-symlinks uninstall-headers @@ -355,7 +355,12 @@ CFLAGS_NOOPT := $(CFLAGS_NOOPT) $(INCLUDE_PATHS) CPPFLAGS := $(CPPFLAGS) $(INCLUDE_PATHS) FFLAGS := $(FFLAGS) $(INCLUDE_PATHS) - +SCRIPTS_PATH := $(DIST_PATH)/src/map/common/lapacksrc/scripts +FDEPS_PATH := $(DIST_PATH)/src/map/common/lapacksrc/fortran +FDEPS1 := $(FDEPS_PATH)/la_constants.f90 +FDEPS2 := $(FDEPS_PATH)/la_xisnan.F90 +FDEPS := $(FDEPS1) $(FDEPS2) +FORT_EXT := %.f %.F %.f90 %.F90 # # --- Library object definitions ----------------------------------------------- @@ -383,8 +388,8 @@ MK_MAP_LAPACK2FLAMEC_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BAS MK_MAP_LAPACK2FLASH_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \ $(filter %.c, $(MK_MAP_LAPACK2FLASH_SRC))) -MK_MAP_FORTRAN_OBJS := $(patsubst $(SRC_PATH)/%.f, $(BASE_OBJ_PATH)/%.o, \ - $(filter %.f, $(MK_MAP_FORTRAN_SRC))) +MK_MAP_FORTRAN_OBJS := $(foreach F_EXT, $(FORT_EXT), $(patsubst $(SRC_PATH)/$(F_EXT), $(BASE_OBJ_PATH)/%.o, \ + $(filter $(FORT_EXT), $(filter-out $(FDEPS), $(MK_MAP_FORTRAN_SRC))))) MK_MAP_F2C_OBJS := $(patsubst $(SRC_PATH)/%.c, $(BASE_OBJ_PATH)/%.o, \ $(filter %.c, $(MK_MAP_F2C_SRC))) @@ -469,11 +474,11 @@ all: libs libs: libflame -install: libs install-libs install-lib-symlinks install-headers +install: libs install-libs install-lib-symlinks install-headers install-netlib-tests uninstall: uninstall-libs uninstall-lib-symlinks uninstall-headers -clean: cleanh cleanobj cleanlib +clean: cleanh cleanobj cleanlib clean-netlib-tests @@ -572,12 +577,37 @@ endif # Default Fortran compilation rules # Might need -fallow-argument-mismatch for newer gfortran (untested) -$(BASE_OBJ_PATH)/%.o: $(SRC_PATH)/%.f $(CONFIG_MK_FILE) $(HEADERS_TO_FLATTEN) +define fortran_rule +$$(BASE_OBJ_PATH)/%.o: $$(SRC_PATH)/$1 $$(CONFIG_MK_FILE) $$(HEADERS_TO_FLATTEN) $$(BASE_OBJ_PATH)/la_xisnan.mod +ifeq ($$(ENABLE_VERBOSE),yes) + $(FC) -cpp -c $$< -o $$@ +else + @echo "Compiling $$<" + @$(FC) -cpp -c $$< -o $$@ +endif +ifeq ($$(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) + @echo $$@ >> $$(AR_OBJ_LIST_FILE) +endif +endef +$(foreach FEXT, $(FORT_EXT), $(eval $(call fortran_rule,$(FEXT)))) + +$(BASE_OBJ_PATH)/la_xisnan.mod: $(FDEPS2) $(BASE_OBJ_PATH)/la_constants.mod ifeq ($(ENABLE_VERBOSE),yes) - $(F77) -cpp -c $< -o $@ + $(FC) -cpp -c $< -o $@ else - @echo "Compiling $<" - @$(F77) -cpp -c $< -o $@ + @echo "Building $<" + @$(FC) -cpp -c $< -o $@ +endif +ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) + @echo $@ >> $(AR_OBJ_LIST_FILE) +endif + +$(BASE_OBJ_PATH)/la_constants.mod: $(FDEPS1) +ifeq ($(ENABLE_VERBOSE),yes) + $(FC) -cpp -c $< -o $@ +else + @echo "Building $<" + @$(FC) -cpp -c $< -o $@ endif ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) @echo $@ >> $(AR_OBJ_LIST_FILE) @@ -784,6 +814,27 @@ else @$(MV) $(@F) $(INSTALL_LIBDIR)/ endif +# --- Install-netlibs-test dir --- + +install-netlib-tests: +ifeq ($(FLA_ENABLE_LEGACY_LAPACK),no) +ifeq ($(FLA_ENABLE_LAPACK2FLAME),yes) +ifeq ($(ENABLE_VERBOSE),yes) + $(SCRIPTS_PATH)/regen-files.sh build_test +else + @echo "Installing netlib-tests" + @$(SCRIPTS_PATH)/regen-files.sh build_test +endif +endif +ifeq ($(FLA_ENABLE_LAPACK2FLASH),yes) +ifeq ($(ENABLE_VERBOSE),yes) + $(SCRIPTS_PATH)/regen-files.sh build_test +else + @echo "Installing netlib-tests" + @$(SCRIPTS_PATH)/regen-files.sh build_test +endif +endif +endif # --- Clean rules --- @@ -891,6 +942,16 @@ else endif endif +clean-netlib-tests: +ifeq ($(IS_CONFIGURED),yes) +ifeq ($(ENABLE_VERBOSE),yes) + $(SCRIPTS_PATH)/regen-files.sh clean_test +else + @echo "Removing netlib-tests" + @$(SCRIPTS_PATH)/regen-files.sh clean_test +endif +endif + # --- Uninstall rules --- # NOTE: We can't write these uninstall rules directly in terms of targets diff --git a/build/config/leaf_list b/build/config/leaf_list index 5d234f553..eeda4d6da 100644 --- a/build/config/leaf_list +++ b/build/config/leaf_list @@ -6,5 +6,5 @@ lapack2flamec:c lapack2flash:c f2c:c lapackcheck:c -fortran:f +fortran:f,F,f90,F90 install:c \ No newline at end of file diff --git a/netlib-test/build/README b/netlib-test/build/README new file mode 100644 index 000000000..96112a926 --- /dev/null +++ b/netlib-test/build/README @@ -0,0 +1,23 @@ +This is a modified netlibs test suite that is using either the lapack2flame or lapack2flash interface. +This test suite is only built by the libflame makefile if one of these options are selected. +This test is removed in a 'make clean' is run on libflame + +Below is an example of how to run this test: +#ln -s ../../lib/x86_64-unknown-linux-gnu/libflame.so liblapack.so +#ln -s PATH_TO_YOUR_BLAS/libblis.so libblas.so +#export LD_LIBRARY_PATH=LOCATION_OF_YOUR_BLAS:LOCATION_OF_YOUR_LAPACK +#make -j + +This should result with something like the following results: + + --> LAPACK TESTING SUMMARY <-- + Processing LAPACK Testing output found in the TESTING directory +SUMMARY nb test run numerical error other error +================ =========== ================= ================ +REAL 1075089 2767 (0.257%) 0 (0.000%) +DOUBLE PRECISION 1198641 2694 (0.225%) 1 (0.000%) +COMPLEX 650845 169 (0.026%) 0 (0.000%) +COMPLEX16 783228 143 (0.018%) 0 (0.000%) + +--> ALL PRECISIONS 3707803 5773 (0.156%) 1 (0.000%) + diff --git a/netlib-test/build/SRC-Makefile b/netlib-test/build/SRC-Makefile index 652411295..fae13d2ac 100644 --- a/netlib-test/build/SRC-Makefile +++ b/netlib-test/build/SRC-Makefile @@ -1,17 +1,17 @@ -LAPACK_PRES := $(shell if [ -e ../liblapack.a ]; then echo "yes"; else echo "no"; fi) -BLAS_PRES := $(shell if [ -e ../libblas.a ]; then echo "yes"; else echo "no"; fi) +LAPACK_PRES := $(shell if [ -e ../liblapack.so ]; then echo "yes"; else echo "no"; fi) +BLAS_PRES := $(shell if [ -e ../libblas.so ]; then echo "yes"; else echo "no"; fi) all: ifeq ($(LAPACK_PRES),yes) - $(info Found 'liblapack.a'.) + $(info Found 'liblapack.so'.) else - $(error Missing liblapack.a. Cannot continue. Please create a symlink named 'liblapack.a' and then re-run 'make'.) + $(error Missing liblapack.so. Cannot continue. Please create a symlink named 'liblapack.so' and then re-run 'make'.) endif ifeq ($(BLAS_PRES),yes) - $(info Found 'libblas.a'.) + $(info Found 'libblas.so'.) else - $(error Missing libblas.a. Cannot continue. Please create a symlink named 'libblas.a' and then re-run 'make'.) + $(error Missing libblas.so. Cannot continue. Please create a symlink named 'libblas.so' and then re-run 'make'.) endif @echo "Netlib LAPACK test suite prerequisites present." diff --git a/netlib-test/create_new_testdir.sh b/netlib-test/create_new_testdir.sh index ffab2d27a..321ebcf67 100755 --- a/netlib-test/create_new_testdir.sh +++ b/netlib-test/create_new_testdir.sh @@ -55,8 +55,12 @@ main() # to libflame). #cp -p ${netlib_path}/make.inc.example ./${testdir_new}/make.inc cat ${netlib_path}/make.inc.example \ - | sed -e "s/liblapack\.a/liblapack\.a -lpthread/g" \ - | sed -e "s/librefblas\.a/libblas\.a/g" \ + | sed -e "s/liblapack\.a/liblapack\.so/g" \ + | sed -e "s/librefblas\.a/libblas\.so/g" \ + | sed -e "s/libtmglib\.a/libtmglib\.so/g" \ + | sed -e "s/AR = ar/AR = \$(CC)/g" \ + | sed -e "s/ARFLAGS = cr/ARFLAGS = -lm -shared/g" \ + | sed -e "s/RANLIB = ranlib/RANLIB = echo/g" \ > ./${testdir_new}/make.inc echo "Creating ./${testdir_new}/SRC" @@ -66,6 +70,9 @@ main() mkdir ./${testdir_new}/SRC cp ./build/SRC-Makefile ./${testdir_new}/SRC/Makefile + # Adding README + cp ./build/README ./${testdir_new}/ + # Make a dummy 'SRC/VARIANTS' directory with a dummy Makefile. mkdir ./${testdir_new}/SRC/VARIANTS cp ./build/SRC-VARIANTS-Makefile ./${testdir_new}/SRC/VARIANTS/Makefile @@ -103,6 +110,27 @@ main() sed -e "${sed_expr}" ${ddrvsg_in} > ${ddrvsg_ou} + # Update makefiles to have the correct path + # There was an issue where the path is given during linking + # as a relitive path. Then when run, it is executed from a different + # dir. This would cause it to fail + for make_file in BLAS/SRC/Makefile INSTALL/Makefile TESTING/Makefile TESTING/EIG/Makefile TESTING/LIN/Makefile TESTING/MATGEN/Makefile + do + sed -i 's/TOPSRCDIR = ../TOPSRCDIR = ${CURDIR}\/../' ${testdir_new}/$make_file + done + + # Adding the '-o' flag needed to link + sed -i 's/$(AR) $(ARFLAGS) $@ $^/$(AR) $(ARFLAGS) -o $@ $^/' ${testdir_new}/TESTING/MATGEN/Makefile + + # Updating these to point to libflame instead of internal files + sed -i 's/testieee: tstiee.o .*/testieee: tstiee.o $(LAPACKLIB) $(BLASLIB)/' ${testdir_new}/INSTALL/Makefile + + sed -i 's/schkaa.o: schkaa.F/schkaa.o: schkaa.F $(LAPACKLIB) $(BLASLIB)/' ${testdir_new}/TESTING/LIN/Makefile + sed -i 's/dchkaa.o: dchkaa.F/dchkaa.o: dchkaa.F $(LAPACKLIB) $(BLASLIB)/' ${testdir_new}/TESTING/LIN/Makefile + sed -i 's/cchkaa.o: cchkaa.F/cchkaa.o: cchkaa.F $(LAPACKLIB) $(BLASLIB)/' ${testdir_new}/TESTING/LIN/Makefile + sed -i 's/zchkaa.o: zchkaa.F/zchkaa.o: zchkaa.F $(LAPACKLIB) $(BLASLIB)/' ${testdir_new}/TESTING/LIN/Makefile + sed -i 's/$(FC) $(FFLAGS_DRV) -c -o $@ $ /dev/null | wc -l) + num_of_tars=$(ls -1q $script_dir/../netlib/*.{tar,tgz,tar.gz} 2> /dev/null | wc -l) ## Check to make sure there is only one tar file in netlib/ ## If so, use it @@ -68,7 +71,7 @@ then fi -if [[ "$install_type" == build || "$install_type" == other_installs ]] +if [[ "$install_type" == build || "$install_type" == build_test || "$install_type" == other_installs ]] then ## Make sure there are no old files @@ -85,8 +88,9 @@ then then cd $script_dir/../netlib tar -xzf $tar_file - cp lapack-*/SRC/*.[fF] . - cp lapack-*/SRC/*.[fF]90 . + cp lapack-*/SRC/*.{f,F,f90,F90} . + cp lapack-*/INSTALL/*roundup_lwork.{f,F,f90,F90} . + cp lapack-*/INSTALL/ilaver.{f,F,f90,F90} . rm -f ._*.f cat support.list | xargs rm -f cat install.list | xargs rm -f @@ -104,14 +108,13 @@ then ## Move to the lapack dir mkdir $script_dir/../fortran/ - mv $script_dir/../netlib/*.[fF] $script_dir/../fortran/ - mv $script_dir/../netlib/*.[fF]90 $script_dir/../fortran/ + mv $script_dir/../netlib/*.{f,F,f90,F90} $script_dir/../fortran/ ## Disable xblas-related code so shared libraries link properly. cd $script_dir ./disable_xblas.sh - elif [[ "$install_type" == other_installs ]] + elif [[ "$install_type" == build_test ]] then ## This section lets a user update netlibs-test and ## Updating other areas in libflame @@ -121,30 +124,48 @@ then ## should verify this is still true if [[ "$tar_file" == *.tgz || "$tar_file" == *.tar.gz ]] then - cd $script_dir/../netlib tar -xzf $tar_file ## Get the name of the directory new_test_dir=$(echo $tar_file | sed "s/\.tgz//" | sed "s/\.tar.gz//" | sed "s/\..\/netlib\///") - ## Call the script that makes a new netlibs-test flablas/f2c/ + ## Call the script that makes a new netlibs-test cd $script_dir/../../../../../netlib-test/ ./create_new_testdir.sh $script_dir/../netlib/$new_test_dir $new_test_dir + else + echo " " + echo " Skipping adding netlibs-test because it is not in the tar " + echo " " + exit + fi + elif [[ "$install_type" == other_installs ]] + then + ## This section lets a user update netlibs-test and + ## Updating other areas in libflame + ## It was observed that the tars had only the src files + ## While the tgz/tar.gz had the full netlibs. However, this + ## is not a guarantee. When adding a new netlibs tar, the dev + ## should verify this is still true + if [[ "$tar_file" == *.tgz || "$tar_file" == *.tar.gz ]] + then + cd $script_dir/../netlib + tar -xzf $tar_file + + ## Get the name of the directory + new_test_dir=$(echo $tar_file | sed "s/\.tgz//" | sed "s/\.tar.gz//" | sed "s/\..\/netlib\///") ## Regen the f2c in src/flablas/f2c/ cd $script_dir/../../../../flablas/f2c/ - rm -f *.[fF] *.[fF]90 *.c + rm -f *.{f,F,f90,F90} *.c cp $script_dir/../netlib/$new_test_dir/BLAS/SRC/* . ./regen-files.sh - else echo " " echo " Skipping other installs because they are not in the tar " echo " " exit fi - else echo "Unknown Error" exit @@ -152,17 +173,19 @@ then ## Cleanup rm -f $script_dir/../netlib/._* - rm -f $script_dir/../netlib/*.[fF] - rm -f $script_dir/../netlib/*.[fF]90 + rm -f $script_dir/../netlib/*.{f,F,f90,F90} rm -rf $script_dir/../netlib/lapack-*/ - elif [[ "$install_type" == cleanup ]] then - ## Cleanup echo "Cleaning up any files from lapack tar." clean - +elif [[ "$install_type" == clean_test ]] +then + ## Only clean out the test we made from this script + echo "Cleaning up any netlibs-tests." + test_dir=$(echo $tar_file | sed "s/\.tgz//" | sed "s/\.tar.gz//" | sed "s/\..\/netlib\///") + rm -rf $script_dir/../../../../../netlib-test/$test_dir else echo "Invalid Arg." usage