Skip to content

Commit

Permalink
add virtual function to the class such that the dynamic_cast works ou…
Browse files Browse the repository at this point in the history
…t of the shared library

marking the class final might lead the issue in clang/msys2/windows?
  • Loading branch information
yhmtsai committed Nov 13, 2024
1 parent 9737d73 commit 10e799e
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/matrix/batch_csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ void Csr<ValueType, IndexType>::move_to(
this->convert_to(result);
}

template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_CSR_MATRIX(ValueType) class Csr<ValueType, int32>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_CSR_MATRIX);
Expand Down
5 changes: 5 additions & 0 deletions core/matrix/batch_dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ void Dense<ValueType>::move_to(Dense<next_precision<ValueType>>* result)
}


template <typename ValueType>
void Dense<ValueType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_DENSE_MATRIX(_type) class Dense<_type>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_DENSE_MATRIX);

Expand Down
5 changes: 5 additions & 0 deletions core/matrix/batch_ell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ void Ell<ValueType, IndexType>::move_to(
}


template <typename ValueType, typename IndexType>
void Ell<ValueType, IndexType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_ELL_MATRIX(ValueType) class Ell<ValueType, int32>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_ELL_MATRIX);

Expand Down
5 changes: 5 additions & 0 deletions core/matrix/batch_identity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ void Identity<ValueType>::apply_impl(const MultiVector<ValueType>* alpha,
}


template <typename ValueType>
void Identity<ValueType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_IDENTITY_MATRIX(ValueType) class Identity<ValueType>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_IDENTITY_MATRIX);

Expand Down
5 changes: 5 additions & 0 deletions core/matrix/scaled_permutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ void ScaledPermutation<ValueType, IndexType>::write(
}


template <typename ValueType, typename IndexType>
void ScaledPermutation<ValueType, IndexType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_SCALED_PERMUTATION_MATRIX(ValueType, IndexType) \
class ScaledPermutation<ValueType, IndexType>
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(
Expand Down
5 changes: 5 additions & 0 deletions core/preconditioner/batch_jacobi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ void Jacobi<ValueType, IndexType>::generate_precond(
}


template <typename ValueType, typename IndexType>
void Jacobi<ValueType, IndexType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_JACOBI(_type) class Jacobi<_type, int32>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_JACOBI);

Expand Down
5 changes: 5 additions & 0 deletions core/solver/batch_bicgstab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ void Bicgstab<ValueType>::solver_apply(
}


template <typename ValueType>
void Bicgstab<ValueType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_BICGSTAB(_type) class Bicgstab<_type>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_BICGSTAB);

Expand Down
5 changes: 5 additions & 0 deletions core/solver/batch_cg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ void Cg<ValueType>::solver_apply(
}


template <typename ValueType>
void Cg<ValueType>::dynamic_cast_helper() const
{}


#define GKO_DECLARE_BATCH_CG(_type) class Cg<_type>
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_BATCH_CG);

Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/matrix/batch_csr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ class Csr final
const MultiVector<value_type>* beta,
MultiVector<value_type>* x) const;

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;

array<value_type> values_;
array<index_type> col_idxs_;
array<index_type> row_ptrs_;
Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/matrix/batch_dense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ class Dense final : public EnableBatchLinOp<Dense<ValueType>>,
idx % this->get_common_size()[1]);
}

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;

array<value_type> values_;
};

Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/matrix/batch_ell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ class Ell final
const MultiVector<value_type>* beta,
MultiVector<value_type>* x) const;

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;

index_type num_elems_per_row_;
array<value_type> values_;
array<index_type> col_idxs_;
Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/matrix/batch_identity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class Identity final : public EnableBatchLinOp<Identity<ValueType>> {
const MultiVector<value_type>* b,
const MultiVector<value_type>* beta,
MultiVector<value_type>* x) const;

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;
};


Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/matrix/scaled_permutation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class ScaledPermutation final
void apply_impl(const LinOp*, const LinOp* in, const LinOp*,
LinOp* out) const override;

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;

array<value_type> scale_;
array<index_type> permutation_;
};
Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/preconditioner/batch_jacobi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ class Jacobi final : public EnableBatchLinOp<Jacobi<ValueType, IndexType>> {
void detect_blocks(
const gko::matrix::Csr<ValueType, IndexType>* system_matrix);

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;

array<index_type> block_pointers_;
size_type num_blocks_;
array<value_type> blocks_;
Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/solver/batch_bicgstab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class Bicgstab final
void solver_apply(
const MultiVector<ValueType>* b, MultiVector<ValueType>* x,
log::detail::log_data<real_type>* log_data) const override;

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;
};


Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/solver/batch_cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class Cg final : public EnableBatchSolver<Cg<ValueType>, ValueType> {
void solver_apply(
const MultiVector<ValueType>* b, MultiVector<ValueType>* x,
log::detail::log_data<real_type>* log_data) const override;

// helper to ensure dynamic_cast work properly out of shared library
virtual void dynamic_cast_helper() const;
};


Expand Down

0 comments on commit 10e799e

Please sign in to comment.