mirror of https://github.com/Qiskit/qiskit-aer.git
Make vector allocation aligned to 64-bytes (#1909)
* Make vector allocation aligned to 64-bytes as that is the same alignement requirement used by State data. * Add release note. --------- Co-authored-by: Jun Doi <doichan@jp.ibm.com>
This commit is contained in:
parent
ada56a3b6c
commit
0cca1e3220
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Change ``AER::Vector`` object alignement to 64-byte. In some cases, it is used to
|
||||
initialize ``AER:QV::QubitVector`` objects by moving storage ownership to these
|
||||
objects. As the code assumes that ``AER:QV::QubitVector`` storage is at least
|
||||
32-byte aligned for AVX2 load instructions, this change enforces the same alignement
|
||||
requirements for both ``AER::Vector`` and ``AER:QV::QubitVector`` objects so that
|
||||
one doesn't get into segmentation faults.
|
||||
|
|
@ -31,7 +31,15 @@ namespace AER {
|
|||
|
||||
template <class T>
|
||||
T *malloc_data(size_t size) {
|
||||
#if !defined(_WIN64) && !defined(_WIN32)
|
||||
// Data allocated here may need to be properly aligned to be compliant with
|
||||
// AVX2.
|
||||
void *data = nullptr;
|
||||
posix_memalign(&data, 64, sizeof(T) * size);
|
||||
return reinterpret_cast<T *>(data);
|
||||
#else
|
||||
return reinterpret_cast<T *>(malloc(sizeof(T) * size));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
Loading…
Reference in New Issue