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

Function evalMultiple

src/backend/cpu/Array.cpp:162–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160
161template<typename T>
162void evalMultiple(vector<Array<T> *> array_ptrs) {
163 vector<Array<T> *> outputs;
164 vector<common::Node_ptr> nodes;
165 vector<Param<T>> params;
166 if (getQueue().is_worker()) {
167 AF_ERROR("Array not evaluated", AF_ERR_INTERNAL);
168 }
169
170 // Check if all the arrays have the same dimension
171 auto it = adjacent_find(begin(array_ptrs), end(array_ptrs),
172 [](const Array<T> *l, const Array<T> *r) {
173 return l->dims() != r->dims();
174 });
175
176 // If they are not the same. eval individually
177 if (it != end(array_ptrs)) {
178 for (auto ptr : array_ptrs) { ptr->eval(); }
179 return;
180 }
181
182 for (Array<T> *array : array_ptrs) {
183 if (array->isReady()) { continue; }
184
185 array->setId(getActiveDeviceId());
186 array->data =
187 shared_ptr<T>(memAlloc<T>(array->elements()).release(), memFree);
188
189 outputs.push_back(array);
190 params.emplace_back(array->getData().get(), array->dims(),
191 array->strides());
192 nodes.push_back(array->node);
193 }
194
195 if (params.empty()) return;
196
197 getQueue().enqueue(cpu::kernel::evalMultiple<T>, params, nodes);
198
199 for (Array<T> *array : outputs) { array->node.reset(); }
200}
201
202template<typename T>
203Node_ptr Array<T>::getNode() {

Callers 1

joinFunction · 0.70

Calls 15

beginFunction · 0.85
endFunction · 0.85
resetMethod · 0.80
getActiveDeviceIdFunction · 0.70
getQueueFunction · 0.50
is_workerMethod · 0.45
dimsMethod · 0.45
evalMethod · 0.45
isReadyMethod · 0.45
setIdMethod · 0.45
elementsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected