Skip to content

Commit

Permalink
[core] enable array conversion between ints
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Aug 16, 2024
1 parent 67e8321 commit 31374e9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common/unified/components/precision_conversion_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void convert_precision(std::shared_ptr<const DefaultExecutor> 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
Expand Down
2 changes: 1 addition & 1 deletion core/base/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void convert_data(std::shared_ptr<const Executor> exec, size_type size,
void convert_data<From, To>(std::shared_ptr<const Executor>, 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
Expand Down
12 changes: 6 additions & 6 deletions core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename SourceType, typename TargetType> \
_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 <typename ValueType> \
_macro(ValueType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \
Expand Down Expand Up @@ -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 <typename SourceType, typename TargetType> \
_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 <typename SourceType, typename TargetType> \
_macro(SourceType, TargetType) GKO_NOT_COMPILED(GKO_HOOK_MODULE); \
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions include/ginkgo/core/base/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,21 @@ GKO_ATTRIBUTES constexpr bool operator!=(precision_reduction x,
template _macro(std::complex<double>, std::complex<float>)


/**
* 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.
Expand Down
2 changes: 1 addition & 1 deletion reference/components/precision_conversion_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void convert_precision(std::shared_ptr<const DefaultExecutor> 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
Expand Down

0 comments on commit 31374e9

Please sign in to comment.