diff --git a/examples/r_randGMRES.cpp b/examples/r_randGMRES.cpp index 65e10981..0d3785f0 100644 --- a/examples/r_randGMRES.cpp +++ b/examples/r_randGMRES.cpp @@ -19,7 +19,6 @@ using namespace ReSolve::constants; int main(int argc, char *argv[]) { // Use the same data types as those you specified in ReSolve build. - using index_type = ReSolve::index_type; using real_type = ReSolve::real_type; using vector_type = ReSolve::vector::Vector; diff --git a/examples/r_randGMRES_CUDA.cpp b/examples/r_randGMRES_CUDA.cpp index b93552c0..814ca2d4 100644 --- a/examples/r_randGMRES_CUDA.cpp +++ b/examples/r_randGMRES_CUDA.cpp @@ -19,7 +19,6 @@ using namespace ReSolve::constants; int main(int argc, char *argv[]) { // Use the same data types as those you specified in ReSolve build. - using index_type = ReSolve::index_type; using real_type = ReSolve::real_type; using vector_type = ReSolve::vector::Vector; diff --git a/resolve/LinSolverDirectRocSparseILU0.cpp b/resolve/LinSolverDirectRocSparseILU0.cpp index 54d5a181..f4bc82e1 100644 --- a/resolve/LinSolverDirectRocSparseILU0.cpp +++ b/resolve/LinSolverDirectRocSparseILU0.cpp @@ -89,8 +89,6 @@ namespace ReSolve &buffer_size_U); error_sum += status_rocsparse_; - size_t buffer_size = std::max(buffer_size_A, std::max(buffer_size_L, buffer_size_U)); - // Now analysis status_rocsparse_ = rocsparse_dcsrilu0_analysis(workspace_->getRocsparseHandle(), n, diff --git a/resolve/LinSolverIterativeRandFGMRES.cpp b/resolve/LinSolverIterativeRandFGMRES.cpp index 5c4137f3..ad6f03b0 100644 --- a/resolve/LinSolverIterativeRandFGMRES.cpp +++ b/resolve/LinSolverIterativeRandFGMRES.cpp @@ -118,15 +118,14 @@ namespace ReSolve switch(rand_method_) { case cs: if(ceil(restart_ * log(n_)) < k_rand_) { - //k_rand_ = ceil(restart_ * log(n_)); - k_rand_ = ceil(restart_ * log(n_)); + k_rand_ = static_cast(std::ceil(restart_ * std::log(static_cast(n_)))); } rand_manager_ = new RandSketchingCountSketch(); //set k and n break; case fwht: if ( ceil(2.0 * restart_ * log(n_) / log(restart_)) < k_rand_) { - k_rand_ = ceil(2.0 * restart_ * log(n_) / log(restart_)); + k_rand_ = static_cast(std::ceil(2.0 * restart_ * std::log(n_) / std::log(restart_))); } rand_manager_ = new RandSketchingFWHT(); break; @@ -134,7 +133,7 @@ namespace ReSolve io::Logger::warning() << "Wrong sketching method, setting to default (CountSketch)\n"; rand_method_ = cs; if(ceil(restart_ * log(n_)) < k_rand_) { - k_rand_ = ceil(restart_ * log(n_)); + k_rand_ = static_cast(std::ceil(restart_ * std::log(n_))); } rand_manager_ = new RandSketchingCountSketch(); break; @@ -194,7 +193,7 @@ namespace ReSolve rnorm = 0.0; bnorm = vector_handler_->dot(rhs, rhs, memspace_); rnorm = vector_handler_->dot(vec_s, vec_s, memspace_); - double rnorm_true = vector_handler_->dot(vec_v, vec_v, memspace_); + // double rnorm_true = vector_handler_->dot(vec_v, vec_v, memspace_); //rnorm = ||V_1|| rnorm = sqrt(rnorm); bnorm = sqrt(bnorm); diff --git a/resolve/RandSketchingCountSketch.cpp b/resolve/RandSketchingCountSketch.cpp index 6f9b068b..7ce61550 100644 --- a/resolve/RandSketchingCountSketch.cpp +++ b/resolve/RandSketchingCountSketch.cpp @@ -51,8 +51,7 @@ namespace ReSolve { k_rand_ = k; n_ = n; - srand(time(NULL)); - // srand(1234); + srand(static_cast(time(nullptr))); //allocate labeling scheme vector and move to GPU h_labels_ = new int[n_]; diff --git a/resolve/RandSketchingFWHT.cpp b/resolve/RandSketchingFWHT.cpp index 1e8e0442..76e91674 100644 --- a/resolve/RandSketchingFWHT.cpp +++ b/resolve/RandSketchingFWHT.cpp @@ -1,7 +1,10 @@ +#include +#include + #include "RandSketchingFWHT.hpp" #include #include -#include +#include #ifdef RESOLVE_USE_HIP #include #endif @@ -11,6 +14,8 @@ #include namespace ReSolve { + using out = io::Logger; + RandSketchingFWHT::RandSketchingFWHT() { h_seq_ = nullptr; @@ -62,11 +67,16 @@ namespace ReSolve k_rand_ = k; n_ = n; // pad to the nearest power of 2 - N_ = pow(2, ceil(log(n_)/log(2))); - log2N_ = log2(N_); - one_over_k_ = 1.0/sqrt((real_type) k_rand_); + real_type N_real = std::pow(2.0, std::ceil(std::log(n_)/std::log(2.0))); + if (N_real > static_cast(std::numeric_limits::max())) { + out::error() << "Exceeded numerical limits of index_type ...\n"; + return 1; + } + N_ = static_cast(N_real); + log2N_ = static_cast(std::log2(N_real)); + one_over_k_ = 1.0/std::sqrt(static_cast(k_rand_)); - srand(time(NULL)); + srand(static_cast(time(nullptr))); h_seq_ = new int[N_]; h_perm_ = new int[k_rand_]; @@ -114,7 +124,7 @@ namespace ReSolve //to be fixed, this can be done on the GPU int RandSketchingFWHT::reset() // if needed can be reset (like when Krylov method restarts) { - srand(time(NULL)); + srand(static_cast(time(nullptr))); int r; int temp;