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

Function checkAndMigrate

src/backend/cuda/Array.cpp:61–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60template<typename T>
61void checkAndMigrate(Array<T> &arr) {
62 int arr_id = arr.getDevId();
63 int cur_id = detail::getActiveDeviceId();
64 if (!isDeviceBufferAccessible(arr_id, cur_id)) {
65 static auto getLogger = [&] { return spdlog::get("platform"); };
66 AF_TRACE("Migrating array from {} to {}.", arr_id, cur_id);
67 auto migrated_data = memAlloc<T>(arr.elements());
68 CUDA_CHECK(
69 cudaMemcpyPeerAsync(migrated_data.get(), getDeviceNativeId(cur_id),
70 arr.get(), getDeviceNativeId(arr_id),
71 arr.elements() * sizeof(T), getActiveStream()));
72 arr.data.reset(migrated_data.release(), memFree);
73 }
74}
75
76template<typename T>
77Array<T>::Array(const af::dim4 &dims)

Callers

nothing calls this directly

Calls 9

getDeviceNativeIdFunction · 0.85
getActiveStreamFunction · 0.85
getDevIdMethod · 0.80
resetMethod · 0.80
getActiveDeviceIdFunction · 0.70
isDeviceBufferAccessibleFunction · 0.70
getFunction · 0.50
elementsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected