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

Function complexMultiplyHelper

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

Source from the content-addressed store, hash-verified

124
125template<typename convT, typename T>
126void complexMultiplyHelper(Param packed, Param sig, Param filter,
127 const int rank, AF_BATCH_KIND kind) {
128 constexpr bool IsTypeDouble = std::is_same<T, double>::value;
129 constexpr auto ctDType =
130 static_cast<af_dtype>(dtype_traits<convT>::af_type);
131
132 std::array<TemplateArg, 3> targs = {
133 TemplateTypename<T>(),
134 TemplateTypename<convT>(),
135 TemplateArg(IsTypeDouble),
136 };
137 std::vector<std::string> options = {
138 DefineKeyValue(T, dtype_traits<T>::getName()),
139 DefineKeyValue(AF_BATCH_NONE, static_cast<int>(AF_BATCH_NONE)),
140 DefineKeyValue(AF_BATCH_LHS, static_cast<int>(AF_BATCH_LHS)),
141 DefineKeyValue(AF_BATCH_RHS, static_cast<int>(AF_BATCH_RHS)),
142 DefineKeyValue(AF_BATCH_SAME, static_cast<int>(AF_BATCH_SAME)),
143 getTypeBuildDefinition<T, convT>()};
144 if (ctDType == c32) {
145 options.emplace_back(DefineKeyValue(CONVT, "float"));
146 } else if (ctDType == c64 && IsTypeDouble) {
147 options.emplace_back(DefineKeyValue(CONVT, "double"));
148 }
149
150 auto cplxMul = common::getKernel(
151 "complex_multiply", {{fftconvolve_multiply_cl_src}}, targs, options);
152
153 Param sig_tmp, filter_tmp;
154 calcParamSizes(sig_tmp, filter_tmp, packed, sig, filter, rank, kind);
155
156 int sig_packed_elem = sig_tmp.info.strides[3] * sig_tmp.info.dims[3];
157 int filter_packed_elem =
158 filter_tmp.info.strides[3] * filter_tmp.info.dims[3];
159 int mul_elem = (sig_packed_elem < filter_packed_elem) ? filter_packed_elem
160 : sig_packed_elem;
161 int blocks = divup(mul_elem, THREADS);
162
163 cl::NDRange local(THREADS);
164 cl::NDRange global(blocks * THREADS);
165
166 // Multiply filter and signal FFT arrays
167 cplxMul(cl::EnqueueArgs(getQueue(), global, local), *packed.data,
168 packed.info, *sig_tmp.data, sig_tmp.info, *filter_tmp.data,
169 filter_tmp.info, mul_elem, (int)kind);
170 CL_DEBUG_FINISH(getQueue());
171}
172
173template<typename T, typename convT>
174void reorderOutputHelper(Param out, Param packed, Param sig, Param filter,

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected