Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QubitRegister<Type>::QubitRegister(new_num_qubits, Type *state) doesnt work correctly #56

Open
mbuchberger1967 opened this issue Jul 25, 2021 · 3 comments

Comments

@mbuchberger1967
Copy link
Contributor

mbuchberger1967 commented Jul 25, 2021

Describe the bug

template <class Type>
QubitRegister<Type>::QubitRegister(std::size_t new_num_qubits, Type *state, 
                                   std::size_t tmp_spacesize_)
{
  imported_state = true;
  Initialize(new_num_qubits, tmp_spacesize_);

  this->state = state;
}

has two problems:

  1. it doesn't initialize all needed class variables, e.g. "specialized", so this flag is sometimes true, sometimes false
  2. it doesn't work if USE_MM_ALLOC is not defined -> memory crash

To Reproduce
Steps to reproduce the behavior:
Use the ctor and initialize the statevector with a prepared memory pointer, undef MM_USE_MALLOC

Fixes

  1. init all class variables in the declaration
  2. add code for undef USE_MM_MALLOC with a specialized AlignedAllocator to transport the memory block into state_storage

See my PR #57

@giangiac
Copy link
Contributor

giangiac commented Aug 3, 2021

Hi @mbuchberger1967 , thanks for pointing out this issue.
I will give a look to your solution.

@mbuchberger1967
Copy link
Contributor Author

Hi @giangiac
we have this fix in our fork and it is working fine.
you really should give it a try....
BR
Markus

@giangiac
Copy link
Contributor

Hi @mbuchberger1967
Thanks for the reminder.
I'll give a look at pull request #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants