Skip to content

Commit

Permalink
Fix warnings in rand-gmres-dev2 branch. (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelesh authored Nov 30, 2023
1 parent 76c24fd commit 36bad31
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
1 change: 0 additions & 1 deletion examples/r_randGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion examples/r_randGMRES_CUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions resolve/LinSolverDirectRocSparseILU0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 4 additions & 5 deletions resolve/LinSolverIterativeRandFGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,22 @@ 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<index_type>(std::ceil(restart_ * std::log(static_cast<real_type>(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<index_type>(std::ceil(2.0 * restart_ * std::log(n_) / std::log(restart_)));
}
rand_manager_ = new RandSketchingFWHT();
break;
default:
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<index_type>(std::ceil(restart_ * std::log(n_)));
}
rand_manager_ = new RandSketchingCountSketch();
break;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions resolve/RandSketchingCountSketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ namespace ReSolve
{
k_rand_ = k;
n_ = n;
srand(time(NULL));
// srand(1234);
srand(static_cast<unsigned>(time(nullptr)));
//allocate labeling scheme vector and move to GPU

h_labels_ = new int[n_];
Expand Down
22 changes: 16 additions & 6 deletions resolve/RandSketchingFWHT.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include <cmath>
#include <limits>

#include "RandSketchingFWHT.hpp"
#include <resolve/MemoryUtils.hpp>
#include <resolve/vector/Vector.hpp>
#include <math.h>
#include <resolve/utilities/logger/Logger.hpp>
#ifdef RESOLVE_USE_HIP
#include <resolve/hip/hipKernels.h>
#endif
Expand All @@ -11,6 +14,8 @@
#include <resolve/RandSketchingFWHT.hpp>
namespace ReSolve
{
using out = io::Logger;

RandSketchingFWHT::RandSketchingFWHT()
{
h_seq_ = nullptr;
Expand Down Expand Up @@ -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<real_type>(std::numeric_limits<index_type>::max())) {
out::error() << "Exceeded numerical limits of index_type ...\n";
return 1;
}
N_ = static_cast<index_type>(N_real);
log2N_ = static_cast<index_type>(std::log2(N_real));
one_over_k_ = 1.0/std::sqrt(static_cast<real_type>(k_rand_));

srand(time(NULL));
srand(static_cast<unsigned>(time(nullptr)));

h_seq_ = new int[N_];
h_perm_ = new int[k_rand_];
Expand Down Expand Up @@ -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<unsigned>(time(nullptr)));

int r;
int temp;
Expand Down

0 comments on commit 36bad31

Please sign in to comment.