Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rygx/20240113_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rygx committed Jan 24, 2024
2 parents 24a6b80 + 8af9faf commit 9d6ede0
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 171 deletions.
1 change: 1 addition & 0 deletions .envrc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/zsh
119 changes: 16 additions & 103 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Expand All @@ -94,100 +82,46 @@ 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",
out_static_libs = [
"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",
],
)

#
Expand All @@ -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",
],
Expand All @@ -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",
],
)
5 changes: 4 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ cc_binary(
"//sas:sas_expr_parser_lib",
"//sas:sas_model_parser_lib",
"@nvwa//:nvwa_pctimer_headers",
]
],
env = {

}
)
2 changes: 1 addition & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
71 changes: 6 additions & 65 deletions pf/ChePFCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<arma::superlu::colperm_t>(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;
Expand All @@ -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<char*>(&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];
Expand All @@ -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<char*>(&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");
Expand Down
1 change: 1 addition & 0 deletions pf/ChePFCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace che {

virtual CheSolution* getCheSolution();
};

}
}

Expand Down
2 changes: 1 addition & 1 deletion sas/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ cc_library(
"ModelParser.cpp",
],
deps = [
":sas_expr_lib",
":sas_expr_parser_lib",
]
)

Expand Down
1 change: 1 addition & 0 deletions util/SafeArmadillo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define _Che_SafeArmadillo_H

#define ARMA_USE_SUPERLU
#define ARMA_USE_LAPACK
#define ARMA_DONT_USE_WRAPPER
#include <armadillo>

Expand Down

0 comments on commit 9d6ede0

Please sign in to comment.