Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@Patil2099
Copy link
Contributor

Fixes #702

@swernli swernli self-requested a review May 24, 2021 16:51
@swernli swernli self-assigned this May 24, 2021
@swernli
Copy link
Collaborator

swernli commented May 24, 2021

This is the right start, but there are a few other spots with code that can be removed as well. Now that __quantum__rt__heap_alloc and __quantum__rt__heap_free are removed, the declaration and implementation of the internal functions backing them can also be removed. Those are located in these two places:

declare i8* @quantum__rt__heap_alloc(i64)
declare void @quantum__rt__heap_free(i8*)

char* quantum__rt__heap_alloc(uint64_t size) // NOLINT
{
char* buffer = new (std::nothrow) char[size];
if(buffer == nullptr)
{
quantum__rt__fail(quantum__rt__string_create("Allocation Failed"));
}
#ifndef NDEBUG
UseMemoryTracker().insert(buffer);
#endif
return buffer;
}
// Release a block of allocated heap memory.
void quantum__rt__heap_free(char* buffer) // NOLINT
{
#ifndef NDEBUG
auto iter = UseMemoryTracker().find(buffer);
assert(iter != UseMemoryTracker().end());
UseMemoryTracker().erase(iter);
#endif
delete[] buffer;
}

With that done, there are no more uses of the MemoryTracker defined at the top of utils.cpp, so that can be removed too.

@ghost
Copy link

ghost commented May 24, 2021

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@swernli swernli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick updates! The changes look good to me, I'll formally sign off to unblock merge once the issue is triaged.

@Patil2099
Copy link
Contributor Author

Can you review it again? @swernli

@swernli
Copy link
Collaborator

swernli commented May 24, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@swernli
Copy link
Collaborator

swernli commented May 24, 2021

Apologies, @Patil2099, we seem to be having some problems in the build pipeline unrelated to this change. Hopefully I can get a clean build soon.

@swernli
Copy link
Collaborator

swernli commented May 24, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@swernli swernli merged commit c84d56d into microsoft:main May 24, 2021
anpaz added a commit that referenced this pull request Jun 16, 2021
* Update API docs with more examples. (#701)

Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>

* QIR runtime heap alloc and heap free functions removed (#703)

* QIR runtime heap alloc and heap free functions removed

* Implement Feedback

Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>

* Add QIR Runtime to bootstrap script (#706)

* Increasing the CMAKE required version for QIR (#708)

This updates the required version for CMAKE in the CMakeLists.txt files for QIR, since we are now using features not correctly supported on older versions.

* Added first version of Qubit manager to QIR (#696)

This is the first version of the native Qubit Manager for QIR. Initial unit tests are included.

Qubit Manager supports

* Allocation and release of qubits including arrays of qubits.
* Reuse encouraged/discouraged. Extending capacity enabled/disabled.
* Restricted reuse areas and segments to support low-depth circuits.

Qubit manager builds and tests are run as part of the qir-runtime-unittests. It is used in the bridge to the full state simulator.

Commits:
* Added first draft version of Qubit manager to QIR
* Review feedback. Rearranged functions, QubitIdType, consts, etc.
* include cstring for memcpy
* Renamed QubitManager
* Adjustment after QubitManager rename
* Moved QubitManager.h to public
* Using QubitManager, adjusted defaults, minor fixes
* Removed unused comment
* CR feedback: fixes to types, failures, braces, etc.
* CR feedback - updated types, unique_ptr, etc.
* Auxilliary stuff is now nested in CQubitmanager
* Initializer lists
* Updated CRestrictedReuseAreaStack and used iterator.
* int32_t, more checks, some refactoring
* Refactoring: marking and counting is done in allocate/release qubit id
* Deletion of qubit object, protected members for overrides, Is...Qubit renames
* Moved allocated marking to listQubitListInSharedArray class
* Added comments, mostly status array
* Tests, refactoring, replaced IsFreeQubit with IsFreeQubitId

Co-authored-by: Dmitry Vasilevsky <dmitryv@microsoft.com>

* Added treating warnings as errors (#718)

* Added "QIR Runtime API Design Guidelines" (#711)

* Initial add of QIR-RT-API-Design-Guidelines.md
* Use of exceptions recommendation (#719)
* Co-authored-by: Mathias Soeken
* Co-authored-by: DmitryVasilevsky

* Auto emulation rewrite step (#514)

* First proposal for auto emulation feature.

* Deprecation.

* Update to newer version.

* Successful tests.

* Compatibility checks.

* Do not change this file.

* Signature checking too restrictive.

* Add integration test.

* Update QDK version.

* Incorporate microsoft/QuantumLibraries#426.

* Rename emulation to substitution.

* Rename projects and directories.

* Packaging.

* Fix line-feed problems.

* Fix LF.

* Adressing reviewer feedback.

* Update Sdk version.

* Fixes dependency error.

Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
Co-authored-by: Chris Granade <chgranad@microsoft.com>
Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>

* Added compiler warning flags -Wall, -Wextra (#725)

* Added -Wall, -Wextra

* Add DelaySign.cs to AutoSubstitution project. (#729)

* extra sln

Co-authored-by: Chris Granade <chgranad@microsoft.com>
Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>
Co-authored-by: Pankaj Patil <pankaj.patil2099@hotmail.com>
Co-authored-by: DmitryVasilevsky <60718360+DmitryVasilevsky@users.noreply.github.com>
Co-authored-by: Dmitry Vasilevsky <dmitryv@microsoft.com>
Co-authored-by: Robin Kuzmin <kuzmin.robin@gmail.com>
Co-authored-by: Mathias Soeken <mathias.soeken@microsoft.com>
Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
anpaz added a commit that referenced this pull request Jun 17, 2021
* Replace generated files in Quantum.Client with reference to the Azure.QuantumJobs package (#697)

* Changes to enable Mocks for iq# and integrate with Live tests (#707)

* Credentials parameter (#721)

* Move to CredentialFactory.

* Adding support for DeviceCode

* Merge main (#731)

* Update API docs with more examples. (#701)

Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>

* QIR runtime heap alloc and heap free functions removed (#703)

* QIR runtime heap alloc and heap free functions removed

* Implement Feedback

Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>

* Add QIR Runtime to bootstrap script (#706)

* Increasing the CMAKE required version for QIR (#708)

This updates the required version for CMAKE in the CMakeLists.txt files for QIR, since we are now using features not correctly supported on older versions.

* Added first version of Qubit manager to QIR (#696)

This is the first version of the native Qubit Manager for QIR. Initial unit tests are included.

Qubit Manager supports

* Allocation and release of qubits including arrays of qubits.
* Reuse encouraged/discouraged. Extending capacity enabled/disabled.
* Restricted reuse areas and segments to support low-depth circuits.

Qubit manager builds and tests are run as part of the qir-runtime-unittests. It is used in the bridge to the full state simulator.

Commits:
* Added first draft version of Qubit manager to QIR
* Review feedback. Rearranged functions, QubitIdType, consts, etc.
* include cstring for memcpy
* Renamed QubitManager
* Adjustment after QubitManager rename
* Moved QubitManager.h to public
* Using QubitManager, adjusted defaults, minor fixes
* Removed unused comment
* CR feedback: fixes to types, failures, braces, etc.
* CR feedback - updated types, unique_ptr, etc.
* Auxilliary stuff is now nested in CQubitmanager
* Initializer lists
* Updated CRestrictedReuseAreaStack and used iterator.
* int32_t, more checks, some refactoring
* Refactoring: marking and counting is done in allocate/release qubit id
* Deletion of qubit object, protected members for overrides, Is...Qubit renames
* Moved allocated marking to listQubitListInSharedArray class
* Added comments, mostly status array
* Tests, refactoring, replaced IsFreeQubit with IsFreeQubitId

Co-authored-by: Dmitry Vasilevsky <dmitryv@microsoft.com>

* Added treating warnings as errors (#718)

* Added "QIR Runtime API Design Guidelines" (#711)

* Initial add of QIR-RT-API-Design-Guidelines.md
* Use of exceptions recommendation (#719)
* Co-authored-by: Mathias Soeken
* Co-authored-by: DmitryVasilevsky

* Auto emulation rewrite step (#514)

* First proposal for auto emulation feature.

* Deprecation.

* Update to newer version.

* Successful tests.

* Compatibility checks.

* Do not change this file.

* Signature checking too restrictive.

* Add integration test.

* Update QDK version.

* Incorporate microsoft/QuantumLibraries#426.

* Rename emulation to substitution.

* Rename projects and directories.

* Packaging.

* Fix line-feed problems.

* Fix LF.

* Adressing reviewer feedback.

* Update Sdk version.

* Fixes dependency error.

Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
Co-authored-by: Chris Granade <chgranad@microsoft.com>
Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>

* Added compiler warning flags -Wall, -Wextra (#725)

* Added -Wall, -Wextra

* Add DelaySign.cs to AutoSubstitution project. (#729)

* extra sln

Co-authored-by: Chris Granade <chgranad@microsoft.com>
Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>
Co-authored-by: Pankaj Patil <pankaj.patil2099@hotmail.com>
Co-authored-by: DmitryVasilevsky <60718360+DmitryVasilevsky@users.noreply.github.com>
Co-authored-by: Dmitry Vasilevsky <dmitryv@microsoft.com>
Co-authored-by: Robin Kuzmin <kuzmin.robin@gmail.com>
Co-authored-by: Mathias Soeken <mathias.soeken@microsoft.com>
Co-authored-by: Mathias Soeken <masoeken@microsoft.com>

* Apply suggestions from code review

Co-authored-by: Chris Granade <chgranad@microsoft.com>

* Incorporating feedback.

* Build 0.17.2106.147878.

Co-authored-by: Chris Granade <chgranad@microsoft.com>
Co-authored-by: Stefan J. Wernli <swernli@microsoft.com>
Co-authored-by: Pankaj Patil <pankaj.patil2099@hotmail.com>
Co-authored-by: DmitryVasilevsky <60718360+DmitryVasilevsky@users.noreply.github.com>
Co-authored-by: Dmitry Vasilevsky <dmitryv@microsoft.com>
Co-authored-by: Robin Kuzmin <kuzmin.robin@gmail.com>
Co-authored-by: Mathias Soeken <mathias.soeken@microsoft.com>
Co-authored-by: Mathias Soeken <masoeken@microsoft.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QIR runtime heap alloc and heap free functions should be removed

2 participants