Skip to content

Commit

Permalink
Remove the CUDA code for PR review.
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Aug 10, 2019
1 parent 1a51a18 commit 7f9e520
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 350 deletions.
51 changes: 1 addition & 50 deletions core/test/solver/trs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,63 +40,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include <ginkgo/core/base/executor.hpp>
#include <ginkgo/core/matrix/csr.hpp>
#include <ginkgo/core/matrix/dense.hpp>
#include <ginkgo/core/stop/combined.hpp>
#include <ginkgo/core/stop/iteration.hpp>
#include <ginkgo/core/stop/residual_norm_reduction.hpp>


namespace {


class Trs : public ::testing::Test {
protected:
using CsrMtx = gko::matrix::Csr<double, int>;
using Mtx = gko::matrix::Dense<>;
using Solver = gko::solver::Trs<>;

Trs()
: exec(gko::ReferenceExecutor::create()),
mtx(gko::initialize<Mtx>(
{{2, 0.0, 0.0}, {3.0, 1, 0.0}, {1.0, 2.0, 3}}, exec)),
b(gko::initialize<Mtx>({{2, 0.0, 0.0}}, exec)),
csr_mtx(gko::copy_and_convert_to<CsrMtx>(exec, mtx.get())),
trs_factory(Solver::build().on(exec)),
solver(trs_factory->generate(mtx, b))
trs_factory(Solver::build().on(exec))
{}

std::shared_ptr<const gko::Executor> exec;
std::shared_ptr<Mtx> mtx;
std::shared_ptr<Mtx> b;
std::shared_ptr<CsrMtx> csr_mtx;
std::unique_ptr<Solver::Factory> trs_factory;
std::unique_ptr<gko::LinOp> solver;

static void assert_same_matrices(const Mtx *m1, const Mtx *m2)
{
ASSERT_EQ(m1->get_size()[0], m2->get_size()[0]);
ASSERT_EQ(m1->get_size()[1], m2->get_size()[1]);
for (gko::size_type i = 0; i < m1->get_size()[0]; ++i) {
for (gko::size_type j = 0; j < m2->get_size()[1]; ++j) {
EXPECT_EQ(m1->at(i, j), m2->at(i, j));
}
}
}

static void assert_same_csr_matrices(const CsrMtx *m1, const CsrMtx *m2)
{
ASSERT_EQ(m1->get_size()[0], m2->get_size()[0]);
ASSERT_EQ(m1->get_size()[1], m2->get_size()[1]);

for (gko::size_type i = 0; i < m1->get_size()[0] + 1; ++i) {
EXPECT_EQ(m1->get_const_row_ptrs()[i], m2->get_const_row_ptrs()[i]);
}
for (gko::size_type i = 0; i < m1->get_num_stored_elements(); ++i) {
EXPECT_EQ(m1->get_const_col_idxs()[i], m2->get_const_col_idxs()[i]);
EXPECT_EQ(m1->get_const_values()[i], m2->get_const_values()[i]);
}
}
};


Expand All @@ -106,13 +66,4 @@ TEST_F(Trs, TrsFactoryKnowsItsExecutor)
}


TEST_F(Trs, TrsFactoryCreatesCorrectSolver)
{
ASSERT_EQ(solver->get_size(), gko::dim<2>(3, 3));
auto trs_solver = static_cast<Solver *>(solver.get());
ASSERT_NE(trs_solver->get_system_matrix(), nullptr);
ASSERT_EQ(trs_solver->get_system_matrix(), mtx);
}


} // namespace
34 changes: 2 additions & 32 deletions cuda/solver/trs_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,14 @@ constexpr int default_block_size = 512;

template <typename ValueType, typename IndexType>
void generate(std::shared_ptr<const CudaExecutor> exec,
const matrix::Csr<ValueType, IndexType> *matrix)
GKO_NOT_IMPLEMENTED;
const matrix::Csr<ValueType, IndexType> *matrix,
const matrix::Dense<ValueType> *b) GKO_NOT_IMPLEMENTED;

template <typename ValueType, typename IndexType>
void solve(std::shared_ptr<const CudaExecutor> exec,
const matrix::Csr<ValueType, IndexType> *matrix,
const matrix::Dense<ValueType> *b,
matrix::Dense<ValueType> *x) GKO_NOT_IMPLEMENTED;
// {
// if (cusparse::is_supported<ValueType, IndexType>::value) {
// // TODO: add implementation for int64 and multiple RHS
// auto handle = exec->get_cusparse_handle();
// auto descr = cusparse::create_mat_descr();
// GKO_ASSERT_NO_CUSPARSE_ERRORS(
// cusparseSetPointerMode(handle, CUSPARSE_POINTER_MODE_HOST));

// auto row_ptrs = matrix->get_const_row_ptrs();
// auto col_idxs = matrix->get_const_col_idxs();
// auto values = matrix->get_const_values();
// auto alpha = one<ValueType>();
// auto beta = zero<ValueType>();
// if (b->get_stride() != 1 || x->get_stride() != 1)
// GKO_NOT_IMPLEMENTED;

// cusparse::spmv(handle, CUSPARSE_OPERATION_NON_TRANSPOSE,
// matrix->get_size()[0], matrix->get_size()[1],
// matrix->get_num_stored_elements(), &alpha, descr,
// values, row_ptrs, col_idxs, b->get_const_values(),
// &beta, x->get_values());

// GKO_ASSERT_NO_CUSPARSE_ERRORS(
// cusparseSetPointerMode(handle, CUSPARSE_POINTER_MODE_DEVICE));

// cusparse::destroy(descr);
// } else {
// GKO_NOT_IMPLEMENTED;
// }
// }

GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_TRS_GENERATE_KERNEL);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_TRS_SOLVE_KERNEL);
Expand Down
1 change: 0 additions & 1 deletion cuda/test/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ ginkgo_create_test(cgs_kernels)
ginkgo_create_test(fcg_kernels)
ginkgo_create_test(gmres_kernels)
ginkgo_create_test(ir_kernels)
ginkgo_create_test(trs_kernels)
256 changes: 0 additions & 256 deletions cuda/test/solver/trs_kernels.cpp

This file was deleted.

Loading

0 comments on commit 7f9e520

Please sign in to comment.