This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Made Width and Depth compatible in current version of the tracer #404
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
93bd71e
Made Width and Depth compatible in current version of the tracer (v1)
cc9b075
Renamed file to match class, removed unneeded comment
5242b8b
Merge branch 'main' into dmitryv/WidthDepthCurrentTracer
bettinaheim e8d02cb
Merge branch 'main' into dmitryv/WidthDepthCurrentTracer
bettinaheim c49d2cc
Code review feedback - typos, formatting, literals, etc
75b40b0
Merge branch 'dmitryv/WidthDepthCurrentTracer' of https://github.com/…
a3dd323
Code review feedback - static class, enumerable instead of materializ…
99916b6
Code review feedback - IEnumerable instead of materializing arrays
5a7ee2b
Code review feedback - ExtraWidth->QubitCount and comments
57e0641
Making OperationCallRecord private
c87f3be
Merge branch 'main' into dmitryv/WidthDepthCurrentTracer
bettinaheim 7bfd9de
Code review feedback - typo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/Simulation/QCTraceSimulator/QubitAvailabilityTimeTracker.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Linq; | ||
|
|
||
| namespace Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime | ||
| { | ||
| /// <summary> | ||
| /// Tracks time when qubits were last used and therefore, time when qubits become available. | ||
| /// Tracking is done by qubit id, which survives during reuse of qubit. | ||
| /// </summary> | ||
| internal class QubitAvailabilityTimeTracker | ||
DmitryVasilevsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| /// <summary> | ||
| /// Availability time of all qubits starts at 0. | ||
| /// </summary> | ||
| private double DefaultAvailabilityTime = 0.0; | ||
|
|
||
| /// <summary> | ||
| /// This tracks time when a qubit was last used, indexed by qubit id. | ||
| /// </summary> | ||
| private List<double> QubitAvailableAt; | ||
DmitryVasilevsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Maximum qubit id seen so far. | ||
| /// </summary> | ||
| private long MaxQubitId = -1; | ||
|
|
||
| internal QubitAvailabilityTimeTracker(int initialCapacity, double defaultAvailabilityTime) | ||
| { | ||
| DefaultAvailabilityTime = defaultAvailabilityTime; | ||
| QubitAvailableAt = new List<double>(initialCapacity); | ||
DmitryVasilevsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| internal double this[long qubitId] | ||
| { | ||
| get | ||
| { | ||
| if (qubitId < QubitAvailableAt.Count) | ||
| { | ||
| return QubitAvailableAt[(int)qubitId]; | ||
| } | ||
| return DefaultAvailabilityTime; | ||
| } | ||
| set | ||
| { | ||
| if (qubitId == QubitAvailableAt.Count) | ||
| { | ||
| QubitAvailableAt.Add(value); | ||
| return; | ||
| } | ||
| else if (qubitId >= int.MaxValue) | ||
| { | ||
| throw new IndexOutOfRangeException("Too many qubits to track."); | ||
| } | ||
| else if (qubitId > QubitAvailableAt.Count) | ||
| { | ||
| QubitAvailableAt.AddRange(Enumerable.Repeat(DefaultAvailabilityTime, (int)qubitId - QubitAvailableAt.Count + 1)); | ||
| } | ||
| QubitAvailableAt[(int)qubitId] = value; | ||
| } | ||
| } | ||
|
|
||
| internal long GetMaxQubitId() | ||
| { | ||
| return MaxQubitId; | ||
| } | ||
|
|
||
| internal void MarkQubitIdUsed(long qubitId) | ||
DmitryVasilevsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| MaxQubitId = System.Math.Max(MaxQubitId, qubitId); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.