| 262 | |
| 263 | |
| 264 | void cpu_deallocNumaArray(qcomp* arr, qindex length) { |
| 265 | |
| 266 | // musn't pass nullptr to munmap() below |
| 267 | if (arr == nullptr) |
| 268 | return; |
| 269 | |
| 270 | #if ! NUMA_AWARE |
| 271 | cpu_deallocArray(arr); |
| 272 | |
| 273 | #elif defined(_WIN32) |
| 274 | error_numaAllocOrDeallocAttemptedOnWindows(); |
| 275 | |
| 276 | #else |
| 277 | qindex arrSize = length * sizeof(qcomp); |
| 278 | long pageSize = cpu_getPageSize(); |
| 279 | |
| 280 | // sub-page arrays were allocated with calloc() |
| 281 | if (arrSize <= pageSize) |
| 282 | return cpu_deallocArray(arr); |
| 283 | |
| 284 | qindex numPages = getNumPagesToContainArray(pageSize, arrSize); |
| 285 | qindex numBytes = numPages * pageSize; // gauranteed no overflow |
| 286 | int success = munmap(arr, numBytes); |
| 287 | |
| 288 | if (success == -1) |
| 289 | error_numaUnmappingFailed(); |
| 290 | #endif |
| 291 | } |
| 292 | |
| 293 | |
| 294 | qcomp** cpu_allocAndInitMatrixWrapper(qcomp* arr, qindex dim) { |
no test coverage detected