Skip to content

Commit

Permalink
add GKO_INDIRECT to properly expand the __VA_ARGS__ in msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Nov 21, 2024
1 parent c14d27b commit c645d8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
22 changes: 11 additions & 11 deletions core/base/batch_instantiation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ namespace batch {
// just make the call list more consistent
#define GKO_CALL(_macro, ...) _macro(__VA_ARGS__)

#define GKO_BATCH_INSTANTIATE_PRECONDITIONER(_next, ...) \
_next(__VA_ARGS__, gko::batch::matrix::Identity); \
_next(__VA_ARGS__, gko::batch::preconditioner::Jacobi)
#define GKO_BATCH_INSTANTIATE_PRECONDITIONER(_next, ...) \
_next(GKO_INDIRECT(__VA_ARGS__), gko::batch::matrix::Identity); \
_next(GKO_INDIRECT(__VA_ARGS__), gko::batch::preconditioner::Jacobi)

#define GKO_BATCH_INSTANTIATE_MATRIX(_next, ...) \
_next(__VA_ARGS__, gko::batch::matrix::Ell); \
_next(__VA_ARGS__, gko::batch::matrix::Dense); \
_next(__VA_ARGS__, gko::batch::matrix::Csr)
#define GKO_BATCH_INSTANTIATE_MATRIX(_next, ...) \
_next(GKO_INDIRECT(__VA_ARGS__), gko::batch::matrix::Ell); \
_next(GKO_INDIRECT(__VA_ARGS__), gko::batch::matrix::Dense); \
_next(GKO_INDIRECT(__VA_ARGS__), gko::batch::matrix::Csr)

/**
* Instantiates a template for each valid combination of value type, batch
Expand All @@ -42,10 +42,10 @@ namespace batch {
*
* @note the second and third arguments only accept the base type.s
*/
#define GKO_INSTANTIATE_FOR_BATCH_VALUE_MATRIX_PRECONDITIONER(...) \
GKO_CALL(GKO_BATCH_INSTANTIATE_MATRIX, \
GKO_BATCH_INSTANTIATE_PRECONDITIONER, \
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_VARGS, __VA_ARGS__)
#define GKO_INSTANTIATE_FOR_BATCH_VALUE_MATRIX_PRECONDITIONER(...) \
GKO_CALL( \
GKO_BATCH_INSTANTIATE_MATRIX, GKO_BATCH_INSTANTIATE_PRECONDITIONER, \
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_VARGS, GKO_INDIRECT(__VA_ARGS__))


} // namespace batch
Expand Down
23 changes: 12 additions & 11 deletions core/solver/batch_dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,27 @@ enum class log_type { simple_convergence_completion };


#define GKO_BATCH_INSTANTIATE_STOP(_next, ...) \
_next(__VA_ARGS__, \
_next(GKO_INDIRECT(__VA_ARGS__), \
::gko::batch::solver::device::batch_stop::SimpleAbsResidual); \
_next(__VA_ARGS__, \
_next(GKO_INDIRECT(__VA_ARGS__), \
::gko::batch::solver::device::batch_stop::SimpleRelResidual)

#define GKO_BATCH_INSTANTIATE_DEVICE_PRECONDITIONER(_next, ...) \
_next(__VA_ARGS__, \
_next(GKO_INDIRECT(__VA_ARGS__), \
::gko::batch::solver::device::batch_preconditioner::Identity); \
_next(__VA_ARGS__, \
_next(GKO_INDIRECT(__VA_ARGS__), \
::gko::batch::solver::device::batch_preconditioner::ScalarJacobi); \
_next(__VA_ARGS__, \
_next(GKO_INDIRECT(__VA_ARGS__), \
::gko::batch::solver::device::batch_preconditioner::BlockJacobi)

#define GKO_BATCH_INSTANTIATE_LOGGER(_next, ...) \
_next(__VA_ARGS__, \
_next(GKO_INDIRECT(__VA_ARGS__), \
::gko::batch::solver::device::batch_log::SimpleFinalLogger)

#define GKO_BATCH_INSTANTIATE_MATRIX_BATCH(_next, ...) \
_next(__VA_ARGS__, batch::matrix::ell::uniform_batch); \
_next(__VA_ARGS__, batch::matrix::dense::uniform_batch); \
_next(__VA_ARGS__, batch::matrix::csr::uniform_batch)
#define GKO_BATCH_INSTANTIATE_MATRIX_BATCH(_next, ...) \
_next(GKO_INDIRECT(__VA_ARGS__), batch::matrix::ell::uniform_batch); \
_next(GKO_INDIRECT(__VA_ARGS__), batch::matrix::dense::uniform_batch); \
_next(GKO_INDIRECT(__VA_ARGS__), batch::matrix::csr::uniform_batch)

/**
* Passes each valid configuration of batch solver template parameter to a
Expand All @@ -199,7 +199,8 @@ enum class log_type { simple_convergence_completion };
GKO_CALL(GKO_BATCH_INSTANTIATE_MATRIX_BATCH, GKO_BATCH_INSTANTIATE_LOGGER, \
GKO_BATCH_INSTANTIATE_DEVICE_PRECONDITIONER, \
GKO_BATCH_INSTANTIATE_STOP, \
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_VARGS, __VA_ARGS__)
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE_VARGS, \
GKO_INDIRECT(__VA_ARGS__))

/**
* Handles dispatching to the correct instantiation of a batched solver
Expand Down

0 comments on commit c645d8e

Please sign in to comment.