diff --git a/include/heyoka/detail/fwd_decl.hpp b/include/heyoka/detail/fwd_decl.hpp index 01ae54dd9..87a3a272b 100644 --- a/include/heyoka/detail/fwd_decl.hpp +++ b/include/heyoka/detail/fwd_decl.hpp @@ -28,19 +28,19 @@ class HEYOKA_DLL_PUBLIC param; class HEYOKA_DLL_PUBLIC llvm_state; template -class HEYOKA_DLL_PUBLIC taylor_adaptive; +class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive; template -class HEYOKA_DLL_PUBLIC taylor_adaptive_batch; +class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_batch; namespace detail { template -class HEYOKA_DLL_PUBLIC nt_event_impl; +class HEYOKA_DLL_PUBLIC_INLINE_CLASS nt_event_impl; template -class HEYOKA_DLL_PUBLIC t_event_impl; +class HEYOKA_DLL_PUBLIC_INLINE_CLASS t_event_impl; } // namespace detail diff --git a/include/heyoka/ensemble_propagate.hpp b/include/heyoka/ensemble_propagate.hpp index 396af24cd..100159991 100644 --- a/include/heyoka/ensemble_propagate.hpp +++ b/include/heyoka/ensemble_propagate.hpp @@ -24,8 +24,13 @@ #endif +#if defined(HEYOKA_HAVE_REAL) + +#include + +#endif + #include -#include #include #include @@ -35,25 +40,60 @@ namespace detail { template -HEYOKA_DLL_PUBLIC - std::vector, taylor_outcome, T, T, std::size_t, std::optional>>> - ensemble_propagate_until_impl(const taylor_adaptive &, T, std::size_t, - const std::function(taylor_adaptive, std::size_t)> &, - std::size_t, T, step_callback &, bool, bool); +std::vector, taylor_outcome, T, T, std::size_t, std::optional>>> +ensemble_propagate_until_impl(const taylor_adaptive &, T, std::size_t, + const std::function(taylor_adaptive, std::size_t)> &, std::size_t, + T, step_callback &, bool, bool); template -HEYOKA_DLL_PUBLIC - std::vector, taylor_outcome, T, T, std::size_t, std::optional>>> - ensemble_propagate_for_impl(const taylor_adaptive &, T, std::size_t, - const std::function(taylor_adaptive, std::size_t)> &, std::size_t, - T, step_callback &, bool, bool); +std::vector, taylor_outcome, T, T, std::size_t, std::optional>>> +ensemble_propagate_for_impl(const taylor_adaptive &, T, std::size_t, + const std::function(taylor_adaptive, std::size_t)> &, std::size_t, T, + step_callback &, bool, bool); template -HEYOKA_DLL_PUBLIC std::vector, taylor_outcome, T, T, std::size_t, std::vector>> +std::vector, taylor_outcome, T, T, std::size_t, std::vector>> ensemble_propagate_grid_impl(const taylor_adaptive &, std::vector, std::size_t, const std::function(taylor_adaptive, std::size_t)> &, std::size_t, T, step_callback &); +// Prevent implicit instantiations. +// NOLINTBEGIN +#define HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_SCALAR_INST(T) \ + extern template std::vector< \ + std::tuple, taylor_outcome, T, T, std::size_t, std::optional>>> \ + ensemble_propagate_until_impl(const taylor_adaptive &, T, std::size_t, \ + const std::function(taylor_adaptive, std::size_t)> &, \ + std::size_t, T, step_callback &, bool, bool); \ + \ + extern template std::vector< \ + std::tuple, taylor_outcome, T, T, std::size_t, std::optional>>> \ + ensemble_propagate_for_impl(const taylor_adaptive &, T, std::size_t, \ + const std::function(taylor_adaptive, std::size_t)> &, \ + std::size_t, T, step_callback &, bool, bool); \ + \ + extern template std::vector, taylor_outcome, T, T, std::size_t, std::vector>> \ + ensemble_propagate_grid_impl(const taylor_adaptive &, std::vector, std::size_t, \ + const std::function(taylor_adaptive, std::size_t)> &, \ + std::size_t, T, step_callback &); +// NOLINTEND + +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_SCALAR_INST(float) +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_SCALAR_INST(double) +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_SCALAR_INST(long double) + +#if defined(HEYOKA_HAVE_REAL128) + +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_SCALAR_INST(mppp::real128) + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_SCALAR_INST(mppp::real) + +#endif + } // namespace detail template @@ -101,25 +141,63 @@ namespace detail { template -HEYOKA_DLL_PUBLIC std::vector, std::optional>>> +std::vector, std::optional>>> ensemble_propagate_until_batch_impl( const taylor_adaptive_batch &, T, std::size_t, const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, const std::vector &, step_callback_batch &, bool, bool); template -HEYOKA_DLL_PUBLIC std::vector, std::optional>>> +std::vector, std::optional>>> ensemble_propagate_for_batch_impl( const taylor_adaptive_batch &, T, std::size_t, const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, const std::vector &, step_callback_batch &, bool, bool); template -HEYOKA_DLL_PUBLIC std::vector, std::vector>> ensemble_propagate_grid_batch_impl( +std::vector, std::vector>> ensemble_propagate_grid_batch_impl( const taylor_adaptive_batch &, const std::vector &, std::size_t, const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, const std::vector &, step_callback_batch &); +// Prevent implicit instantiations. +// NOLINTBEGIN +#define HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_BATCH_INST(T) \ + extern template std::vector, std::optional>>> \ + ensemble_propagate_until_batch_impl( \ + const taylor_adaptive_batch &, T, std::size_t, \ + const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, \ + const std::vector &, step_callback_batch &, bool, bool); \ + \ + extern template std::vector, std::optional>>> \ + ensemble_propagate_for_batch_impl( \ + const taylor_adaptive_batch &, T, std::size_t, \ + const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, \ + const std::vector &, step_callback_batch &, bool, bool); \ + \ + extern template std::vector, std::vector>> \ + ensemble_propagate_grid_batch_impl( \ + const taylor_adaptive_batch &, const std::vector &, std::size_t, \ + const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, \ + const std::vector &, step_callback_batch &); +// NOLINTEND + +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_BATCH_INST(float) +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_BATCH_INST(double) +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_BATCH_INST(long double) + +#if defined(HEYOKA_HAVE_REAL128) + +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_BATCH_INST(mppp::real128) + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +HEYOKA_ENSEMBLE_PROPAGATE_EXTERN_BATCH_INST(mppp::real) + +#endif + } // namespace detail template diff --git a/include/heyoka/expression.hpp b/include/heyoka/expression.hpp index 10a79e8f5..9783a709e 100644 --- a/include/heyoka/expression.hpp +++ b/include/heyoka/expression.hpp @@ -725,13 +725,39 @@ namespace detail { template -HEYOKA_DLL_PUBLIC std::vector add_cfunc(llvm_state &, const std::string &, const std::vector &, - std::uint32_t, bool, bool, bool, long long); +std::vector add_cfunc(llvm_state &, const std::string &, const std::vector &, std::uint32_t, + bool, bool, bool, long long); template -HEYOKA_DLL_PUBLIC std::vector add_cfunc(llvm_state &, const std::string &, const std::vector &, - const std::vector &, std::uint32_t, bool, bool, bool, - long long); +std::vector add_cfunc(llvm_state &, const std::string &, const std::vector &, + const std::vector &, std::uint32_t, bool, bool, bool, long long); + +// Prevent implicit instantiations. +#define HEYOKA_CFUNC_EXTERN_INST(T) \ + extern template std::vector add_cfunc(llvm_state &, const std::string &, \ + const std::vector &, std::uint32_t, bool, bool, \ + bool, long long); \ + extern template std::vector add_cfunc( \ + llvm_state &, const std::string &, const std::vector &, const std::vector &, \ + std::uint32_t, bool, bool, bool, long long); + +HEYOKA_CFUNC_EXTERN_INST(float) +HEYOKA_CFUNC_EXTERN_INST(double) +HEYOKA_CFUNC_EXTERN_INST(long double) + +#if defined(HEYOKA_HAVE_REAL128) + +HEYOKA_CFUNC_EXTERN_INST(mppp::real128) + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +HEYOKA_CFUNC_EXTERN_INST(mppp::real) + +#endif + +#undef HEYOKA_CFUNC_EXTERN_INST } // namespace detail diff --git a/include/heyoka/taylor.hpp b/include/heyoka/taylor.hpp index 30894b894..1ec3a64f5 100644 --- a/include/heyoka/taylor.hpp +++ b/include/heyoka/taylor.hpp @@ -142,15 +142,41 @@ HEYOKA_DLL_PUBLIC std::pair> taylor_decompose(const std::vector> &, const std::vector &); template -HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, const std::vector &, - std::uint32_t, std::uint32_t, bool, bool, - const std::vector & = {}, bool = false, long long = 0); +taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, const std::vector &, std::uint32_t, + std::uint32_t, bool, bool, const std::vector & = {}, bool = false, + long long = 0); template -HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector> &, std::uint32_t, - std::uint32_t, bool, bool, const std::vector & = {}, - bool = false, long long = 0); +taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, const std::vector> &, + std::uint32_t, std::uint32_t, bool, bool, const std::vector & = {}, bool = false, + long long = 0); + +// Prevent implicit instantiations. +#define HEYOKA_TAYLOR_ADD_JET_EXTERN_INST(F) \ + extern template taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, const std::vector &, \ + std::uint32_t, std::uint32_t, bool, bool, \ + const std::vector &, bool, long long); \ + extern template taylor_dc_t taylor_add_jet( \ + llvm_state &, const std::string &, const std::vector> &, std::uint32_t, \ + std::uint32_t, bool, bool, const std::vector &, bool, long long); + +HEYOKA_TAYLOR_ADD_JET_EXTERN_INST(float) +HEYOKA_TAYLOR_ADD_JET_EXTERN_INST(double) +HEYOKA_TAYLOR_ADD_JET_EXTERN_INST(long double) + +#if defined(HEYOKA_HAVE_REAL128) + +HEYOKA_TAYLOR_ADD_JET_EXTERN_INST(mppp::real128) + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +HEYOKA_TAYLOR_ADD_JET_EXTERN_INST(mppp::real) + +#endif + +#undef HEYOKA_TAYLOR_ADD_JET_EXTERN_INST // Enum to represent the outcome of a stepping/propagate function. enum class taylor_outcome : std::int64_t { @@ -274,7 +300,7 @@ namespace detail // Helper for parsing common options for the Taylor integrators. template -inline auto taylor_adaptive_common_ops(KwArgs &&...kw_args) +inline auto taylor_adaptive_common_ops(const KwArgs &...kw_args) { igor::parser p{kw_args...}; @@ -341,7 +367,7 @@ inline auto taylor_adaptive_common_ops(KwArgs &&...kw_args) } template -class HEYOKA_DLL_PUBLIC nt_event_impl +class HEYOKA_DLL_PUBLIC_INLINE_CLASS nt_event_impl { static_assert(is_supported_fp_v, "Unhandled type."); @@ -370,7 +396,8 @@ class HEYOKA_DLL_PUBLIC nt_event_impl nt_event_impl(); template - explicit nt_event_impl(expression e, callback_t cb, KwArgs &&...kw_args) : eq(std::move(e)), callback(std::move(cb)) + explicit nt_event_impl(expression e, callback_t cb, const KwArgs &...kw_args) + : eq(std::move(e)), callback(std::move(cb)) { igor::parser p{kw_args...}; @@ -407,6 +434,29 @@ class HEYOKA_DLL_PUBLIC nt_event_impl [[nodiscard]] event_direction get_direction() const; }; +// Prevent implicit instantiations. +#define HEYOKA_NT_EVENT_EXTERN_INST(F) \ + extern template class nt_event_impl; \ + extern template class nt_event_impl; + +HEYOKA_NT_EVENT_EXTERN_INST(float) +HEYOKA_NT_EVENT_EXTERN_INST(double) +HEYOKA_NT_EVENT_EXTERN_INST(long double) + +#if defined(HEYOKA_HAVE_REAL128) + +HEYOKA_NT_EVENT_EXTERN_INST(mppp::real128) + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +HEYOKA_NT_EVENT_EXTERN_INST(mppp::real) + +#endif + +#undef HEYOKA_NT_EVENT_EXTERN_INST + template inline std::ostream &operator<<(std::ostream &os, const nt_event_impl &) { @@ -447,7 +497,7 @@ HEYOKA_DLL_PUBLIC std::ostream &operator<<(std::ostream &, const nt_event_impl -class HEYOKA_DLL_PUBLIC t_event_impl +class HEYOKA_DLL_PUBLIC_INLINE_CLASS t_event_impl { static_assert(is_supported_fp_v, "Unhandled type."); @@ -478,7 +528,7 @@ class HEYOKA_DLL_PUBLIC t_event_impl t_event_impl(); template - explicit t_event_impl(expression e, KwArgs &&...kw_args) : eq(std::move(e)) + explicit t_event_impl(expression e, const KwArgs &...kw_args) : eq(std::move(e)) { igor::parser p{kw_args...}; @@ -534,6 +584,29 @@ class HEYOKA_DLL_PUBLIC t_event_impl T get_cooldown() const; }; +// Prevent implicit instantiations. +#define HEYOKA_T_EVENT_EXTERN_INST(F) \ + extern template class t_event_impl; \ + extern template class t_event_impl; + +HEYOKA_T_EVENT_EXTERN_INST(float) +HEYOKA_T_EVENT_EXTERN_INST(double) +HEYOKA_T_EVENT_EXTERN_INST(long double) + +#if defined(HEYOKA_HAVE_REAL128) + +HEYOKA_T_EVENT_EXTERN_INST(mppp::real128) + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +HEYOKA_T_EVENT_EXTERN_INST(mppp::real) + +#endif + +#undef HEYOKA_T_EVENT_EXTERN_INST + template inline std::ostream &operator<<(std::ostream &os, const t_event_impl &) { @@ -588,7 +661,7 @@ template using t_event_batch = detail::t_event_impl; template -class HEYOKA_DLL_PUBLIC continuous_output; +class HEYOKA_DLL_PUBLIC_INLINE_CLASS continuous_output; namespace detail { @@ -599,12 +672,12 @@ std::ostream &c_out_stream_impl(std::ostream &, const continuous_output &); } // namespace detail template -class HEYOKA_DLL_PUBLIC continuous_output +class HEYOKA_DLL_PUBLIC_INLINE_CLASS continuous_output { static_assert(detail::is_supported_fp_v, "Unhandled type."); template - friend class HEYOKA_DLL_PUBLIC taylor_adaptive; + friend class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive; friend std::ostream &detail::c_out_stream_impl(std::ostream &, const continuous_output &); @@ -645,6 +718,23 @@ class HEYOKA_DLL_PUBLIC continuous_output [[nodiscard]] std::size_t get_n_steps() const; }; +// Prevent implicit instantiations. +extern template class continuous_output; +extern template class continuous_output; +extern template class continuous_output; + +#if defined(HEYOKA_HAVE_REAL128) + +extern template class continuous_output; + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +extern template class continuous_output; + +#endif + template inline std::ostream &operator<<(std::ostream &os, const continuous_output &) { @@ -677,7 +767,7 @@ HEYOKA_DLL_PUBLIC std::ostream &operator<<(std::ostream &, const continuous_outp #endif template -class HEYOKA_DLL_PUBLIC continuous_output_batch; +class HEYOKA_DLL_PUBLIC_INLINE_CLASS continuous_output_batch; namespace detail { @@ -688,12 +778,12 @@ std::ostream &c_out_batch_stream_impl(std::ostream &, const continuous_output_ba } // namespace detail template -class HEYOKA_DLL_PUBLIC continuous_output_batch +class HEYOKA_DLL_PUBLIC_INLINE_CLASS continuous_output_batch { static_assert(detail::is_supported_fp_v, "Unhandled type."); template - 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(std::ostream &, const continuous_output_batch &); @@ -742,6 +832,23 @@ class HEYOKA_DLL_PUBLIC continuous_output_batch [[nodiscard]] std::size_t get_n_steps() const; }; +// Prevent implicit instantiations. +extern template class continuous_output_batch; +extern template class continuous_output_batch; +extern template class continuous_output_batch; + +#if defined(HEYOKA_HAVE_REAL128) + +extern template class continuous_output_batch; + +#endif + +#if defined(HEYOKA_HAVE_REAL) + +extern template class continuous_output_batch; + +#endif + template inline std::ostream &operator<<(std::ostream &os, const continuous_output_batch &) { @@ -788,7 +895,7 @@ HEYOKA_DLL_PUBLIC T taylor_default_max_delta_t(); // Parser for the common kwargs options for the propagate_*() functions. template -inline auto taylor_propagate_common_ops(KwArgs &&...kw_args) +inline auto taylor_propagate_common_ops(const KwArgs &...kw_args) { igor::parser p{kw_args...}; @@ -867,7 +974,7 @@ inline auto taylor_propagate_common_ops(KwArgs &&...kw_args) // Base class to contain data specific to integrators of type // T. By default this is just an empty class. template -class HEYOKA_DLL_PUBLIC taylor_adaptive_base +class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_base { friend class boost::serialization::access; template @@ -879,7 +986,7 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive_base #if defined(HEYOKA_HAVE_REAL) template -class HEYOKA_DLL_PUBLIC taylor_adaptive_base +class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_base { friend class boost::serialization::access; template @@ -906,10 +1013,10 @@ void taylor_adaptive_setup_sv_rhs(TA &, const U &); } // namespace detail template -class HEYOKA_DLL_PUBLIC taylor_adaptive : public detail::taylor_adaptive_base> +class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive : public detail::taylor_adaptive_base> { static_assert(detail::is_supported_fp_v, "Unhandled type."); - friend class HEYOKA_DLL_PUBLIC detail::taylor_adaptive_base>; + friend class HEYOKA_DLL_PUBLIC_INLINE_CLASS detail::taylor_adaptive_base>; using base_t = detail::taylor_adaptive_base>; template friend void detail::taylor_adaptive_setup_sv_rhs(TA &, const U &); @@ -1049,9 +1156,8 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive : public detail::taylor_adaptive_base - HEYOKA_DLL_PUBLIC void finalise_ctor_impl(const U &, std::vector, std::optional, std::optional, bool, bool, - std::vector, std::vector, std::vector, bool, - std::optional); + void finalise_ctor_impl(const U &, std::vector, std::optional, std::optional, bool, bool, std::vector, + std::vector, std::vector, bool, std::optional); template void finalise_ctor(const U &sys, std::vector state, KwArgs &&...kw_args) { @@ -1241,29 +1347,43 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive : public detail::taylor_adaptive_base; -extern template class taylor_adaptive; -extern template class taylor_adaptive; +// NOLINTBEGIN +#define HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST(F) \ + extern template class detail::taylor_adaptive_base>; \ + extern template class taylor_adaptive; \ + extern template void taylor_adaptive::finalise_ctor_impl( \ + const std::vector &, std::vector, std::optional, std::optional, bool, bool, \ + std::vector, std::vector, std::vector, bool, std::optional); \ + extern template void taylor_adaptive::finalise_ctor_impl( \ + const std::vector> &, std::vector, std::optional, std::optional, \ + bool, bool, std::vector, std::vector, std::vector, bool, std::optional); +// NOLINTEND + +HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST(float) +HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST(double) +HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST(long double) #if defined(HEYOKA_HAVE_REAL128) -extern template class taylor_adaptive; +HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST(mppp::real128) #endif #if defined(HEYOKA_HAVE_REAL) -extern template class taylor_adaptive; +HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST(mppp::real) #endif +#undef HEYOKA_TAYLOR_ADAPTIVE_EXTERN_INST + namespace detail { // Parser for the common kwargs options for the propagate_*() functions // for the batch integrator. template -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 @@ -1366,7 +1486,7 @@ inline auto taylor_propagate_common_ops_batch(std::uint32_t batch_size, KwArgs & } // namespace detail template -class HEYOKA_DLL_PUBLIC taylor_adaptive_batch +class HEYOKA_DLL_PUBLIC_INLINE_CLASS taylor_adaptive_batch { static_assert(detail::is_supported_fp_v, "Unhandled type."); @@ -1541,9 +1661,8 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive_batch // Private implementation-detail constructor machinery. template - HEYOKA_DLL_PUBLIC void finalise_ctor_impl(const U &, std::vector, std::uint32_t, std::vector, - std::optional, bool, bool, std::vector, std::vector, - std::vector, bool); + void finalise_ctor_impl(const U &, std::vector, std::uint32_t, std::vector, std::optional, bool, bool, + std::vector, std::vector, std::vector, bool); template void finalise_ctor(const U &sys, std::vector state, std::uint32_t batch_size, KwArgs &&...kw_args) { @@ -1762,22 +1881,33 @@ class HEYOKA_DLL_PUBLIC taylor_adaptive_batch }; // Prevent implicit instantiations. -extern template class taylor_adaptive_batch; -extern template class taylor_adaptive_batch; -extern template class taylor_adaptive_batch; +#define HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(F) \ + extern template class taylor_adaptive_batch; \ + extern template void taylor_adaptive_batch::finalise_ctor_impl( \ + const std::vector &, std::vector, std::uint32_t, std::vector, std::optional, bool, bool, \ + std::vector, std::vector, std::vector, bool); \ + extern template void taylor_adaptive_batch::finalise_ctor_impl( \ + const std::vector> &, std::vector, std::uint32_t, std::vector, \ + std::optional, bool, bool, std::vector, std::vector, std::vector, 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; +HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(mppp::real128) #endif #if defined(HEYOKA_HAVE_REAL) -extern template class taylor_adaptive_batch; +HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST(mppp::real) #endif +#undef HEYOKA_TAYLOR_ADAPTIVE_BATCH_EXTERN_INST + template inline std::ostream &operator<<(std::ostream &os, const taylor_adaptive &) { diff --git a/src/detail/event_detection.cpp b/src/detail/event_detection.cpp index d66ba6b9a..a9d29f7d5 100644 --- a/src/detail/event_detection.cpp +++ b/src/detail/event_detection.cpp @@ -1432,7 +1432,7 @@ void taylor_adaptive::ed_data::detect_events(const T &h, std::uint32_t order, run_detection(m_d_ntes, m_ntes); } -// Instantiate the book-keeping structure for event detection +// Explicit instantiation of the book-keeping structures for event detection // in the scalar integrator. template struct taylor_adaptive::ed_data; template struct taylor_adaptive::ed_data; @@ -2129,7 +2129,7 @@ void taylor_adaptive_batch::ed_data::detect_events(const T *h_ptr, std::uint3 run_detection(m_d_ntes, m_ntes); } -// Instantiate the book-keeping structure for event detection +// Explicit instantiation of the book-keeping structures for event detection // in the batch integrator. template struct taylor_adaptive_batch::ed_data; template struct taylor_adaptive_batch::ed_data; diff --git a/src/ensemble_propagate.cpp b/src/ensemble_propagate.cpp index 9fbe54d77..75d55f2f4 100644 --- a/src/ensemble_propagate.cpp +++ b/src/ensemble_propagate.cpp @@ -198,21 +198,21 @@ ensemble_propagate_grid_impl(const taylor_adaptive &ta, std::vector grid, #define HEYOKA_ENSEMBLE_PROPAGATE_SCALAR_INST(T) \ template HEYOKA_DLL_PUBLIC std::vector< \ std::tuple, taylor_outcome, T, T, std::size_t, std::optional>>> \ - ensemble_propagate_until_impl(const taylor_adaptive &, T, std::size_t, \ - const std::function(taylor_adaptive, std::size_t)> &, \ - std::size_t, T, step_callback &, bool, bool); \ + ensemble_propagate_until_impl(const taylor_adaptive &, T, std::size_t, \ + const std::function(taylor_adaptive, std::size_t)> &, \ + std::size_t, T, step_callback &, bool, bool); \ \ template HEYOKA_DLL_PUBLIC std::vector< \ std::tuple, taylor_outcome, T, T, std::size_t, std::optional>>> \ - ensemble_propagate_for_impl(const taylor_adaptive &, T, std::size_t, \ - const std::function(taylor_adaptive, std::size_t)> &, \ - std::size_t, T, step_callback &, bool, bool); \ + ensemble_propagate_for_impl(const taylor_adaptive &, T, std::size_t, \ + const std::function(taylor_adaptive, std::size_t)> &, \ + std::size_t, T, step_callback &, bool, bool); \ \ template HEYOKA_DLL_PUBLIC \ std::vector, taylor_outcome, T, T, std::size_t, std::vector>> \ - ensemble_propagate_grid_impl(const taylor_adaptive &, std::vector, std::size_t, \ - const std::function(taylor_adaptive, std::size_t)> &, \ - std::size_t, T, step_callback &); + ensemble_propagate_grid_impl(const taylor_adaptive &, std::vector, std::size_t, \ + const std::function(taylor_adaptive, std::size_t)> &, \ + std::size_t, T, step_callback &); // NOLINTEND HEYOKA_ENSEMBLE_PROPAGATE_SCALAR_INST(float) @@ -231,6 +231,8 @@ HEYOKA_ENSEMBLE_PROPAGATE_SCALAR_INST(mppp::real) #endif +#undef HEYOKA_ENSEMBLE_PROPAGATE_SCALAR_INST + template std::vector, std::optional>>> ensemble_propagate_until_batch_impl( @@ -387,20 +389,20 @@ std::vector, std::vector>> ensemble_propa #define HEYOKA_ENSEMBLE_PROPAGATE_BATCH_INST(T) \ template HEYOKA_DLL_PUBLIC \ std::vector, std::optional>>> \ - ensemble_propagate_until_batch_impl( \ + ensemble_propagate_until_batch_impl( \ const taylor_adaptive_batch &, T, std::size_t, \ const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, \ const std::vector &, step_callback_batch &, bool, bool); \ \ template HEYOKA_DLL_PUBLIC \ std::vector, std::optional>>> \ - ensemble_propagate_for_batch_impl( \ + ensemble_propagate_for_batch_impl( \ const taylor_adaptive_batch &, T, std::size_t, \ const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, \ const std::vector &, step_callback_batch &, bool, bool); \ \ template HEYOKA_DLL_PUBLIC std::vector, std::vector>> \ - ensemble_propagate_grid_batch_impl( \ + ensemble_propagate_grid_batch_impl( \ const taylor_adaptive_batch &, const std::vector &, std::size_t, \ const std::function(taylor_adaptive_batch, std::size_t)> &, std::size_t, \ const std::vector &, step_callback_batch &); @@ -416,6 +418,8 @@ HEYOKA_ENSEMBLE_PROPAGATE_BATCH_INST(mppp::real128) #endif +#undef HEYOKA_ENSEMBLE_PROPAGATE_BATCH_INST + } // namespace detail HEYOKA_END_NAMESPACE diff --git a/src/taylor_00.cpp b/src/taylor_00.cpp index 935e20774..67c8bb197 100644 --- a/src/taylor_00.cpp +++ b/src/taylor_00.cpp @@ -2170,103 +2170,35 @@ const std::vector &taylor_adaptive::update_d_output(T time, bool rel_time) } // Explicit instantiation of the implementation classes/functions. -// NOTE: on Windows apparently it is necessary to declare that -// these instantiations are meant to be dll-exported. - -namespace detail -{ - -template class taylor_adaptive_base>; - -template class taylor_adaptive_base>; - -template class taylor_adaptive_base>; +// NOLINTBEGIN +#define HEYOKA_TAYLOR_ADAPTIVE_INST(F) \ + template class HEYOKA_DLL_PUBLIC detail::taylor_adaptive_base>; \ + template class HEYOKA_DLL_PUBLIC taylor_adaptive; \ + template HEYOKA_DLL_PUBLIC void taylor_adaptive::finalise_ctor_impl( \ + const std::vector &, std::vector, std::optional, std::optional, bool, bool, \ + std::vector, std::vector, std::vector, bool, std::optional); \ + template HEYOKA_DLL_PUBLIC void taylor_adaptive::finalise_ctor_impl( \ + const std::vector> &, std::vector, std::optional, std::optional, \ + bool, bool, std::vector, std::vector, std::vector, bool, std::optional); +// NOLINTEND + +HEYOKA_TAYLOR_ADAPTIVE_INST(float) +HEYOKA_TAYLOR_ADAPTIVE_INST(double) +HEYOKA_TAYLOR_ADAPTIVE_INST(long double) #if defined(HEYOKA_HAVE_REAL128) -template class taylor_adaptive_base>; +HEYOKA_TAYLOR_ADAPTIVE_INST(mppp::real128) #endif #if defined(HEYOKA_HAVE_REAL) -template class taylor_adaptive_base>; - -#endif - -} // namespace detail - -template class taylor_adaptive; - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive::finalise_ctor_impl(const std::vector &, std::vector, std::optional, - std::optional, bool, bool, std::vector, std::vector, - std::vector, bool, std::optional); - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive::finalise_ctor_impl(const std::vector> &, std::vector, - std::optional, std::optional, bool, bool, std::vector, - std::vector, std::vector, bool, - std::optional); - -template class taylor_adaptive; - -template HEYOKA_DLL_PUBLIC void taylor_adaptive::finalise_ctor_impl( - const std::vector &, std::vector, std::optional, std::optional, bool, bool, - std::vector, std::vector, std::vector, bool, std::optional); - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive::finalise_ctor_impl(const std::vector> &, std::vector, - std::optional, std::optional, bool, bool, - std::vector, std::vector, std::vector, bool, - std::optional); - -template class taylor_adaptive; - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive::finalise_ctor_impl(const std::vector &, std::vector, - std::optional, std::optional, bool, bool, - std::vector, std::vector, - std::vector, bool, std::optional); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive::finalise_ctor_impl( - const std::vector> &, std::vector, std::optional, - std::optional, bool, bool, std::vector, std::vector, std::vector, - bool, std::optional); - -#if defined(HEYOKA_HAVE_REAL128) - -template class taylor_adaptive; - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive::finalise_ctor_impl(const std::vector &, std::vector, - std::optional, std::optional, bool, - bool, std::vector, std::vector, - std::vector, bool, std::optional); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive::finalise_ctor_impl( - const std::vector> &, std::vector, std::optional, - std::optional, bool, bool, std::vector, std::vector, - std::vector, bool, std::optional); +HEYOKA_TAYLOR_ADAPTIVE_INST(mppp::real) #endif -#if defined(HEYOKA_HAVE_REAL) - -template class taylor_adaptive; - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive::finalise_ctor_impl(const std::vector &, std::vector, - std::optional, std::optional, bool, bool, - std::vector, std::vector, - std::vector, bool, std::optional); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive::finalise_ctor_impl( - const std::vector> &, std::vector, std::optional, - std::optional, bool, bool, std::vector, std::vector, std::vector, - bool, std::optional); - -#endif +#undef HEYOKA_TAYLOR_ADAPTIVE_INST template template @@ -4287,54 +4219,26 @@ void taylor_adaptive_batch::reset_cooldowns(std::uint32_t i) } } -// Explicit instantiation of the batch implementation classes. -template class taylor_adaptive_batch; +// Explicit instantiation of the batch implementation classes/functions. +#define HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(F) \ + template class HEYOKA_DLL_PUBLIC taylor_adaptive_batch; \ + template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( \ + const std::vector &, std::vector, std::uint32_t, std::vector, std::optional, bool, bool, \ + std::vector, std::vector, std::vector, bool); \ + template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( \ + const std::vector> &, std::vector, std::uint32_t, std::vector, \ + std::optional, bool, bool, std::vector, std::vector, std::vector, bool); -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector &, std::vector, std::uint32_t, std::vector, std::optional, bool, - bool, std::vector, std::vector, std::vector, bool); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector> &, std::vector, std::uint32_t, std::vector, - std::optional, bool, bool, std::vector, std::vector, std::vector, bool); - -template class taylor_adaptive_batch; - -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector &, std::vector, std::uint32_t, std::vector, std::optional, - bool, bool, std::vector, std::vector, std::vector, bool); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector> &, std::vector, std::uint32_t, std::vector, - std::optional, bool, bool, std::vector, std::vector, std::vector, bool); - -template class taylor_adaptive_batch; - -template HEYOKA_DLL_PUBLIC void -taylor_adaptive_batch::finalise_ctor_impl(const std::vector &, std::vector, - std::uint32_t, std::vector, - std::optional, bool, bool, std::vector, - std::vector, std::vector, bool); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector> &, std::vector, std::uint32_t, - std::vector, std::optional, bool, bool, std::vector, std::vector, - std::vector, 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; - -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector &, std::vector, std::uint32_t, std::vector, - std::optional, bool, bool, std::vector, std::vector, - std::vector, bool); - -template HEYOKA_DLL_PUBLIC void taylor_adaptive_batch::finalise_ctor_impl( - const std::vector> &, std::vector, std::uint32_t, - std::vector, std::optional, bool, bool, std::vector, - std::vector, std::vector, bool); +HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST(mppp::real128) #endif +#undef HEYOKA_TAYLOR_ADAPTIVE_BATCH_INST + HEYOKA_END_NAMESPACE diff --git a/src/taylor_01.cpp b/src/taylor_01.cpp index 7192cbab7..0e15085f0 100644 --- a/src/taylor_01.cpp +++ b/src/taylor_01.cpp @@ -1779,42 +1779,40 @@ std::ostream &operator<<(std::ostream &os, const t_event_impl #endif -// Explicit instantiation of the implementation classes/functions. -template class nt_event_impl; -template class t_event_impl; +// Explicit instantiation of the event classes. +#define HEYOKA_NT_EVENT_INST(F) \ + template class HEYOKA_DLL_PUBLIC nt_event_impl; \ + template class HEYOKA_DLL_PUBLIC nt_event_impl; -template class nt_event_impl; -template class t_event_impl; +#define HEYOKA_T_EVENT_INST(F) \ + template class HEYOKA_DLL_PUBLIC t_event_impl; \ + template class HEYOKA_DLL_PUBLIC t_event_impl; -template class nt_event_impl; -template class t_event_impl; +HEYOKA_NT_EVENT_INST(float) +HEYOKA_NT_EVENT_INST(double) +HEYOKA_NT_EVENT_INST(long double) -template class nt_event_impl; -template class t_event_impl; - -template class nt_event_impl; -template class t_event_impl; - -template class nt_event_impl; -template class t_event_impl; +HEYOKA_T_EVENT_INST(float) +HEYOKA_T_EVENT_INST(double) +HEYOKA_T_EVENT_INST(long double) #if defined(HEYOKA_HAVE_REAL128) -template class nt_event_impl; -template class t_event_impl; - -template class nt_event_impl; -template class t_event_impl; +HEYOKA_NT_EVENT_INST(mppp::real128) +HEYOKA_T_EVENT_INST(mppp::real128) #endif #if defined(HEYOKA_HAVE_REAL) -template class nt_event_impl; -template class t_event_impl; +template class HEYOKA_DLL_PUBLIC nt_event_impl; +template class HEYOKA_DLL_PUBLIC t_event_impl; #endif +#undef HEYOKA_NT_EVENT_INST +#undef HEYOKA_T_EVENT_INST + // Add a function for computing the dense output // via polynomial evaluation. void taylor_add_d_out_function(llvm_state &s, llvm::Type *fp_scal_t, std::uint32_t n_eq, std::uint32_t order, @@ -2412,19 +2410,19 @@ std::size_t continuous_output::get_n_steps() const } // Explicit instantiations. -template class continuous_output; -template class continuous_output; -template class continuous_output; +template class HEYOKA_DLL_PUBLIC continuous_output; +template class HEYOKA_DLL_PUBLIC continuous_output; +template class HEYOKA_DLL_PUBLIC continuous_output; #if defined(HEYOKA_HAVE_REAL128) -template class continuous_output; +template class HEYOKA_DLL_PUBLIC continuous_output; #endif #if defined(HEYOKA_HAVE_REAL) -template class continuous_output; +template class HEYOKA_DLL_PUBLIC continuous_output; #endif @@ -3166,13 +3164,13 @@ std::size_t continuous_output_batch::get_n_steps() const } // Explicit instantiations. -template class continuous_output_batch; -template class continuous_output_batch; -template class continuous_output_batch; +template class HEYOKA_DLL_PUBLIC continuous_output_batch; +template class HEYOKA_DLL_PUBLIC continuous_output_batch; +template class HEYOKA_DLL_PUBLIC continuous_output_batch; #if defined(HEYOKA_HAVE_REAL128) -template class continuous_output_batch; +template class HEYOKA_DLL_PUBLIC continuous_output_batch; #endif diff --git a/src/taylor_02.cpp b/src/taylor_02.cpp index 9f01c4b34..3836208d4 100644 --- a/src/taylor_02.cpp +++ b/src/taylor_02.cpp @@ -2053,61 +2053,32 @@ taylor_dc_t taylor_add_jet(llvm_state &s, const std::string &name, } // Explicit instantiations. -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector &, std::uint32_t, - std::uint32_t, bool, bool, const std::vector &, - bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector> &, - std::uint32_t, std::uint32_t, bool, bool, - const std::vector &, bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector &, std::uint32_t, - std::uint32_t, bool, bool, - const std::vector &, bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector> &, - std::uint32_t, std::uint32_t, bool, bool, - const std::vector &, bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector &, std::uint32_t, - std::uint32_t, bool, bool, - const std::vector &, bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t -taylor_add_jet(llvm_state &, const std::string &, const std::vector> &, - std::uint32_t, std::uint32_t, bool, bool, const std::vector &, bool, long long); +#define HEYOKA_TAYLOR_ADD_JET_INST(F) \ + template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet( \ + llvm_state &, const std::string &, const std::vector &, std::uint32_t, std::uint32_t, bool, bool, \ + const std::vector &, bool, long long); \ + template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet( \ + llvm_state &, const std::string &, const std::vector> &, std::uint32_t, \ + std::uint32_t, bool, bool, const std::vector &, bool, long long); + +HEYOKA_TAYLOR_ADD_JET_INST(float) +HEYOKA_TAYLOR_ADD_JET_INST(double) +HEYOKA_TAYLOR_ADD_JET_INST(long double) #if defined(HEYOKA_HAVE_REAL128) -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector &, std::uint32_t, - std::uint32_t, bool, bool, - const std::vector &, bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet( - llvm_state &, const std::string &, const std::vector> &, std::uint32_t, - std::uint32_t, bool, bool, const std::vector &, bool, long long); +HEYOKA_TAYLOR_ADD_JET_INST(mppp::real128) #endif #if defined(HEYOKA_HAVE_REAL) -template HEYOKA_DLL_PUBLIC taylor_dc_t taylor_add_jet(llvm_state &, const std::string &, - const std::vector &, std::uint32_t, - std::uint32_t, bool, bool, - const std::vector &, bool, long long); - -template HEYOKA_DLL_PUBLIC taylor_dc_t -taylor_add_jet(llvm_state &, const std::string &, const std::vector> &, - std::uint32_t, std::uint32_t, bool, bool, const std::vector &, bool, long long); +HEYOKA_TAYLOR_ADD_JET_INST(mppp::real) #endif +#undef HEYOKA_TAYLOR_ADD_JET_INST + namespace detail {