diff --git a/.envrc.local b/.envrc.local new file mode 100644 index 0000000..f7df9c2 --- /dev/null +++ b/.envrc.local @@ -0,0 +1 @@ +#!/bin/zsh diff --git a/BUILD.bazel b/BUILD.bazel index 9fea1d6..3a61ca0 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -59,29 +59,17 @@ cmake( cmake( name = "armadillo_lib", cache_entries = { - # "CMAKE_INSTALL_PREFIX": ".", - # "CMAKE_INSTALL_INCLUDEDIR": "include", - # deps ":openblas_lib_bazel" will be copied to "$EXT_BUILD_DEPS" - # The directory structure of ":openblas_lib_bazel" are retained, - # usually libraries are under /lib and headers are under /include - # "TPL_BLAS_LIBRARIES": "$EXT_BUILD_DEPS/lib/libopenblas.a" "BUILD_SHARED_LIBS": "OFF", }, lib_source = "@armadillo//:all_srcs", out_static_libs = ["libarmadillo.a"], - # out_include_dir = "include", deps = [ - # cannot directly use ":openblas_lib", - # need bridged through a `cc_library` containing ":openblas_lib" - # i.e. ":openblas_lib_bazel" ":openblas_lib_bazel" ], copts =[ "-DARMA_DONT_USE_WRAPPER" ], linkopts = [ - # "-lpthread", - # "-L$EXT_BUILD_DEPS/lib", "-lopenblas", "-lgfortran", ], ) @@ -94,81 +82,39 @@ cc_library( ], ) -cmake( +# +configure_make( name = "hdf5_lib", - cache_entries = { - # "CMAKE_INSTALL_PREFIX": ".", - # "CMAKE_INSTALL_INCLUDEDIR": "include", - # deps ":openblas_lib_bazel" will be copied to "$EXT_BUILD_DEPS" - # The directory structure of ":openblas_lib_bazel" are retained, - # usually libraries are under /lib and headers are under /include - # "TPL_BLAS_LIBRARIES": "$EXT_BUILD_DEPS/lib/libopenblas.a" - "BUILD_SHARED_LIBS": "OFF", - "CMAKE_BUILD_TYPE": "Release", - "HDF5_BUILD_TOOLS": "ON", - "BUILD_TESTING": "ON", - "SZIP_USE_EXTERNAL": "ON", - "ZLIB_USE_EXTERNAL": "ON", - "USE_LIBAEC_STATIC": "ON", - "SZIP_INCLUDE_DIR": "$EXT_BUILD_DEPS/include", - "ZLIB_INCLUDE_DIR": "$EXT_BUILD_DEPS/include", - "SZIP_LIBRARY": "$EXT_BUILD_DEPS/lib/libsz.a", - "ZLIB_LIBRARY": "$EXT_BUILD_DEPS/lib/libz.a", - }, + configure_in_place = True, + configure_options = [ + "--with-szlib=libaec/include,$EXT_BUILD_DEPS/libaec/lib", + "--with-zlib=z_lib/include,$EXT_BUILD_DEPS/z_lib/lib", + ], lib_source = "@hdf5//:all_srcs", - out_static_libs = ["libhdf5.a"], - # out_include_dir = "include", deps = [ - # cannot directly use ":openblas_lib", - # need bridged through a `cc_library` containing ":openblas_lib" - # i.e. ":openblas_lib_bazel" - # ":openblas_lib_bazel" ":hdf5_deps_lib", ], - linkopts = [ - # "-lpthread", - # "-L$EXT_BUILD_DEPS/lib", "-lopenblas", - # "-lgfortran", - # "-lsz", "-lz", - ], + out_static_libs = ["libhdf5.a"], + linkopts = ["-lpthread"], + includes = [ + "z_lib/include", + "libaec/include", + ] ) cmake( name = "z_lib", cache_entries = { - # "CMAKE_INSTALL_PREFIX": ".", - # "CMAKE_INSTALL_INCLUDEDIR": "include", - # deps ":openblas_lib_bazel" will be copied to "$EXT_BUILD_DEPS" - # The directory structure of ":openblas_lib_bazel" are retained, - # usually libraries are under /lib and headers are under /include - # "TPL_BLAS_LIBRARIES": "$EXT_BUILD_DEPS/lib/libopenblas.a" "BUILD_SHARED_LIBS": "OFF", }, lib_source = "@zlib//:all_srcs", out_static_libs = ["libz.a"], - # out_include_dir = "include", - deps = [ - # cannot directly use ":openblas_lib", - # need bridged through a `cc_library` containing ":openblas_lib" - # i.e. ":openblas_lib_bazel" - # ":openblas_lib_bazel" - ], - linkopts = [ - # "-lpthread", - # "-L$EXT_BUILD_DEPS/lib", "-lopenblas", - # "-lgfortran", - ], + copts = ["-fPIC"] # this is necessary otherwise will cause hdf5 build to complain ) cmake( name = "libaec", cache_entries = { - # "CMAKE_INSTALL_PREFIX": ".", - # "CMAKE_INSTALL_INCLUDEDIR": "include", - # deps ":openblas_lib_bazel" will be copied to "$EXT_BUILD_DEPS" - # The directory structure of ":openblas_lib_bazel" are retained, - # usually libraries are under /lib and headers are under /include - # "TPL_BLAS_LIBRARIES": "$EXT_BUILD_DEPS/lib/libopenblas.a" "BUILD_SHARED_LIBS": "OFF", }, lib_source = "@libaec//:all_srcs", @@ -176,18 +122,6 @@ cmake( "libaec.a", "libsz.a", ], - # out_include_dir = "include", - deps = [ - # cannot directly use ":openblas_lib", - # need bridged through a `cc_library` containing ":openblas_lib" - # i.e. ":openblas_lib_bazel" - # ":openblas_lib_bazel" - ], - linkopts = [ - # "-lpthread", - # "-L$EXT_BUILD_DEPS/lib", "-lopenblas", - # "-lgfortran", - ], ) # @@ -197,15 +131,12 @@ configure_make( configure_options = [ "--enable-mat73=yes", "--enable-extended-sparse=yes", - "--with-zlib=\"$EXT_BUILD_DEPS/hdf5_lib/lib\"", - "--with-hdf5=\"$EXT_BUILD_DEPS/z_lib/lib\"", + "--with-hdf5=\"$EXT_BUILD_DEPS/hdf5_lib/lib\"", + "--with-zlib=\"$EXT_BUILD_DEPS/z_lib/lib\"", "--with-default-file-ver=7.3", ], lib_source = "@libmatio//:all_srcs", deps = [ - # cannot directly use ":openblas_lib", - # need bridged through a `cc_library` containing ":openblas_lib" - # i.e. ":openblas_lib_bazel" ":hdf5_lib", ":z_lib", ], @@ -216,28 +147,10 @@ configure_make( cmake( name = "libjsoncpp", cache_entries = { - # "CMAKE_INSTALL_PREFIX": ".", - # "CMAKE_INSTALL_INCLUDEDIR": "include", - # deps ":openblas_lib_bazel" will be copied to "$EXT_BUILD_DEPS" - # The directory structure of ":openblas_lib_bazel" are retained, - # usually libraries are under /lib and headers are under /include - # "TPL_BLAS_LIBRARIES": "$EXT_BUILD_DEPS/lib/libopenblas.a" "BUILD_SHARED_LIBS": "OFF", }, lib_source = "@jsoncpp//:all_srcs", out_static_libs = [ "libjsoncpp.a", ], - # out_include_dir = "include", - deps = [ - # cannot directly use ":openblas_lib", - # need bridged through a `cc_library` containing ":openblas_lib" - # i.e. ":openblas_lib_bazel" - # ":openblas_lib_bazel" - ], - linkopts = [ - # "-lpthread", - # "-L$EXT_BUILD_DEPS/lib", "-lopenblas", - # "-lgfortran", - ], ) diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 08f3acc..09b346f 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -13,5 +13,8 @@ cc_binary( "//sas:sas_expr_parser_lib", "//sas:sas_model_parser_lib", "@nvwa//:nvwa_pctimer_headers", - ] + ], + env = { + + } ) diff --git a/app/main.cpp b/app/main.cpp index 8da6cd4..13124ea 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -400,7 +400,7 @@ int main(int argc, char **argv) double alphaTol = 1e-4; double diffTol = 1e-6; double diffTolMax = 1e-2; - int repeat = 10; + int repeat = 1; for (int iArg = 2; iArg < argc; iArg++) { string arg = argv[iArg]; diff --git a/pf/ChePFCalculator.cpp b/pf/ChePFCalculator.cpp index a972140..b72decf 100644 --- a/pf/ChePFCalculator.cpp +++ b/pf/ChePFCalculator.cpp @@ -1232,7 +1232,8 @@ namespace che { if(this->perm_c==NULL){ options.ColPerm=arma::superlu::COLAMD; }else{ - options.ColPerm=arma::superlu::MY_PERMC; + // TODO - rygx: work with arma team to fix the enum slip issue + options.ColPerm=static_cast(8); // This represents the MY_PERMC in SuperLu 6.0 arrayops::copy(perm_c,this->perm_c,A.n_cols + 1); } options.Fact=arma::superlu::DOFACT; @@ -1243,37 +1244,8 @@ namespace che { arrayops::copy(perm_r,this->perm_r,A.n_rows + 1); arrayops::copy(etree,this->etree,A.n_cols + 1); } - if (use_iter_solver){ - // arma_wrapper(dgssvx)(&options, &superA, perm_c, perm_r, etree, equed, R, C, &superL, &superU, &work[0], lwork, &superB, &superX, &rpg, &rcond, ferr, berr, &glu, &mu, &stat, &superInfo); - arma_wrapper(ilu_set_default_options)(&options); - options.Equil=arma::superlu::NO; - lwork=0; - char equedx[1]={'N'}; - arma_wrapper(dgsisx)(&options, &superA, perm_c, perm_r, etree, equedx, R, C, &superL, &superU, NULL, 0, &superB, &superX, &rpg, &rcond, &glu, &mu, &stat, &superInfo); - // arma_wrapper(dgsitrf)(&options, &superA, 2, 10, etree, &work[0], lwork, perm_c, perm_r, &superL, &superU, &glu, &stat, &superInfo); - // arma_wrapper(dgstrs)(options.Trans, &superL, &superU, perm_c, perm_r, &superX, &stat, &superInfo); - - vec xx=RHS; - arma::superlu::SuperMatrix superX2; arrayops::inplace_set(reinterpret_cast(&superX2), char(0), sizeof(arma::superlu::SuperMatrix)); - - const bool status_x2 = sp_auxlib::wrap_to_supermatrix(superX2, xx); - arma_wrapper(dgstrs)(options.Trans, &superL, &superU, perm_c, perm_r, &superX2, &stat, &superInfo); - x=xx; - sp_auxlib::destroy_supermatrix(superX2); - - int max_it=5000; - double tol=1.0e-10; - double err=0.0; - int iter=0; - int flag=0; - // x.fill(0.0); - // LHS_mat.print("A"); - vec cbx=RHS; - bicgstab(LHS_mat, x, cbx, options.Trans, &superL, &superU, perm_c, perm_r, &stat, &superInfo, max_it, tol, &err, &iter, &flag); - }else{ - arma_wrapper(dgssvx)(&options, &superA, perm_c, perm_r, etree, equed, R, C, &superL, &superU, &work[0], lwork, &superB, &superX, &rpg, &rcond, ferr, berr, &glu, &mu, &stat, &superInfo); - } - // arma_wrapper(dgssvx)(&options, &superA, perm_c, perm_r, etree, equed, R, C, &superL, &superU, &work[0], lwork, &superB, &superX, &rpg, &rcond, ferr, berr, &glu, &mu, &stat, &superInfo); + + arma_wrapper(dgssvx)(&options, &superA, perm_c, perm_r, etree, equed, R, C, &superL, &superU, &work[0], lwork, &superB, &superX, &rpg, &rcond, ferr, berr, &glu, &mu, &stat, &superInfo); if(this->perm_c==NULL){ this->perm_c=new int[A.n_cols + 1]; @@ -1288,39 +1260,8 @@ namespace che { arrayops::copy(this->perm_r,perm_r,A.n_rows + 1); arrayops::copy(this->etree,etree,A.n_cols + 1); } - else { - if (use_iter_solver){ - // x.print("xx"); - // arma_wrapper(dgstrs)(options.Trans, &superL, &superU, perm_c, perm_r, &superX, &stat, &superInfo); - // x.print("xx"); - arma_wrapper(ilu_set_default_options)(&options); - options.Equil=arma::superlu::NO; - // lwork=0; - // char equedx[1]={'B'}; - // arma_wrapper(dgsisx)(&options, &superA, perm_c, perm_r, etree, equedx, R, C, &superL, &superU, NULL, 0, &superB, &superX, &rpg, &rcond, &glu, &mu, &stat, &superInfo); - - int max_it=5000; - double tol=1.0e-10; - double err=0.0; - int iter=0; - int flag=0; - - vec xx=RHS; - arma::superlu::SuperMatrix superX2; arrayops::inplace_set(reinterpret_cast(&superX2), char(0), sizeof(arma::superlu::SuperMatrix)); - - const bool status_x2 = sp_auxlib::wrap_to_supermatrix(superX2, xx); - arma_wrapper(dgstrs)(options.Trans, &superL, &superU, perm_c, perm_r, &superX2, &stat, &superInfo); - x=xx; - sp_auxlib::destroy_supermatrix(superX2); - - // x.print("x"); - vec cbx=RHS; - bicgstab(LHS_mat, x, cbx, options.Trans, &superL, &superU, perm_c, perm_r, &stat, &superInfo, max_it, tol, &err, &iter, &flag); - // x.print("x"); - }else{ - arma_wrapper(dgstrs)(options.Trans, &superL, &superU, perm_c, perm_r, &superX, &stat, &superInfo); - } - + else { + arma_wrapper(dgstrs)(options.Trans, &superL, &superU, perm_c, perm_r, &superX, &stat, &superInfo); } // x.print("x"); diff --git a/pf/ChePFCalculator.h b/pf/ChePFCalculator.h index 3ce712c..e09ce34 100644 --- a/pf/ChePFCalculator.h +++ b/pf/ChePFCalculator.h @@ -83,6 +83,7 @@ namespace che { virtual CheSolution* getCheSolution(); }; + } } diff --git a/sas/BUILD.bazel b/sas/BUILD.bazel index b256740..0e18040 100644 --- a/sas/BUILD.bazel +++ b/sas/BUILD.bazel @@ -94,7 +94,7 @@ cc_library( "ModelParser.cpp", ], deps = [ - ":sas_expr_lib", + ":sas_expr_parser_lib", ] ) diff --git a/util/SafeArmadillo.h b/util/SafeArmadillo.h index 3fd3601..eea0aea 100644 --- a/util/SafeArmadillo.h +++ b/util/SafeArmadillo.h @@ -28,6 +28,7 @@ #define _Che_SafeArmadillo_H #define ARMA_USE_SUPERLU +#define ARMA_USE_LAPACK #define ARMA_DONT_USE_WRAPPER #include