Skip to content

Commit

Permalink
Rename Trs to LowerTrs
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Aug 12, 2019
1 parent 234d2b1 commit 217a9c1
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 197 deletions.
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ target_sources(ginkgo
solver/fcg.cpp
solver/gmres.cpp
solver/ir.cpp
solver/trs.cpp
solver/lower_trs.cpp
stop/combined.cpp
stop/criterion.cpp
stop/iteration.cpp
Expand Down
16 changes: 9 additions & 7 deletions core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/solver/fcg_kernels.hpp"
#include "core/solver/gmres_kernels.hpp"
#include "core/solver/ir_kernels.hpp"
#include "core/solver/trs_kernels.hpp"
#include "core/solver/lower_trs_kernels.hpp"
#include "core/stop/criterion_kernels.hpp"
#include "core/stop/residual_norm_reduction_kernels.hpp"

Expand Down Expand Up @@ -182,21 +182,23 @@ GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_CG_STEP_2_KERNEL);
} // namespace cg


namespace trs {
namespace lower_trs {


template <typename ValueType, typename IndexType>
GKO_DECLARE_TRS_GENERATE_KERNEL(ValueType, IndexType)
GKO_DECLARE_LOWER_TRS_GENERATE_KERNEL(ValueType, IndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_TRS_GENERATE_KERNEL);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_LOWER_TRS_GENERATE_KERNEL);

template <typename ValueType, typename IndexType>
GKO_DECLARE_TRS_SOLVE_KERNEL(ValueType, IndexType)
GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL(ValueType, IndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_TRS_SOLVE_KERNEL);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL);


} // namespace trs
} // namespace lower_trs


namespace fcg {
Expand Down
33 changes: 18 additions & 15 deletions core/solver/trs.cpp → core/solver/lower_trs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#include <ginkgo/core/solver/trs.hpp>
#include <ginkgo/core/solver/lower_trs.hpp>


#include <ginkgo/core/base/array.hpp>
Expand All @@ -43,26 +43,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/matrix/dense.hpp>


#include "core/solver/trs_kernels.hpp"
#include "core/solver/lower_trs_kernels.hpp"


namespace gko {
namespace solver {


namespace trs {
namespace lower_trs {


GKO_REGISTER_OPERATION(generate, trs::generate);
GKO_REGISTER_OPERATION(solve, trs::solve);
GKO_REGISTER_OPERATION(generate, lower_trs::generate);
GKO_REGISTER_OPERATION(solve, lower_trs::solve);


} // namespace trs
} // namespace lower_trs


template <typename ValueType, typename IndexType>
void Trs<ValueType, IndexType>::generate(const LinOp *system_matrix,
const LinOp *b)
void LowerTrs<ValueType, IndexType>::generate(const LinOp *system_matrix,
const LinOp *b)
{
using CsrMatrix = matrix::Csr<ValueType, IndexType>;
using Vector = matrix::Dense<ValueType>;
Expand All @@ -77,26 +77,29 @@ void Trs<ValueType, IndexType>::generate(const LinOp *system_matrix,
copy_and_convert_to<CsrMatrix>(exec, system_matrix);
}
auto dense_b = as<const Vector>(b);
exec->run(trs::make_generate(gko::lend(csr_system_matrix_), dense_b));
exec->run(lower_trs::make_generate(gko::lend(csr_system_matrix_), dense_b));
}


template <typename ValueType, typename IndexType>
void Trs<ValueType, IndexType>::apply_impl(const LinOp *b, LinOp *x) const
void LowerTrs<ValueType, IndexType>::apply_impl(const LinOp *b, LinOp *x) const
{
using Vector = matrix::Dense<ValueType>;
const auto exec = this->get_executor();

auto dense_b = as<const Vector>(b);
auto dense_x = as<Vector>(x);

exec->run(trs::make_solve(gko::lend(csr_system_matrix_), dense_b, dense_x));
exec->run(
lower_trs::make_solve(gko::lend(csr_system_matrix_), dense_b, dense_x));
}


template <typename ValueType, typename IndexType>
void Trs<ValueType, IndexType>::apply_impl(const LinOp *alpha, const LinOp *b,
const LinOp *beta, LinOp *x) const
void LowerTrs<ValueType, IndexType>::apply_impl(const LinOp *alpha,
const LinOp *b,
const LinOp *beta,
LinOp *x) const
{
auto dense_x = as<matrix::Dense<ValueType>>(x);

Expand All @@ -107,8 +110,8 @@ void Trs<ValueType, IndexType>::apply_impl(const LinOp *alpha, const LinOp *b,
}


#define GKO_DECLARE_TRS(_vtype, _itype) class Trs<_vtype, _itype>
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_TRS);
#define GKO_DECLARE_LOWER_TRS(_vtype, _itype) class LowerTrs<_vtype, _itype>
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_LOWER_TRS);


} // namespace solver
Expand Down
36 changes: 18 additions & 18 deletions core/solver/trs_kernels.hpp → core/solver/lower_trs_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#ifndef GKO_CORE_SOLVER_TRS_KERNELS_HPP_
#define GKO_CORE_SOLVER_TRS_KERNELS_HPP_
#ifndef GKO_CORE_SOLVER_LOWER_TRS_KERNELS_HPP_
#define GKO_CORE_SOLVER_LOWER_TRS_KERNELS_HPP_


#include <memory>
Expand All @@ -44,55 +44,55 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace gko {
namespace kernels {
namespace trs {
namespace lower_trs {


#define GKO_DECLARE_TRS_GENERATE_KERNEL(_vtype, _itype) \
#define GKO_DECLARE_LOWER_TRS_GENERATE_KERNEL(_vtype, _itype) \
void generate(std::shared_ptr<const DefaultExecutor> exec, \
const matrix::Csr<_vtype, _itype> *matrix, \
const matrix::Dense<_vtype> *b)


#define GKO_DECLARE_TRS_SOLVE_KERNEL(_vtype, _itype) \
#define GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL(_vtype, _itype) \
void solve(std::shared_ptr<const DefaultExecutor> exec, \
const matrix::Csr<_vtype, _itype> *matrix, \
const matrix::Dense<_vtype> *b, matrix::Dense<_vtype> *x)


#define GKO_DECLARE_ALL_AS_TEMPLATES \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_TRS_SOLVE_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_TRS_GENERATE_KERNEL(ValueType, IndexType)
#define GKO_DECLARE_ALL_AS_TEMPLATES \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_LOWER_TRS_GENERATE_KERNEL(ValueType, IndexType)


} // namespace trs
} // namespace lower_trs


namespace omp {
namespace trs {
namespace lower_trs {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace trs
} // namespace lower_trs
} // namespace omp


namespace cuda {
namespace trs {
namespace lower_trs {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace trs
} // namespace lower_trs
} // namespace cuda


namespace reference {
namespace trs {
namespace lower_trs {

GKO_DECLARE_ALL_AS_TEMPLATES;

} // namespace trs
} // namespace lower_trs
} // namespace reference


Expand All @@ -103,4 +103,4 @@ GKO_DECLARE_ALL_AS_TEMPLATES;
} // namespace gko


#endif // GKO_CORE_SOLVER_TRS_KERNELS_HPP
#endif // GKO_CORE_SOLVER_LOWER_TRS_KERNELS_HPP
2 changes: 1 addition & 1 deletion core/test/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ginkgo_create_test(cgs)
ginkgo_create_test(fcg)
ginkgo_create_test(gmres)
ginkgo_create_test(ir)
ginkgo_create_test(trs)
ginkgo_create_test(lower_trs)
21 changes: 11 additions & 10 deletions core/test/solver/trs.cpp → core/test/solver/lower_trs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#include <ginkgo/core/solver/trs.hpp>
#include <ginkgo/core/solver/lower_trs.hpp>


#include <memory>
Expand All @@ -46,33 +46,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace {


class Trs : public ::testing::Test {
class LowerTrs : public ::testing::Test {
protected:
using Solver = gko::solver::Trs<>;
using Solver = gko::solver::LowerTrs<>;
using CGSolver = gko::solver::Cg<>;

Trs()
LowerTrs()
: exec(gko::ReferenceExecutor::create()),
prec_fac(CGSolver::build().on(exec)),
trs_factory(Solver::build().with_preconditioner(prec_fac).on(exec))
lower_trs_factory(
Solver::build().with_preconditioner(prec_fac).on(exec))
{}

std::shared_ptr<const gko::Executor> exec;
std::shared_ptr<CGSolver::Factory> prec_fac;
std::unique_ptr<Solver::Factory> trs_factory;
std::unique_ptr<Solver::Factory> lower_trs_factory;
};


TEST_F(Trs, TrsFactoryKnowsItsExecutor)
TEST_F(LowerTrs, LowerTrsFactoryKnowsItsExecutor)
{
ASSERT_EQ(trs_factory->get_executor(), exec);
ASSERT_EQ(lower_trs_factory->get_executor(), exec);
}


TEST_F(Trs, TrsFactoryKnowsItsPrecond)
TEST_F(LowerTrs, LowerTrsFactoryKnowsItsPrecond)
{
ASSERT_EQ(static_cast<const CGSolver::Factory *>(
trs_factory->get_parameters().preconditioner.get()),
lower_trs_factory->get_parameters().preconditioner.get()),
prec_fac.get());
}

Expand Down
2 changes: 1 addition & 1 deletion cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ target_sources(ginkgo_cuda
solver/fcg_kernels.cu
solver/gmres_kernels.cu
solver/ir_kernels.cu
solver/trs_kernels.cu
solver/lower_trs_kernels.cu
stop/criterion_kernels.cu
stop/residual_norm_reduction_kernels.cu)

Expand Down
16 changes: 9 additions & 7 deletions cuda/solver/trs_kernels.cu → cuda/solver/lower_trs_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#include "core/solver/trs_kernels.hpp"
#include "core/solver/lower_trs_kernels.hpp"


#include <ginkgo/core/base/exception_helpers.hpp>
Expand All @@ -46,19 +46,20 @@ namespace gko {
namespace kernels {
namespace cuda {
/**
* @brief The TRS solver namespace.
* @brief The LOWER_TRS solver namespace.
*
* @ingroup trs
* @ingroup lower_trs
*/
namespace trs {
namespace lower_trs {


template <typename ValueType, typename IndexType>
void generate(std::shared_ptr<const CudaExecutor> exec,
const matrix::Csr<ValueType, IndexType> *matrix,
const matrix::Dense<ValueType> *b) 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_LOWER_TRS_GENERATE_KERNEL);


template <typename ValueType, typename IndexType>
Expand All @@ -67,10 +68,11 @@ void solve(std::shared_ptr<const CudaExecutor> exec,
const matrix::Dense<ValueType> *b,
matrix::Dense<ValueType> *x) GKO_NOT_IMPLEMENTED;

GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_TRS_SOLVE_KERNEL);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL);


} // namespace trs
} // namespace lower_trs
} // namespace cuda
} // namespace kernels
} // namespace gko
Loading

0 comments on commit 217a9c1

Please sign in to comment.