Skip to content

Commit

Permalink
Debug tools
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Sep 17, 2024
1 parent 67ab776 commit 813e654
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
8 changes: 5 additions & 3 deletions bittide-experiments/src/Bittide/Plot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import Data.List (foldl', transpose, unzip4, zip4)
import GHC.Float.RealFracMethods (roundFloatInteger)
import System.FilePath ((</>))

import Debug.Trace

import Graphics.Matplotlib (
Matplotlib,
axes,
Expand Down Expand Up @@ -105,7 +107,7 @@ plot maybeCorrection outputDir graph plotData =
if edgeCount <= 20
then \(j, p) ->
withLegend $
p @@ [o2 "label" $ show nodeIndex <> "" <> show j]
p @@ [o2 "label" $ traceId (show nodeIndex <> "" <> show j)]
else snd
)
$ zip (filter (hasEdge graph nodeIndex) [0, 1 ..])
Expand Down Expand Up @@ -212,14 +214,14 @@ matplotWrite dir maybeCorrection clockDats ebDats = do
file (dir </> plotClocksFileName) $
constrained
( xlabel "Time (ms)"
% ylabel ("Relative frequency (ppm)" <> correctionLabel)
% ylabel ("ω (ppm)" <> correctionLabel)
% foldPlots (reverse $ Vec.toList clockDats)
)
void $
file (dir </> plotElasticBuffersFileName) $
constrained
( xlabel "Time (ms)"
% ylabel "Occupancy count"
% ylabel "β (elements)"
% foldPlots (Vec.toList ebDats)
)
where
Expand Down
27 changes: 17 additions & 10 deletions bittide-tools/clockcontrol/plot/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
Expand Down Expand Up @@ -99,7 +100,7 @@ import System.Directory (
doesDirectoryExist,
listDirectory,
)
import System.Environment (getArgs, getProgName)
import System.Environment (getArgs, getProgName, getEnv)
import System.Exit (die)
import System.FilePath (
isExtensionOf,
Expand All @@ -119,6 +120,7 @@ import System.IO (
openFile,
withFile,
)
import System.IO.Unsafe(unsafePerformIO)
import "bittide-extra" Numeric.Extra (parseHex)

import Bittide.Arithmetic.PartsPer (PartsPer (..), cyclesToPartsPerI, ppm)
Expand Down Expand Up @@ -637,7 +639,7 @@ plotTest refDom testDir cfg dir globalOutDir = do
BSL.writeFile (outDir </> (takeFileName d <> ".csv")) $
encodeByName header rs

return (toPlotData <$> rs)
return (catMaybes $ toPlotData <$> rs)

let postProcessDataVec = Vec.unsafeFromList postProcessData

Expand Down Expand Up @@ -689,21 +691,26 @@ plotTest refDom testDir cfg dir globalOutDir = do

toPlotData ::
DataPoint n decompressedElasticBufferBits ->
( Femtoseconds
Maybe ( Femtoseconds
, PartsPer
, ReframingStage
, [ ( RelDataCount decompressedElasticBufferBits
, StabilityIndication
)
]
)
toPlotData DataPoint{..} =
( dpGlobalTime
, dpDrift
, dpRfStage
, mapMaybe (uncurry $ liftA2 (,)) $
zip (Vec.toList dpDataCounts) (repeat (Just (StabilityIndication False False)))
)
toPlotData DataPoint{..} = if dpGlobalTime > wait_fs then Nothing else Just res
where
wait_ms = unsafePerformIO $ getEnv "CUTOFF_MS"
wait_fs = Femtoseconds $ 1_000_000_000_000 * read wait_ms

res =
( dpGlobalTime
, dpDrift
, dpRfStage
, mapMaybe (uncurry $ liftA2 (,)) $
zip (Vec.toList dpDataCounts) (repeat (Just (StabilityIndication False False)))
)

writeTop (fromMaybe "digraph{}" -> str) =
withFile (outDir </> simTopologyFileName) WriteMode $ \h -> do
Expand Down
18 changes: 18 additions & 0 deletions plot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
set -u

export JOB_ID="$1"
export CUTOFF_MS="$2"
export TOPOLOGY="$3"
export FIBER="$4"
export BITTIDE_PAPERS_DIR="$5"
export BITTIDE_PAPERS_RESULTS_DIR="${BITTIDE_PAPERS_DIR}"/asplos/results
export TARGET_DIR="${FIBER}"_10ppb_60ms_k2e9

export RUNREF="https://github.com/bittide/bittide-hardware/actions/runs/${JOB_ID}"

cabal run bittide-tools:cc-plot "${JOB_ID}":hwCcTopologyTest _build

rm -rf "${BITTIDE_PAPERS_RESULTS_DIR}"/"${TARGET_DIR}"/"${TOPOLOGY}"
mv "${TOPOLOGY}" "${BITTIDE_PAPERS_RESULTS_DIR}"/"${TARGET_DIR}"/
17 changes: 17 additions & 0 deletions plots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e
set -u

JOB_ID_2KM=10850182763
JOB_ID_2M=10850489509

BITTIDE_PAPERS_DIR=/home/martijn/code/bittide-papers


./plot.sh "${JOB_ID_2KM}" 50000 hourglass 2km "${BITTIDE_PAPERS_DIR}"
./plot.sh "${JOB_ID_2KM}" 5000 complete 2km "${BITTIDE_PAPERS_DIR}"
./plot.sh "${JOB_ID_2KM}" 10000 hypercube 2km "${BITTIDE_PAPERS_DIR}"

./plot.sh "${JOB_ID_2M}" 50000 hourglass 2km "${BITTIDE_PAPERS_DIR}"
./plot.sh "${JOB_ID_2M}" 5000 complete 2km "${BITTIDE_PAPERS_DIR}"
./plot.sh "${JOB_ID_2M}" 10000 hypercube 2km "${BITTIDE_PAPERS_DIR}"

0 comments on commit 813e654

Please sign in to comment.