MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / reorderOutputHelper

Function reorderOutputHelper

src/backend/opencl/kernel/fftconvolve.hpp:174–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172
173template<typename T, typename convT>
174void reorderOutputHelper(Param out, Param packed, Param sig, Param filter,
175 const int rank, AF_BATCH_KIND kind, bool expand) {
176 constexpr bool IsTypeDouble = std::is_same<T, double>::value;
177 constexpr auto ctDType =
178 static_cast<af_dtype>(dtype_traits<convT>::af_type);
179 constexpr bool RoundResult = std::is_integral<T>::value;
180
181 std::array<TemplateArg, 5> targs = {
182 TemplateTypename<T>(), TemplateTypename<convT>(),
183 TemplateArg(IsTypeDouble), TemplateArg(RoundResult),
184 TemplateArg(expand),
185 };
186 std::vector<std::string> options = {
187 DefineKeyValue(T, dtype_traits<T>::getName()),
188 DefineKeyValue(ROUND_OUT, static_cast<int>(RoundResult)),
189 DefineKeyValue(EXPAND, static_cast<int>(expand)),
190 getTypeBuildDefinition<T, convT>()};
191 if (ctDType == c32) {
192 options.emplace_back(DefineKeyValue(CONVT, "float"));
193 } else if (ctDType == c64 && IsTypeDouble) {
194 options.emplace_back(DefineKeyValue(CONVT, "double"));
195 }
196
197 auto reorder = common::getKernel(
198 "reorder_output", {{fftconvolve_reorder_cl_src}}, targs, options);
199
200 int fftScale = 1;
201
202 // Calculate the scale by which to divide clFFT results
203 for (int k = 0; k < rank; k++) fftScale *= packed.info.dims[k];
204
205 Param sig_tmp, filter_tmp;
206 calcParamSizes(sig_tmp, filter_tmp, packed, sig, filter, rank, kind);
207
208 // Number of packed complex elements in dimension 0
209 int sig_half_d0 = divup(sig.info.dims[0], 2);
210
211 int blocks = divup(out.info.strides[3] * out.info.dims[3], THREADS);
212
213 cl::NDRange local(THREADS);
214 cl::NDRange global(blocks * THREADS);
215
216 if (kind == AF_BATCH_RHS) {
217 reorder(cl::EnqueueArgs(getQueue(), global, local), *out.data, out.info,
218 *filter_tmp.data, filter_tmp.info, filter.info, sig_half_d0,
219 rank, fftScale);
220 } else {
221 reorder(cl::EnqueueArgs(getQueue(), global, local), *out.data, out.info,
222 *sig_tmp.data, sig_tmp.info, filter.info, sig_half_d0, rank,
223 fftScale);
224 }
225 CL_DEBUG_FINISH(getQueue());
226}
227} // namespace kernel
228} // namespace opencl
229} // namespace arrayfire

Callers

nothing calls this directly

Calls 7

TemplateArgClass · 0.85
getNameFunction · 0.85
EnqueueArgsClass · 0.85
calcParamSizesFunction · 0.70
reorderFunction · 0.70
getKernelFunction · 0.50
getQueueFunction · 0.50

Tested by

no test coverage detected