Exemplo n.º 1
0
        public void OnOperationEnd(object[] returnedQubitsTraceData)
        {
            double maxReturnedQubitsAvailableTime = 0;

            if (returnedQubitsTraceData != null)
            {
                QubitTimeMetrics[] qubitsMetrics = Utils.UnboxAs <QubitTimeMetrics>(returnedQubitsTraceData);
                maxReturnedQubitsAvailableTime = QubitsMetricsUtils.MaxQubitAvailableTime(qubitsMetrics);
            }
            OperationCallRecord opRec = operationCallStack.Pop();

            Debug.Assert(operationCallStack.Count != 0, "Operation call stack must never get empty");
            double inputQubitsAvailableTime = QubitsMetricsUtils.MaxQubitAvailableTime(opRec.InputQubitMetrics);
            double operationEndTime         =
                Max(
                    Max(maxReturnedQubitsAvailableTime, opRec.ReturnedQubitsAvailableTime),
                    Max(opRec.ReleasedQubitsAvailableTime, inputQubitsAvailableTime));
            OperationCallRecord caller     = operationCallStack.Peek();
            HashedString        callerName = caller.OperationName;

            caller.ReleasedQubitsAvailableTime = Max(opRec.ReleasedQubitsAvailableTime, caller.ReleasedQubitsAvailableTime);
            caller.ReleasedQubitsAvailableTime = Max(opRec.ReleasedQubitsAvailableTime, caller.ReleasedQubitsAvailableTime);

            double[] metrics =
                StatisticsRecord(
                    Depth: operationEndTime - opRec.MaxOperationStartTime,
                    StartTimeDifference: opRec.MaxOperationStartTime - opRec.MinOperationStartTime);

            stats.AddSample(new CallGraphEdge(opRec.OperationName, callerName, opRec.FunctorSpecialization, caller.FunctorSpecialization), metrics);
        }
Exemplo n.º 2
0
        public void OnPrimitiveOperation(int id, object[] qubitsTraceData, double primitiveOperationDuration)
        {
            QubitTimeMetrics[] qubitsMetrics = Utils.UnboxAs <QubitTimeMetrics>(qubitsTraceData);
            double             startTime     = QubitsMetricsUtils.MaxQubitAvailableTime(qubitsMetrics);

            foreach (QubitTimeMetrics q in qubitsMetrics)
            {
                q.RecordQubitUsage(startTime, primitiveOperationDuration);
            }
        }
Exemplo n.º 3
0
        public void OnOperationStart(HashedString name, OperationFunctor functorSpecialization, object[] qubitsTraceData)
        {
            Debug.Assert(qubitsTraceData != null);
            OperationCallRecord opRec = new OperationCallRecord();

            opRec.FunctorSpecialization = functorSpecialization;
            opRec.OperationName         = name;
            opRec.InputQubitMetrics     = Utils.UnboxAs <QubitTimeMetrics>(qubitsTraceData);
            opRec.MaxOperationStartTime = QubitsMetricsUtils.MaxQubitAvailableTime(opRec.InputQubitMetrics);
            opRec.MinOperationStartTime = QubitsMetricsUtils.MinQubitAvailableTime(opRec.InputQubitMetrics);
            operationCallStack.Push(opRec);
        }
Exemplo n.º 4
0
        public void OnReturn(object[] qubitsTraceData, long qubitReleased)
        {
            OperationCallRecord opRec = operationCallStack.Peek();

            QubitTimeMetrics[] qubitsMetrics = Utils.UnboxAs <QubitTimeMetrics>(qubitsTraceData);
            opRec.ReturnedQubitsAvailableTime = Max(opRec.ReturnedQubitsAvailableTime, QubitsMetricsUtils.MaxQubitAvailableTime(qubitsMetrics));
        }