diff --git a/common/unified/components/precision_conversion_kernels.cpp b/common/unified/components/precision_conversion_kernels.cpp index 0402d9bef68..4f3bce969e0 100644 --- a/common/unified/components/precision_conversion_kernels.cpp +++ b/common/unified/components/precision_conversion_kernels.cpp @@ -23,7 +23,7 @@ void convert_precision(std::shared_ptr exec, size, in, out); } -GKO_INSTANTIATE_FOR_EACH_VALUE_CONVERSION(GKO_DECLARE_CONVERT_PRECISION_KERNEL); +GKO_INSTANTIATE_FOR_EACH_POD_CONVERSION(GKO_DECLARE_CONVERT_PRECISION_KERNEL); } // namespace components diff --git a/core/base/array.cpp b/core/base/array.cpp index a41f7c07e55..2025cc6480d 100644 --- a/core/base/array.cpp +++ b/core/base/array.cpp @@ -51,7 +51,7 @@ void convert_data(std::shared_ptr exec, size_type size, void convert_data(std::shared_ptr, size_type, \ const From*, To*) -GKO_INSTANTIATE_FOR_EACH_VALUE_CONVERSION(GKO_DECLARE_ARRAY_CONVERSION); +GKO_INSTANTIATE_FOR_EACH_POD_CONVERSION(GKO_DECLARE_ARRAY_CONVERSION); } // namespace detail diff --git a/core/device_hooks/common_kernels.inc.cpp b/core/device_hooks/common_kernels.inc.cpp index fe054856695..d86184c1ce6 100644 --- a/core/device_hooks/common_kernels.inc.cpp +++ b/core/device_hooks/common_kernels.inc.cpp @@ -81,6 +81,11 @@ _macro(SourceType, TargetType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \ GKO_INSTANTIATE_FOR_EACH_VALUE_CONVERSION(_macro) +#define GKO_STUB_POD_CONVERSION(_macro) \ + template \ + _macro(SourceType, TargetType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \ + GKO_INSTANTIATE_FOR_EACH_POD_CONVERSION(_macro) + #define GKO_STUB_NON_COMPLEX_VALUE_TYPE(_macro) \ template \ _macro(ValueType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \ @@ -147,11 +152,6 @@ _macro(IndexType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \ GKO_INSTANTIATE_FOR_EACH_TEMPLATE_TYPE(_macro) -#define GKO_STUB_VALUE_CONVERSION(_macro) \ - template \ - _macro(SourceType, TargetType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \ - GKO_INSTANTIATE_FOR_EACH_VALUE_CONVERSION(_macro) - #define GKO_STUB_VALUE_CONVERSION_OR_COPY(_macro) \ template \ _macro(SourceType, TargetType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \ @@ -173,7 +173,7 @@ namespace GKO_HOOK_MODULE { namespace components { -GKO_STUB_VALUE_CONVERSION(GKO_DECLARE_CONVERT_PRECISION_KERNEL); +GKO_STUB_POD_CONVERSION(GKO_DECLARE_CONVERT_PRECISION_KERNEL); GKO_STUB_INDEX_TYPE(GKO_DECLARE_PREFIX_SUM_NONNEGATIVE_KERNEL); // explicitly instantiate for size_type, as this is // used in the SellP format diff --git a/include/ginkgo/core/base/types.hpp b/include/ginkgo/core/base/types.hpp index 3783d2c4b41..5387a38514c 100644 --- a/include/ginkgo/core/base/types.hpp +++ b/include/ginkgo/core/base/types.hpp @@ -682,6 +682,21 @@ GKO_ATTRIBUTES constexpr bool operator!=(precision_reduction x, template _macro(std::complex, std::complex) +/** + * Instantiates a template for each pod type conversion pair compiled by + * Ginkgo. + * + * @param _macro A macro which expands the template instantiation + * (not including the leading `template` specifier). + * Should take two arguments `src` and `dst`, which + * are replaced by the source and destination value type. + */ +#define GKO_INSTANTIATE_FOR_EACH_POD_CONVERSION(_macro) \ + GKO_INSTANTIATE_FOR_EACH_VALUE_CONVERSION(_macro); \ + template _macro(int32, int64); \ + template _macro(int64, int32) + + /** * Instantiates a template for each value type conversion or copy pair compiled * by Ginkgo. diff --git a/reference/components/precision_conversion_kernels.cpp b/reference/components/precision_conversion_kernels.cpp index db12d9316ee..059d8922939 100644 --- a/reference/components/precision_conversion_kernels.cpp +++ b/reference/components/precision_conversion_kernels.cpp @@ -20,7 +20,7 @@ void convert_precision(std::shared_ptr exec, std::copy_n(in, size, out); } -GKO_INSTANTIATE_FOR_EACH_VALUE_CONVERSION(GKO_DECLARE_CONVERT_PRECISION_KERNEL); +GKO_INSTANTIATE_FOR_EACH_POD_CONVERSION(GKO_DECLARE_CONVERT_PRECISION_KERNEL); } // namespace components