| 59 | |
| 60 | template<typename T> |
| 61 | void 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 | |
| 76 | template<typename T> |
| 77 | Array<T>::Array(const af::dim4 &dims) |
nothing calls this directly
no test coverage detected