| 2440 | |
| 2441 | |
| 2442 | void cpu_statevec_initUniformState_sub(Qureg qureg, qcomp amp) { |
| 2443 | |
| 2444 | // approx-uniformly distribute modified memory pages across threads, |
| 2445 | // in the hope that each std::fill() will touch only memory within |
| 2446 | // the thread's corresponding NUMA node, for best performance |
| 2447 | |
| 2448 | int numAmpsPerPage = cpu_getPageSize() / sizeof(qcomp); // divides evenly |
| 2449 | |
| 2450 | #pragma omp parallel if(qureg.isMultithreaded) |
| 2451 | { |
| 2452 | const auto [start, end] = util_getBlockMultipleSubRange( |
| 2453 | qureg.numAmpsPerNode, numAmpsPerPage, |
| 2454 | cpu_getOpenmpThreadInd(), cpu_getCurrentNumThreads()); |
| 2455 | |
| 2456 | std::fill(qureg.cpuAmps + start, qureg.cpuAmps + end, amp); |
| 2457 | } |
| 2458 | } |
| 2459 | |
| 2460 | |
| 2461 | void cpu_statevec_initDebugState_sub(Qureg qureg) { |
no test coverage detected