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

Function findPlan

src/backend/oneapi/fft.cpp:103–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101template<::oneapi::mkl::dft::precision precision,
102 ::oneapi::mkl::dft::domain domain>
103PlanType findPlan(int rank, const bool isInPlace, const dim_t *idims,
104 std::int64_t *istrides, int ibatch, std::int64_t *ostrides,
105 int obatch, int nbatch) {
106 using desc_ty = ::oneapi::mkl::dft::descriptor<precision, domain>;
107
108 std::string key_string =
109 genPlanHashStr(rank, precision, domain, isInPlace, idims, istrides,
110 ibatch, ostrides, obatch, nbatch);
111
112 PlanCache &planner = arrayfire::oneapi::fftManager();
113 std::shared_ptr<PlanType> retVal = (planner.find(key_string));
114 if (retVal) { return *retVal; }
115
116 desc_ty *desc = [rank, &idims]() {
117 if (rank == 1) return new desc_ty(static_cast<int64_t>(idims[0]));
118 if (rank == 2) return new desc_ty({idims[1], idims[0]});
119 if (rank == 3) return new desc_ty({idims[2], idims[1], idims[0]});
120 return new desc_ty({idims[3], idims[2], idims[1], idims[0]});
121 }();
122
123 if (rank > 1) {
124 desc->set_value(::oneapi::mkl::dft::config_param::INPUT_STRIDES,
125 istrides);
126 desc->set_value(::oneapi::mkl::dft::config_param::OUTPUT_STRIDES,
127 ostrides);
128 }
129
130 if (isInPlace) {
131 desc->set_value(::oneapi::mkl::dft::config_param::PLACEMENT,
132 DFTI_INPLACE);
133 } else {
134 desc->set_value(::oneapi::mkl::dft::config_param::PLACEMENT,
135 DFTI_NOT_INPLACE);
136 }
137
138 desc->set_value(::oneapi::mkl::dft::config_param::NUMBER_OF_TRANSFORMS,
139 (int64_t)nbatch);
140
141 desc->set_value(::oneapi::mkl::dft::config_param::FWD_DISTANCE, ibatch);
142 desc->set_value(::oneapi::mkl::dft::config_param::BWD_DISTANCE, obatch);
143
144 if constexpr (domain == ::oneapi::mkl::dft::domain::COMPLEX) {
145 desc->set_value(::oneapi::mkl::dft::config_param::COMPLEX_STORAGE,
146 DFTI_COMPLEX_COMPLEX);
147 } else {
148 desc->set_value(
149 ::oneapi::mkl::dft::config_param::CONJUGATE_EVEN_STORAGE,
150 DFTI_COMPLEX_COMPLEX);
151 desc->set_value(::oneapi::mkl::dft::config_param::PACKED_FORMAT,
152 DFTI_CCE_FORMAT);
153 }
154
155 try {
156 desc->commit(getQueue());
157 } catch (::oneapi::mkl::device_bad_alloc &e) {
158 // If plan creation fails, clean up the memory we hold on to and try
159 // again
160 arrayfire::oneapi::signalMemoryCleanup();

Callers

nothing calls this directly

Calls 5

genPlanHashStrFunction · 0.85
findMethod · 0.80
pushMethod · 0.80
signalMemoryCleanupFunction · 0.70
getQueueFunction · 0.50

Tested by

no test coverage detected