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

Removed move_to_XXX kernels and COO::transpose #288

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 0 additions & 42 deletions core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,49 +103,24 @@ GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_DENSE_CONVERT_TO_CSR_KERNEL);

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


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

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

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

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

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

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

template <typename ValueType>
GKO_DECLARE_DENSE_COUNT_NONZEROS_KERNEL(ValueType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
Expand Down Expand Up @@ -349,12 +324,6 @@ GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_CSR_CONVERT_TO_COO_KERNEL);

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

template <typename ValueType, typename IndexType>
GKO_DECLARE_CSR_CONVERT_TO_SELLP_KERNEL(ValueType, IndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
Expand Down Expand Up @@ -431,17 +400,6 @@ GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
GKO_DECLARE_COO_CONVERT_TO_DENSE_KERNEL);

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

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


} // namespace coo

Expand Down
26 changes: 0 additions & 26 deletions core/matrix/coo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ GKO_REGISTER_OPERATION(spmv2, coo::spmv2);
GKO_REGISTER_OPERATION(advanced_spmv2, coo::advanced_spmv2);
GKO_REGISTER_OPERATION(convert_to_csr, coo::convert_to_csr);
GKO_REGISTER_OPERATION(convert_to_dense, coo::convert_to_dense);
GKO_REGISTER_OPERATION(transpose, coo::transpose);
GKO_REGISTER_OPERATION(conj_transpose, coo::conj_transpose);


} // namespace coo
Expand Down Expand Up @@ -192,30 +190,6 @@ void Coo<ValueType, IndexType>::write(mat_data &data) const
}


template <typename ValueType, typename IndexType>
std::unique_ptr<LinOp> Coo<ValueType, IndexType>::transpose() const
{
auto exec = this->get_executor();
auto trans_cpy = Coo::create(exec, gko::transpose(this->get_size()),
this->get_num_stored_elements());

exec->run(coo::make_transpose(trans_cpy.get(), this));
return std::move(trans_cpy);
}


template <typename ValueType, typename IndexType>
std::unique_ptr<LinOp> Coo<ValueType, IndexType>::conj_transpose() const
{
auto exec = this->get_executor();
auto trans_cpy = Coo::create(exec, gko::transpose(this->get_size()),
this->get_num_stored_elements());

exec->run(coo::make_conj_transpose(trans_cpy.get(), this));
return std::move(trans_cpy);
}


#define GKO_DECLARE_COO_MATRIX(ValueType, IndexType) \
class Coo<ValueType, IndexType>
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_COO_MATRIX);
Expand Down
40 changes: 13 additions & 27 deletions core/matrix/coo_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,19 @@ namespace kernels {
matrix::Csr<ValueType, IndexType> *result, \
const matrix::Coo<ValueType, IndexType> *source)

#define GKO_DECLARE_COO_TRANSPOSE_KERNEL(ValueType, IndexType) \
void transpose(std::shared_ptr<const DefaultExecutor> exec, \
matrix::Coo<ValueType, IndexType> *trans, \
const matrix::Coo<ValueType, IndexType> *orig)

#define GKO_DECLARE_COO_CONJ_TRANSPOSE_KERNEL(ValueType, IndexType) \
void conj_transpose(std::shared_ptr<const DefaultExecutor> exec, \
matrix::Coo<ValueType, IndexType> *trans, \
const matrix::Coo<ValueType, IndexType> *orig)

#define GKO_DECLARE_ALL_AS_TEMPLATES \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_SPMV_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_ADVANCED_SPMV_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_SPMV2_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_ADVANCED_SPMV2_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_CONVERT_TO_CSR_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_CONVERT_TO_DENSE_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_TRANSPOSE_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_CONJ_TRANSPOSE_KERNEL(ValueType, IndexType)
#define GKO_DECLARE_ALL_AS_TEMPLATES \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_SPMV_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_ADVANCED_SPMV_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_SPMV2_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_ADVANCED_SPMV2_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_CONVERT_TO_CSR_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_COO_CONVERT_TO_DENSE_KERNEL(ValueType, IndexType)


namespace omp {
Expand Down
16 changes: 3 additions & 13 deletions core/matrix/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/base/utils.hpp>
#include <ginkgo/core/matrix/coo.hpp>
#include <ginkgo/core/matrix/dense.hpp>
#include <ginkgo/core/matrix/sellp.hpp>
#include <ginkgo/core/matrix/ell.hpp>
#include <ginkgo/core/matrix/sellp.hpp>


#include "core/matrix/csr_kernels.hpp"
Expand All @@ -55,7 +55,6 @@ GKO_REGISTER_OPERATION(spmv, csr::spmv);
GKO_REGISTER_OPERATION(advanced_spmv, csr::advanced_spmv);
GKO_REGISTER_OPERATION(convert_to_coo, csr::convert_to_coo);
GKO_REGISTER_OPERATION(convert_to_dense, csr::convert_to_dense);
GKO_REGISTER_OPERATION(move_to_dense, csr::move_to_dense);
GKO_REGISTER_OPERATION(convert_to_sellp, csr::convert_to_sellp);
GKO_REGISTER_OPERATION(calculate_total_cols, csr::calculate_total_cols);
GKO_REGISTER_OPERATION(convert_to_ell, csr::convert_to_ell);
Expand Down Expand Up @@ -103,13 +102,7 @@ void Csr<ValueType, IndexType>::convert_to(
template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::move_to(Coo<ValueType, IndexType> *result)
{
auto exec = this->get_executor();
auto tmp = Coo<ValueType, IndexType>::create(
exec, this->get_size(), this->get_num_stored_elements());
tmp->values_ = std::move(this->values_);
tmp->col_idxs_ = std::move(this->col_idxs_);
exec->run(csr::make_convert_to_coo(tmp.get(), this));
tmp->move_to(result);
this->convert_to(result);
}


Expand All @@ -126,10 +119,7 @@ void Csr<ValueType, IndexType>::convert_to(Dense<ValueType> *result) const
template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::move_to(Dense<ValueType> *result)
{
auto exec = this->get_executor();
auto tmp = Dense<ValueType>::create(exec, this->get_size());
exec->run(csr::make_move_to_dense(tmp.get(), this));
tmp->move_to(result);
this->convert_to(result);
}


Expand Down
7 changes: 0 additions & 7 deletions core/matrix/csr_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ namespace kernels {
matrix::Dense<ValueType> *result, \
const matrix::Csr<ValueType, IndexType> *source)

#define GKO_DECLARE_CSR_MOVE_TO_DENSE_KERNEL(ValueType, IndexType) \
void move_to_dense(std::shared_ptr<const DefaultExecutor> exec, \
matrix::Dense<ValueType> *result, \
matrix::Csr<ValueType, IndexType> *source)

#define GKO_DECLARE_CSR_CONVERT_TO_COO_KERNEL(ValueType, IndexType) \
void convert_to_coo(std::shared_ptr<const DefaultExecutor> exec, \
matrix::Coo<ValueType, IndexType> *result, \
Expand Down Expand Up @@ -113,8 +108,6 @@ namespace kernels {
template <typename ValueType, typename IndexType> \
GKO_DECLARE_CSR_CONVERT_TO_DENSE_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_CSR_MOVE_TO_DENSE_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_CSR_CONVERT_TO_COO_KERNEL(ValueType, IndexType); \
template <typename ValueType, typename IndexType> \
GKO_DECLARE_CSR_CONVERT_TO_SELLP_KERNEL(ValueType, IndexType); \
Expand Down
46 changes: 10 additions & 36 deletions core/matrix/dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@ GKO_REGISTER_OPERATION(transpose, dense::transpose);
GKO_REGISTER_OPERATION(conj_transpose, dense::conj_transpose);
GKO_REGISTER_OPERATION(convert_to_coo, dense::convert_to_coo);
GKO_REGISTER_OPERATION(convert_to_csr, dense::convert_to_csr);
GKO_REGISTER_OPERATION(move_to_csr, dense::move_to_csr);
GKO_REGISTER_OPERATION(convert_to_ell, dense::convert_to_ell);
GKO_REGISTER_OPERATION(move_to_ell, dense::move_to_ell);
GKO_REGISTER_OPERATION(convert_to_hybrid, dense::convert_to_hybrid);
GKO_REGISTER_OPERATION(move_to_hybrid, dense::move_to_hybrid);
GKO_REGISTER_OPERATION(convert_to_sellp, dense::convert_to_sellp);
GKO_REGISTER_OPERATION(move_to_sellp, dense::move_to_sellp);


} // namespace dense
Expand Down Expand Up @@ -268,9 +264,7 @@ void Dense<ValueType>::convert_to(Coo<ValueType, int32> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Coo<ValueType, int32> *result)
{
conversion_helper(result, this,
dense::template make_convert_to_coo<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -287,9 +281,7 @@ void Dense<ValueType>::convert_to(Coo<ValueType, int64> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Coo<ValueType, int64> *result)
{
conversion_helper(result, this,
dense::template make_convert_to_coo<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -307,10 +299,7 @@ void Dense<ValueType>::convert_to(Csr<ValueType, int32> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Csr<ValueType, int32> *result)
{
conversion_helper(result, this,
dense::template make_move_to_csr<decltype(result),
Dense<ValueType> *&>);
result->make_srow();
this->convert_to(result);
}


Expand All @@ -328,10 +317,7 @@ void Dense<ValueType>::convert_to(Csr<ValueType, int64> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Csr<ValueType, int64> *result)
{
conversion_helper(result, this,
dense::template make_move_to_csr<decltype(result),
Dense<ValueType> *&>);
result->make_srow();
this->convert_to(result);
}


Expand All @@ -348,9 +334,7 @@ void Dense<ValueType>::convert_to(Ell<ValueType, int32> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Ell<ValueType, int32> *result)
{
conversion_helper(result, this,
dense::template make_move_to_ell<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -367,9 +351,7 @@ void Dense<ValueType>::convert_to(Ell<ValueType, int64> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Ell<ValueType, int64> *result)
{
conversion_helper(result, this,
dense::template make_move_to_ell<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -386,9 +368,7 @@ void Dense<ValueType>::convert_to(Hybrid<ValueType, int32> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Hybrid<ValueType, int32> *result)
{
conversion_helper(result, this,
dense::template make_move_to_hybrid<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -405,9 +385,7 @@ void Dense<ValueType>::convert_to(Hybrid<ValueType, int64> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Hybrid<ValueType, int64> *result)
{
conversion_helper(result, this,
dense::template make_move_to_hybrid<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -424,9 +402,7 @@ void Dense<ValueType>::convert_to(Sellp<ValueType, int32> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Sellp<ValueType, int32> *result)
{
conversion_helper(result, this,
dense::template make_move_to_sellp<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand All @@ -443,9 +419,7 @@ void Dense<ValueType>::convert_to(Sellp<ValueType, int64> *result) const
template <typename ValueType>
void Dense<ValueType>::move_to(Sellp<ValueType, int64> *result)
{
conversion_helper(result, this,
dense::template make_move_to_sellp<decltype(result),
Dense<ValueType> *&>);
this->convert_to(result);
}


Expand Down
Loading