Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Make measurement result change inplace #67

Open
GiggleLiu opened this issue Aug 28, 2019 · 1 comment
Open

Make measurement result change inplace #67

GiggleLiu opened this issue Aug 28, 2019 · 1 comment

Comments

@GiggleLiu
Copy link
Member

Change mb.result = measure(...) to

res = measure(...)
if typeof(res) == typeof(mb) && size(res) == size(mb)
    mb.result[:] .= res
else
    isdefined(res, :result) && warn("Measure result output stream changed! Giveup allocated memory and use new one.")
    mb.result = res
end

For two reasons,

  • It is easier to port QASM, where classical memory creg can be mapped to a constant address. (or can we use measure block itself as creg? sounds a bit strange)
  • When porting real device, mb.result can act as a shared memory between quantum program and classical program.
@Roger-luo
Copy link
Member

I think we would compile instead interpretation when porting real device, since interpretation itself is just not very suitable (and require more work) to make it. I don't think it matters to consider whether measure block represents classical register or not, only its semantic matters. It can be lowered to classical register without changing its inner behaviour.

The implementation in this package is mainly just for simulation, and I think simply give an allocated memory is sufficient.

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

No branches or pull requests

2 participants