Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3f15227
abstrace and virtual members of SimulatorBase
Sep 2, 2020
3f4427f
minor things
Sep 2, 2020
286dd03
unifying qubit managers
Sep 2, 2020
6d358be
committing a working version
Sep 3, 2020
ff3297a
some bug
Sep 3, 2020
45c9a56
found and fixed the bug (which was in the original code)
Sep 3, 2020
2cc7037
cleaned up the structure
Sep 4, 2020
5a1b79d
qubit manager should now be in a good state
Sep 4, 2020
e6c0302
removing the base class that just throws
Sep 4, 2020
54f08c9
forgot to adapt a test
Sep 4, 2020
242de6a
processor base
Sep 4, 2020
ec819c4
removing accidental commit
Sep 7, 2020
85497ca
Merge branch 'master' into beheim/qubitManager
bettinaheim Sep 7, 2020
72dfaa3
wrong package nr
Sep 7, 2020
6172760
Update src/Simulation/Common/AssemblyInfo.cs
bettinaheim Sep 9, 2020
5818db9
Update src/Simulation/Common/QubitManager.cs
bettinaheim Sep 9, 2020
29b6088
nullable enable
Sep 10, 2020
47601ba
review feedback
Sep 10, 2020
68d593e
api change
Sep 10, 2020
cbbf458
Merge branch 'beheim/qubitManager' of https://github.com/microsoft/qs…
Sep 10, 2020
1cf73ea
getting updates from main
Sep 10, 2020
8a6a83b
qubit allocation events
Sep 12, 2020
9c4672b
Merge branch 'main' into beheim/qubitManager
bettinaheim Sep 12, 2020
5c47a68
correct stack handling
Sep 13, 2020
f88993f
Merge branch 'main' into beheim/qubitManager
anpaz Sep 16, 2020
19496a5
Merge branch 'main' into beheim/qubitManager
Nov 2, 2020
a796387
Merge branch 'main' into beheim/qubitManager
bettinaheim Nov 3, 2020
43e8f03
Merge branch 'main' into beheim/qubitManager
bettinaheim Nov 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Simulation/Common/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Runtime.CompilerServices;

// Allow the test assembly to use our internal methods
[assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)]
2 changes: 1 addition & 1 deletion src/Simulation/Common/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static uint[] GetIds(this IQArray<Qubit> qubits)
/// a subclass of T and registers as the override of the BaseType
/// it implements.
/// </summary>
public static void InitBuiltinOperations<T>(this AbstractFactory<T> factory, Type t)
public static void InitBuiltinOperations<T>(this Factory<T> factory, Type t)
{
if (t == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Quantum.Simulation.Common
/// It also provides a mechanism to register overrides when a given
/// type should be replaced by a subclass.
/// </summary>
public abstract class AbstractFactory<T>
public class Factory<T>
{
protected Dictionary<Type, Type> opsOverrides = new Dictionary<Type, Type>();
protected Dictionary<Type, T> opsCache = new Dictionary<Type, T>();
Expand Down
1 change: 0 additions & 1 deletion src/Simulation/Common/IQuantumProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Microsoft.Quantum.Simulation.Common
/// </summary>
/// <remarks>
/// To implement a target machine that executes quantum commands, implement this interface.
/// Consider using <see cref="QuantumProcessorBase"/> as a stub for easy impementation of this interface.
/// Implementors of <see cref="IQuantumProcessor"/> interface do not manage qubits on their own.
/// All qubit management (allocation, dealocation, etc.) is done by the caller of this interface.
/// Implementors are notified when qubits are allocated, released, borrowed and returned allowing them to react to these events if necessary.
Expand Down
34 changes: 15 additions & 19 deletions src/Simulation/Common/IQubitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,37 @@

namespace Microsoft.Quantum.Simulation.Common
{
using Microsoft.Quantum.Simulation.Core;
using System.Collections.Generic;
using Microsoft.Quantum.Simulation.Core;

public interface IQubitManager
{
bool DisableBorrowing { get; }

bool IsValid(Qubit qubit);
bool IsFree(Qubit qubit);
bool IsDisabled(Qubit qubit);

long FreeQubitsCount { get; }
long AllocatedQubitsCount { get; }
IEnumerable<long> AllocatedIds();
long QubitsAvailableToBorrowCount(int stackFrame = 0);

void Disable(Qubit qubit);
void Disable(IQArray<Qubit> qubits);

Qubit Allocate();
IQArray<Qubit> Allocate(long count);

void Release(Qubit qubit);
void Release(IQArray<Qubit> qubits);

void Disable(Qubit qubit);
void Disable(IQArray<Qubit> qubits);

Qubit Borrow();
IQArray<Qubit> Borrow(long count);

void Return(Qubit q);
void Return(IQArray<Qubit> qubits);

bool ToBeReleasedAfterReturn(Qubit qubit);
long ToBeReleasedAfterReturnCount(IQArray<Qubit> qubitsToReturn);

bool IsValid(Qubit qubit);
bool IsFree(Qubit qubit);
bool IsDisabled(Qubit qubit);

long GetFreeQubitsCount();
long GetQubitsAvailableToBorrowCount();
long GetParentQubitsAvailableToBorrowCount(); // Required for GetAvailableQubitsToBorrow
long GetAllocatedQubitsCount();
IEnumerable<long> GetAllocatedIds();

bool DisableBorrowing { get; }

/// <summary>
/// Callback to notify QubitManager that an operation execution has started.
/// This helps manage qubits scope.
Expand Down
Loading