Skip to content

Commit dc41a73

Browse files
yasahi-hpcYuuichi Asahi
andauthored
Print in/out view details and axes in case of extent errors (#301)
* Print in/out view details and axes in case of extent errors * capture views, axes and rank explicitly * Do not capture rank --------- Co-authored-by: Yuuichi Asahi <[email protected]>
1 parent e5aa357 commit dc41a73

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

common/src/KokkosFFT_Extents.hpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,49 @@ auto get_extents(const InViewType& in, const OutViewType& out,
7575
static_assert(!(is_real_v<in_value_type> && is_real_v<out_value_type>),
7676
"get_extents: real to real transform is not supported");
7777

78+
auto mismatched_extents = [&in, &out, &axes]() -> std::string {
79+
std::string message;
80+
message += in.label();
81+
message += "(";
82+
message += std::to_string(in.extent(0));
83+
for (std::size_t r = 1; r < rank; r++) {
84+
message += ",";
85+
message += std::to_string(in.extent(r));
86+
}
87+
message += "), ";
88+
message += out.label();
89+
message += "(";
90+
message += std::to_string(out.extent(0));
91+
for (std::size_t r = 1; r < rank; r++) {
92+
message += ",";
93+
message += std::to_string(out.extent(r));
94+
}
95+
message += "), with axes (";
96+
message += std::to_string(axes.at(0));
97+
for (std::size_t i = 1; i < axes.size(); i++) {
98+
message += ",";
99+
message += std::to_string(axes.at(i));
100+
}
101+
message += ")";
102+
return message;
103+
};
104+
78105
for (std::size_t i = 0; i < rank; i++) {
79106
// The requirement for inner_most_axis is different for transform type
80107
if (static_cast<int>(i) == inner_most_axis) continue;
81108
KOKKOSFFT_THROW_IF(in_extents_full.at(i) != out_extents_full.at(i),
82109
"input and output extents must be the same except for "
83-
"the transform axis");
110+
"the transform axis: " +
111+
mismatched_extents());
84112
}
85113

86114
if constexpr (is_complex_v<in_value_type> && is_complex_v<out_value_type>) {
87115
// Then C2C
88116
KOKKOSFFT_THROW_IF(
89117
in_extents_full.at(inner_most_axis) !=
90118
out_extents_full.at(inner_most_axis),
91-
"input and output extents must be the same for C2C transform");
119+
"input and output extents must be the same for C2C transform: " +
120+
mismatched_extents());
92121
}
93122

94123
if constexpr (is_real_v<in_value_type>) {
@@ -101,7 +130,8 @@ auto get_extents(const InViewType& in, const OutViewType& out,
101130
out_extents_full.at(inner_most_axis) !=
102131
in_extents_full.at(inner_most_axis) / 2 + 1,
103132
"For R2C, the 'output extent' of transform must be equal to "
104-
"'input extent'/2 + 1");
133+
"'input extent'/2 + 1: " +
134+
mismatched_extents());
105135
}
106136
}
107137

@@ -115,7 +145,8 @@ auto get_extents(const InViewType& in, const OutViewType& out,
115145
in_extents_full.at(inner_most_axis) !=
116146
out_extents_full.at(inner_most_axis) / 2 + 1,
117147
"For C2R, the 'input extent' of transform must be equal to "
118-
"'output extent' / 2 + 1");
148+
"'output extent' / 2 + 1: " +
149+
mismatched_extents());
119150
}
120151
}
121152

0 commit comments

Comments
 (0)