-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release] add docker image and related document
Signed-off-by: Avimitin <[email protected]>
- Loading branch information
Showing
4 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,90 @@ | ||
{ lib | ||
, newScope | ||
|
||
, stdenvNoCC | ||
, fetchFromGitHub | ||
, runCommand | ||
, makeWrapper | ||
, typst | ||
, jq | ||
|
||
, configName | ||
, t1-script | ||
, ip-emulator | ||
, cases | ||
, elaborateConfigJson | ||
, pkgsCross | ||
}: | ||
|
||
lib.makeScope newScope (scope: rec { | ||
inherit ip-emulator elaborateConfigJson; | ||
|
||
testCases = with cases; [ | ||
intrinsic.matmul | ||
intrinsic.softmax | ||
intrinsic.linear_normalization | ||
]; | ||
|
||
emulator-wrapped = runCommand "ip-emulator" | ||
{ | ||
nativeBuildInputs = [ makeWrapper ]; | ||
} | ||
'' | ||
mkdir -p $out/bin | ||
makeWrapper ${t1-script}/bin/t1-helper $out/bin/ip-emulator \ | ||
--add-flags "ipemu" \ | ||
--add-flags "--config ${elaborateConfigJson}" \ | ||
--add-flags "--emulator-path ${ip-emulator}/bin/emulator" | ||
''; | ||
|
||
docker-layers = scope.callPackage ./docker-layers.nix { | ||
rv32-gcc = pkgsCross.riscv32-embedded.buildPackages.gcc; | ||
}; | ||
|
||
doc = stdenvNoCC.mkDerivation { | ||
name = "${configName}-typst-release-doc"; | ||
|
||
nativeBuildInputs = [ typst jq ]; | ||
|
||
src = ./doc.typ; | ||
|
||
unpackPhase = | ||
let | ||
typstPkgs = [ | ||
{ | ||
pkgName = "preview/codly"; | ||
version = "0.2.0"; | ||
src = fetchFromGitHub { | ||
owner = "Dherse"; | ||
repo = "codly"; | ||
rev = "0037b522957de3ab8e88cb689bf813aafa96a1b8"; | ||
hash = "sha256-OZB9D0KpS9qVIU6O62uPQzQKx0xFxm8/nnkFU4MIkqY="; | ||
}; | ||
} | ||
]; | ||
in | ||
'' | ||
export XDG_CACHE_HOME=$(mktemp -d) | ||
typstPkgRoot="$XDG_CACHE_HOME"/typst/packages | ||
${lib.concatMapStringsSep "\n" | ||
(info: '' | ||
dstDir="$typstPkgRoot/${info.pkgName}/${info.version}" | ||
mkdir -p $dstDir | ||
cp -vrT ${info.src} "$dstDir" | ||
'') | ||
typstPkgs} | ||
ls -al $typstPkgRoot | ||
''; | ||
|
||
buildPhase = '' | ||
cp -v ${./doc.typ} ./doc.typ | ||
jq '.name = "${configName}"' ${elaborateConfigJson} > config.json | ||
mkdir $out | ||
typst compile \ | ||
./doc.typ $out/${configName}.pdf | ||
''; | ||
}; | ||
}) |
This file contains 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,67 @@ | ||
#import "@preview/codly:0.2.0": * | ||
#show: codly-init.with() | ||
#codly(languages: ( | ||
bash: (name: "Bash", icon: none, color: rgb("#CE412B")), | ||
)) | ||
|
||
= T1 Docker Image Guidance | ||
|
||
== Released IP configs | ||
|
||
#let table-json(config) = { | ||
let name = config.name | ||
let param = config.parameter | ||
let floatSupport = if param.extensions.first() == "Zve32f" [ True ] else [ False ] | ||
let VRFRamType = param.vrfRamType.split(".").last() | ||
let VRF = [#param.vrfBankSize Bank, #VRFRamType] | ||
let lsuBankCnt = param.lsuBankParameters.len() | ||
let beatByteCnt = param.lsuBankParameters.first().beatbyte | ||
table( | ||
columns: 6, | ||
[*Config Name*], [*DLEN*], [*VLEN*], [*Float support*], [*VRF*], [*LSU*], | ||
[*#name*], [#param.dLen], [#param.vLen], [#floatSupport], [#VRF], [#lsuBankCnt bank, #beatByteCnt beatbyte], | ||
) | ||
} | ||
|
||
#table-json(json("./config.json")) | ||
|
||
== Address Range | ||
|
||
#table( | ||
columns: 3, | ||
[*Range*], [*Usage*], [*Address Range*], | ||
[0-1G], [Scalar Bank], [0x20000000], | ||
[1-3G], [DDR Bank (512M/bank)], [0x40000000], | ||
[3G-3G+2M], [SRAM Bank (256K/bank 8Banks)], [0xc0000000] | ||
) | ||
|
||
Scalar core cannot access Vector DDR/SRAM, for, users need to access corresponding memory banks via vector load store instructions. | ||
|
||
== How to use the Docker image | ||
|
||
```bash | ||
# Load the image into docker registry | ||
docker pull ghcr.io/chipsalliance/t1:latest | ||
# Run the t1/release:latest image with command /bin/bash, name the running container with name "t1", with [i]nterative shell and a working [t]ty. | ||
# The directory `/workspace` will be bind mount on the current directory. The container will be automatically [r]e[m]ove at exit. | ||
docker run --name t1 -it -v $PWD:/workspace --rm t1/release:latest /bin/bash | ||
``` | ||
|
||
== What is inside | ||
|
||
+ IP emulator: `/bin/ip-emulator` | ||
+ Softmax/Linear Normalization/Matmul test cases: `/workspace/cases` | ||
+ RISCV 32 GCC ToolChain | ||
|
||
== How to run workload using IP emulator | ||
|
||
```bash | ||
# There are three cases under the /workspace/cases directory | ||
ls /workspace/cases | ||
# Choose one of the case to run | ||
ip-emulator --case cases/intrinsic-matmul/bin/intrinsic.matmul.elf | ||
# Get waveform trace file | ||
ip-emulator --trace --case ... | ||
``` |
This file contains 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,63 @@ | ||
{ lib | ||
# build deps | ||
, dockerTools | ||
, runCommand | ||
|
||
# Runtime deps | ||
, bashInteractive | ||
, which | ||
, stdenv | ||
, jq | ||
|
||
# T1 Stuff | ||
, rv32-gcc | ||
, emulator-wrapped | ||
, testCases | ||
}: | ||
|
||
let | ||
# Don't use buildImage which relies on KVM feature | ||
self = dockerTools.streamLayeredImage { | ||
name = "t1/release"; | ||
tag = "latest"; | ||
|
||
contents = with dockerTools; [ | ||
usrBinEnv | ||
binSh | ||
bashInteractive | ||
which | ||
|
||
emulator-wrapped | ||
rv32-gcc | ||
] | ||
++ stdenv.initialPath; | ||
|
||
enableFakechroot = true; | ||
fakeRootCommands = '' | ||
echo "Start finalizing rootfs" | ||
echo "Creating testcase directory" | ||
mkdir -p /workspace/cases/ | ||
caseArray=( ${lib.escapeShellArgs testCases} ) | ||
for caseDir in "''${caseArray[@]}"; do | ||
dirName=$(${jq}/bin/jq -r '.name|split(".")|join("-")' "$caseDir"/*.json) | ||
cp -r "$caseDir" /workspace/cases/"$dirName" | ||
done | ||
chmod u+w -R /workspace/cases | ||
''; | ||
|
||
config = { | ||
# Cmd = [ ]; | ||
WorkingDir = "/workspace"; | ||
}; | ||
|
||
passthru = { | ||
final-image = runCommand "convert-layer-to-final-image" { } '' | ||
mkdir $out | ||
${bashInteractive}/bin/bash ${self} > $out/image.tar | ||
''; | ||
}; | ||
}; | ||
in | ||
self |