MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / ~array

Method ~array

src/api/cpp/array.cpp:254–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252#undef INSTANTIATE
253
254array::~array() {
255#ifdef AF_UNIFIED
256 using af_release_array_ptr =
257 std::add_pointer<decltype(af_release_array)>::type;
258
259 if (get()) {
260 af_backend backend = arrayfire::unified::getActiveBackend();
261 af_err err = af_get_backend_id(&backend, get());
262 if (!err) {
263 switch (backend) {
264 case AF_BACKEND_CPU: {
265 static auto *cpu_handle =
266 arrayfire::unified::getActiveHandle();
267 static auto release_func =
268 reinterpret_cast<af_release_array_ptr>(
269 getFunctionPointer(cpu_handle, "af_release_array"));
270 release_func(get());
271 break;
272 }
273 case AF_BACKEND_OPENCL: {
274 static auto *opencl_handle =
275 arrayfire::unified::getActiveHandle();
276 static auto release_func =
277 reinterpret_cast<af_release_array_ptr>(
278 getFunctionPointer(opencl_handle,
279 "af_release_array"));
280 release_func(get());
281 break;
282 }
283 case AF_BACKEND_CUDA: {
284 static auto *cuda_handle =
285 arrayfire::unified::getActiveHandle();
286 static auto release_func =
287 reinterpret_cast<af_release_array_ptr>(
288 getFunctionPointer(cuda_handle,
289 "af_release_array"));
290 release_func(get());
291 break;
292 }
293 case AF_BACKEND_ONEAPI: {
294 static auto *oneapi_handle =
295 arrayfire::unified::getActiveHandle();
296 static auto release_func =
297 reinterpret_cast<af_release_array_ptr>(
298 getFunctionPointer(oneapi_handle,
299 "af_release_array"));
300 release_func(get());
301 break;
302 }
303 case AF_BACKEND_DEFAULT:
304 assert(1 != 1 &&
305 "AF_BACKEND_DEFAULT cannot be set as a backend for "
306 "an array");
307 }
308 }
309 }
310#else
311 // THOU SHALL NOT THROW IN DESTRUCTORS

Callers

nothing calls this directly

Calls 5

getActiveBackendFunction · 0.85
getFunction · 0.50
af_get_backend_idFunction · 0.50
getFunctionPointerFunction · 0.50
af_release_arrayFunction · 0.50

Tested by

no test coverage detected