[Buffer] Add optimal latency and occupancy balancing LPs#782
[Buffer] Add optimal latency and occupancy balancing LPs#782ziadomalik wants to merge 18 commits intomainfrom
Conversation
Addressing Jiahui's FeedbackWhat's the difference between extraLatency and dataLatency?The Add a remark for the CPVars that are exclusive to FPGA24Done. Better names for
|
| /// [FPGA24] Extra latency to insert on this channel for balancing (integer). | ||
| CPVar extraLatency; |
There was a problem hiding this comment.
extraLatency: should we just use dataLatency?
| struct LatencyBalancingResult { | ||
| /// Map from channel to its computed extra latency. | ||
| DenseMap<Value, unsigned> channelExtraLatency; | ||
| /// Target intiation interval. | ||
| double targetII; | ||
| /// Target intiation interval per CFDFC. | ||
| DenseMap<CFDFC *, double> cfdfcTargetIIs; | ||
| }; |
There was a problem hiding this comment.
Use MapVector<> to make sure that the result is deterministic
| double targetPeriod, | ||
| ArrayRef<ReconvergentPathWithGraph> reconvergentPaths, | ||
| ArrayRef<SynchronizingCyclePair> syncCyclePairs, | ||
| const SynchronizingCyclesFinderGraph &syncGraph, |
There was a problem hiding this comment.
why do we still need the syncGraph if we already have the pairs?
| /// Add pattern imbalance constraints for reconvergent paths. | ||
| void addReconvergentPathConstraints(); | ||
|
|
||
| /// Add pattern imbalance constraints for synchronizing cycles. | ||
| void addSyncCycleConstraints(); | ||
|
|
||
| void addStallPropagationConstraints(); | ||
|
|
||
| /// Add cycle time (II) constraints for each CFDFC cycle. | ||
| void addCycleTimeConstraints(); | ||
|
|
||
| /// Minimize stalls first, then latency cost. | ||
| void setLatencyBalancingObjective(); |
There was a problem hiding this comment.
the policy is to put all the constraint writing functions into BufferPlacementMILP (which has a database of constraints)
| /// Big-M constant for imbalance constraints. | ||
| // (Paper: Section 4, Equation 2) | ||
| static constexpr double BIG_M = 1000.0; | ||
|
|
||
| /// Weight for stall penalty vs latency cost (>> LATENCY_WEIGHT to prioritize | ||
| /// stalls). See usage in (Paper: Section 4, Equation 7) | ||
| static constexpr double LATENCY_WEIGHT = 1.0; | ||
| static constexpr double STALL_WEIGHT = 1000.0; | ||
|
|
||
| /// Upper bound for occupancy | ||
| static constexpr double MAX_OCCUPANCY = 100.0; |
| // LLVM_DEBUG(llvm::errs() << "Load Operation Latency: " << latency << " | ||
| // for " << opName.str() << "\n"); | ||
| llvm::errs() << "Getting latency for load operation failed! For " | ||
| << opName.str() << "\n"; |
| // LLVM_DEBUG(llvm::errs() << "Load Operation Latency: " << latency << " for | ||
| // " << opName.str() << "\n"); | ||
| llvm::errs() << "Load Operation Latency: " << latency << " for " | ||
| << opName.str() << "\n"; | ||
| } |
| /// 1. Channels in synchronization patterns (for balancing). | ||
| /// 2. ALL channels in CFDFCs (for cycle time constraints). | ||
| /// Relevant: (Paper: Section 4, Equation 1, 5). | ||
| DenseSet<Value> allChannels; |
There was a problem hiding this comment.
Use ordered set to make sure that the result is deterministic
| /// The latency variable L_c is the number of extra latencies to be added to a | ||
| /// channel. It will be used in the input of the occupancy balancing LP. Defined | ||
| /// in (Paper: Section 4, Table 1). | ||
| void LatencyBalancingMILP::addLatencyVariables() { |
There was a problem hiding this comment.
- not just latency variables?
- why not just adding all variables
isn't the latency we determined from LP1 the actual D/V buffer latency that we gonna use? |
A cleaner version of #711, as I am unsure if I messed up the rebasing or not.