Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda kernels for Lower triangular solve #336

Merged
merged 19 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_CG_STEP_2_KERNEL);
namespace lower_trs {


GKO_DECLARE_LOWER_TRS_CHECK_TRANSPOSABILITY_KERNEL()
GKO_DECLARE_LOWER_TRS_SHOULD_PERFORM_TRANSPOSE_KERNEL()
GKO_NOT_COMPILED(GKO_HOOK_MODULE);

GKO_DECLARE_LOWER_TRS_INIT_STRUCT_KERNEL()
Expand Down
13 changes: 7 additions & 6 deletions core/solver/lower_trs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ namespace lower_trs {

GKO_REGISTER_OPERATION(generate, lower_trs::generate);
GKO_REGISTER_OPERATION(init_struct, lower_trs::init_struct);
GKO_REGISTER_OPERATION(perform_transpose, lower_trs::perform_transpose);
GKO_REGISTER_OPERATION(should_perform_transpose,
lower_trs::should_perform_transpose);
GKO_REGISTER_OPERATION(solve, lower_trs::solve);


Expand All @@ -71,7 +72,7 @@ template <typename ValueType, typename IndexType>
void LowerTrs<ValueType, IndexType>::generate()
{
this->get_executor()->run(lower_trs::make_generate(
gko::lend(system_matrix_), this->solve_struct_.get(),
gko::lend(system_matrix_), gko::lend(this->solve_struct_),
parameters_.num_rhs));
}

Expand All @@ -84,20 +85,20 @@ void LowerTrs<ValueType, IndexType>::apply_impl(const LinOp *b, LinOp *x) const

auto dense_b = as<const Vector>(b);
auto dense_x = as<Vector>(x);
bool transposability = false;
bool do_transpose = false;
std::shared_ptr<Vector> trans_b;
std::shared_ptr<Vector> trans_x;
this->get_executor()->run(
lower_trs::make_perform_transpose(transposability));
if (transposability) {
lower_trs::make_should_perform_transpose(do_transpose));
if (do_transpose) {
trans_b = Vector::create(exec, gko::transpose(dense_b->get_size()));
trans_x = Vector::create(exec, gko::transpose(dense_x->get_size()));
} else {
trans_b = Vector::create(exec);
trans_x = Vector::create(exec);
}
exec->run(lower_trs::make_solve(
gko::lend(system_matrix_), this->solve_struct_.get(),
gko::lend(system_matrix_), gko::lend(this->solve_struct_),
gko::lend(trans_b), gko::lend(trans_x), dense_b, dense_x));
thoasm marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
10 changes: 5 additions & 5 deletions core/solver/lower_trs_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ namespace kernels {
namespace lower_trs {


#define GKO_DECLARE_LOWER_TRS_CHECK_TRANSPOSABILITY_KERNEL() \
void perform_transpose(std::shared_ptr<const DefaultExecutor> exec, \
bool &transposability)
#define GKO_DECLARE_LOWER_TRS_SHOULD_PERFORM_TRANSPOSE_KERNEL() \
void should_perform_transpose(std::shared_ptr<const DefaultExecutor> exec, \
bool &do_transpose)


#define GKO_DECLARE_LOWER_TRS_INIT_STRUCT_KERNEL() \
Expand All @@ -68,13 +68,13 @@ namespace lower_trs {
#define GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL(_vtype, _itype) \
void solve(std::shared_ptr<const DefaultExecutor> exec, \
const matrix::Csr<_vtype, _itype> *matrix, \
gko::solver::SolveStruct *solve_struct, \
const gko::solver::SolveStruct *solve_struct, \
thoasm marked this conversation as resolved.
Show resolved Hide resolved
matrix::Dense<_vtype> *trans_b, matrix::Dense<_vtype> *trans_x, \
const matrix::Dense<_vtype> *b, matrix::Dense<_vtype> *x)


#define GKO_DECLARE_ALL_AS_TEMPLATES \
GKO_DECLARE_LOWER_TRS_CHECK_TRANSPOSABILITY_KERNEL(); \
GKO_DECLARE_LOWER_TRS_SHOULD_PERFORM_TRANSPOSE_KERNEL(); \
GKO_DECLARE_LOWER_TRS_INIT_STRUCT_KERNEL(); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_LOWER_TRS_SOLVE_KERNEL(ValueType, IndexType); \
Expand Down
4 changes: 4 additions & 0 deletions core/test/solver/lower_trs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include <memory>
#include <typeinfo>
thoasm marked this conversation as resolved.
Show resolved Hide resolved


#include <gtest/gtest.h>
Expand All @@ -43,6 +44,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/solver/cg.hpp>


#include "core/test/utils/assertions.hpp"


namespace {


Expand Down
Loading