Skip to content

Commit

Permalink
Fixup explicit instantiations for taylor_adaptive_batch, another MSVC…
Browse files Browse the repository at this point in the history
… attempt.
  • Loading branch information
bluescarni committed Dec 7, 2023
1 parent 3a6d5e9 commit 0ed7c4a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 58 deletions.
2 changes: 1 addition & 1 deletion include/heyoka/detail/fwd_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template <typename>
class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive;

template <typename>
class HEYOKA_DLL_PUBLIC taylor_adaptive_batch;
class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_batch;

namespace detail
{
Expand Down
37 changes: 23 additions & 14 deletions include/heyoka/taylor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ class HEYOKA_DLL_PUBLIC continuous_output_batch
static_assert(detail::is_supported_fp_v<T>, "Unhandled type.");

template <typename>
friend class HEYOKA_DLL_PUBLIC taylor_adaptive_batch;
friend class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_batch;

friend std::ostream &detail::c_out_batch_stream_impl<T>(std::ostream &, const continuous_output_batch<T> &);

Expand Down Expand Up @@ -1050,9 +1050,8 @@ class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive : public detail::taylor_ada
// NOTE: apparently on Windows we need to re-iterate
// here that this is going to be dll-exported.
template <typename U>
HEYOKA_DLL_PUBLIC void finalise_ctor_impl(const U &, std::vector<T>, std::optional<T>, std::optional<T>, bool, bool,
std::vector<T>, std::vector<t_event_t>, std::vector<nt_event_t>, bool,
std::optional<long long>);
void finalise_ctor_impl(const U &, std::vector<T>, std::optional<T>, std::optional<T>, bool, bool, std::vector<T>,
std::vector<t_event_t>, std::vector<nt_event_t>, bool, std::optional<long long>);
template <typename U, typename... KwArgs>
void finalise_ctor(const U &sys, std::vector<T> state, KwArgs &&...kw_args)
{
Expand Down Expand Up @@ -1278,7 +1277,7 @@ namespace detail
// Parser for the common kwargs options for the propagate_*() functions
// for the batch integrator.
template <typename T, bool Grid, bool ForceScalarMaxDeltaT, typename... KwArgs>
inline auto taylor_propagate_common_ops_batch(std::uint32_t batch_size, KwArgs &&...kw_args)
inline auto taylor_propagate_common_ops_batch(std::uint32_t batch_size, const KwArgs &...kw_args)
{
assert(batch_size > 0u); // LCOV_EXCL_LINE

Expand Down Expand Up @@ -1381,7 +1380,7 @@ inline auto taylor_propagate_common_ops_batch(std::uint32_t batch_size, KwArgs &
} // namespace detail

template <typename T>
class HEYOKA_DLL_PUBLIC taylor_adaptive_batch
class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_batch
{
static_assert(detail::is_supported_fp_v<T>, "Unhandled type.");

Expand Down Expand Up @@ -1556,9 +1555,8 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive_batch

// Private implementation-detail constructor machinery.
template <typename U>
HEYOKA_DLL_PUBLIC void finalise_ctor_impl(const U &, std::vector<T>, std::uint32_t, std::vector<T>,
std::optional<T>, bool, bool, std::vector<T>, std::vector<t_event_t>,
std::vector<nt_event_t>, bool);
void finalise_ctor_impl(const U &, std::vector<T>, std::uint32_t, std::vector<T>, std::optional<T>, bool, bool,
std::vector<T>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);
template <typename U, typename... KwArgs>
void finalise_ctor(const U &sys, std::vector<T> state, std::uint32_t batch_size, KwArgs &&...kw_args)
{
Expand Down Expand Up @@ -1777,22 +1775,33 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive_batch
};

// Prevent implicit instantiations.
extern template class taylor_adaptive_batch<float>;
extern template class taylor_adaptive_batch<double>;
extern template class taylor_adaptive_batch<long double>;
#define HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(F) \
extern template class taylor_adaptive_batch<F>; \
extern template void taylor_adaptive_batch<F>::finalise_ctor_impl( \
const std::vector<expression> &, std::vector<F>, std::uint32_t, std::vector<F>, std::optional<F>, bool, bool, \
std::vector<F>, std::vector<t_event_t>, std::vector<nt_event_t>, bool); \
extern template void taylor_adaptive_batch<F>::finalise_ctor_impl( \
const std::vector<std::pair<expression, expression>> &, std::vector<F>, std::uint32_t, std::vector<F>, \
std::optional<F>, bool, bool, std::vector<F>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);

HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(float)
HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(double)
HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(long double)

#if defined(HEYOKA_HAVE_REAL128)

extern template class taylor_adaptive_batch<mppp::real128>;
HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(mppp::real128)

#endif

#if defined(HEYOKA_HAVE_REAL)

extern template class taylor_adaptive_batch<mppp::real>;
HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(mppp::real)

#endif

#undef HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST

template <typename T>
inline std::ostream &operator<<(std::ostream &os, const taylor_adaptive<T> &)
{
Expand Down
58 changes: 15 additions & 43 deletions src/taylor_00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4220,53 +4220,25 @@ void taylor_adaptive_batch<T>::reset_cooldowns(std::uint32_t i)
}

// Explicit instantiation of the batch implementation classes.
template class taylor_adaptive_batch<float>;

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<float>::finalise_ctor_impl(
const std::vector<expression> &, std::vector<float>, std::uint32_t, std::vector<float>, std::optional<float>, bool,
bool, std::vector<float>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<float>::finalise_ctor_impl(
const std::vector<std::pair<expression, expression>> &, std::vector<float>, std::uint32_t, std::vector<float>,
std::optional<float>, bool, bool, std::vector<float>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);

template class taylor_adaptive_batch<double>;

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<double>::finalise_ctor_impl(
const std::vector<expression> &, std::vector<double>, std::uint32_t, std::vector<double>, std::optional<double>,
bool, bool, std::vector<double>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<double>::finalise_ctor_impl(
const std::vector<std::pair<expression, expression>> &, std::vector<double>, std::uint32_t, std::vector<double>,
std::optional<double>, bool, bool, std::vector<double>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);

template class taylor_adaptive_batch<long double>;

template HEYOKA_DLL_PUBLIC void
taylor_adaptive_batch<long double>::finalise_ctor_impl(const std::vector<expression> &, std::vector<long double>,
std::uint32_t, std::vector<long double>,
std::optional<long double>, bool, bool, std::vector<long double>,
std::vector<t_event_t>, std::vector<nt_event_t>, bool);

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<long double>::finalise_ctor_impl(
const std::vector<std::pair<expression, expression>> &, std::vector<long double>, std::uint32_t,
std::vector<long double>, std::optional<long double>, bool, bool, std::vector<long double>, std::vector<t_event_t>,
std::vector<nt_event_t>, bool);
#define HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(F) \
template class HEYOKA_DLL_PUBLIC taylor_adaptive_batch<F>; \
template void taylor_adaptive_batch<F>::finalise_ctor_impl( \
const std::vector<expression> &, std::vector<F>, std::uint32_t, std::vector<F>, std::optional<F>, bool, bool, \
std::vector<F>, std::vector<t_event_t>, std::vector<nt_event_t>, bool); \
template void taylor_adaptive_batch<F>::finalise_ctor_impl( \
const std::vector<std::pair<expression, expression>> &, std::vector<F>, std::uint32_t, std::vector<F>, \
std::optional<F>, bool, bool, std::vector<F>, std::vector<t_event_t>, std::vector<nt_event_t>, bool);

HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(float)
HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(double)
HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(long double)

#if defined(HEYOKA_HAVE_REAL128)

template class taylor_adaptive_batch<mppp::real128>;

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<mppp::real128>::finalise_ctor_impl(
const std::vector<expression> &, std::vector<mppp::real128>, std::uint32_t, std::vector<mppp::real128>,
std::optional<mppp::real128>, bool, bool, std::vector<mppp::real128>, std::vector<t_event_t>,
std::vector<nt_event_t>, bool);

template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch<mppp::real128>::finalise_ctor_impl(
const std::vector<std::pair<expression, expression>> &, std::vector<mppp::real128>, std::uint32_t,
std::vector<mppp::real128>, std::optional<mppp::real128>, bool, bool, std::vector<mppp::real128>,
std::vector<t_event_t>, std::vector<nt_event_t>, bool);
HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(mppp::real128)

#endif

#undef HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST

HEYOKA_END_NAMESPACE

0 comments on commit 0ed7c4a

Please sign in to comment.