Skip to content

Commit 4429a6a

Browse files
committed
[GAP-CI] Some CI Bugs fixed
1 parent f88d5c5 commit 4429a6a

File tree

18 files changed

+220
-1081
lines changed

18 files changed

+220
-1081
lines changed

.github/workflows/_runner-gap9-tiled.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,25 @@ jobs:
5858
submodules: recursive
5959
- name: Build Deeploy
6060
shell: bash
61-
run: pip install -e .
62-
- name: Cache ccache
63-
uses: actions/cache/restore@v4
61+
run: |
62+
source /app/install/gap9-sdk/.gap9-venv/bin/activate
63+
source /app/install/gap9-sdk/configs/gap9_evk_audio.sh || true
64+
pip install -e . || true
65+
deactivate
66+
- name: Setup ccache
67+
uses: actions/cache@v4
6468
with:
6569
path: /app/.ccache
6670
key: ccache-ci
6771
- name: Run Test
68-
uses: nick-fields/retry@v3
69-
with:
70-
timeout_minutes: 15
71-
max_attempts: 3
72-
retry_on: timeout
73-
command: |
74-
cd DeeployTest
75-
mkdir -p /app/.ccache
76-
export CCACHE_DIR=/app/.ccache
77-
python testRunner_tiled_gap9.py -t Tests/${{ inputs.test-name }} --cores=${{ inputs.num-cores }} --l1 ${{ matrix.L1 }} --defaultMemLevel=${{ inputs.default-memory-level }} ${{ inputs.double-buffer && '--doublebuffer' || '' }} --memAllocStrategy=${{ inputs.memory-allocation-strategy }} --searchStrategy=${{ inputs.search-strategy }}
78-
shell: bash
72+
run: |
73+
source /app/install/gap9-sdk/.gap9-venv/bin/activate
74+
source /app/install/gap9-sdk/configs/gap9_evk_audio.sh || true
75+
export GVSOC_INSTALL_DIR=/app/install/gap9-sdk/install/workstation
76+
export GAP_RISCV_GCC_TOOLCHAIN=/app/install/gcc/gap9
77+
cd DeeployTest
78+
mkdir -p /app/.ccache
79+
export CCACHE_DIR=/app/.ccache
80+
python testRunner_tiled_gap9.py -t Tests/${{ inputs.test-name }} --cores=${{ inputs.num-cores }} --l1 ${{ matrix.L1 }} --defaultMemLevel=${{ inputs.default-memory-level }} ${{ inputs.double-buffer && '--doublebuffer' || '' }} --memAllocStrategy=${{ inputs.memory-allocation-strategy }} --searchStrategy=${{ inputs.search-strategy }}
81+
deactivate
82+
shell: bash

.github/workflows/_runner-gap9.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838
source /app/install/gap9-sdk/configs/gap9_evk_audio.sh || true
3939
pip install -e . || true
4040
deactivate
41-
- name: Cache ccache
42-
uses: actions/cache/restore@v4
41+
- name: Setup ccache
42+
uses: actions/cache@v4
4343
with:
4444
path: /app/.ccache
45-
key: ccache-ci
45+
key: ccache-ci
4646
- name: Run Test
4747
run: |
4848
testNames="${{ inputs.test-names }}"

.github/workflows/ci-platform-gap9-tiled.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ jobs:
4747
L1: [800, 500, 300]
4848
- name: "testConcat"
4949
L1: [32000, 16000, 8000]
50-
- name: "testRMSNorm"
51-
L1: [2048, 1024, 512]
5250
- name: "Hardswish"
5351
L1: [750]
5452
- name: "RQHardswish"
@@ -83,8 +81,6 @@ jobs:
8381
L1: [2000]
8482
- name: "testFloatMul"
8583
L1: [2000]
86-
- name: "largeFloatAdd"
87-
L1: [220000]
8884
- name: "testRQGEMMwBatch"
8985
L1: [20000]
9086
- name: "testMatMulBatch"
@@ -113,8 +109,6 @@ jobs:
113109
L1: [1600, 1000, 600]
114110
- name: "testConcat"
115111
L1: [64000, 32000, 16000]
116-
- name: "testRMSNorm"
117-
L1: [4096, 2048, 1024]
118112
- name: "Hardswish"
119113
L1: [750]
120114
- name: "RQHardswish"

.github/workflows/ci-platform-gap9.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
test2DRequantizedConv
4747
iSoftmax
4848
testConcat
49-
testRMSNorm
5049
trueIntegerDivSandwich
5150
Hardswish
5251
RQHardswish

.github/workflows/infra-generate-ccache.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ jobs:
4343
python testRunner_tiled_siracusa.py -t ./Tests/Adder
4444
python testRunner_tiled_siracusa_w_neureka.py -t ./Tests/Adder
4545
python testRunner_chimera.py -t ./Tests/Adder
46+
47+
# GAP9 tests
48+
source /app/install/gap9-sdk/.gap9-venv/bin/activate
49+
source /app/install/gap9-sdk/configs/gap9_evk_audio.sh || true
50+
export GVSOC_INSTALL_DIR=/app/install/gap9-sdk/install/workstation
51+
export GAP_RISCV_GCC_TOOLCHAIN=/app/install/gcc/gap9
52+
python testRunner_gap9.py -t ./Tests/Adder
53+
python testRunner_tiled_gap9.py -t ./Tests/Adder
54+
deactivate
4655
- name: Clean and Upload CCache
4756
uses: actions/cache@v4
4857
with:

Container/Dockerfile.Gap9

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM ghcr.io/pulp-platform/deeploy:latest
2+
3+
ENV GAP_RISCV_GCC_TOOLCHAIN=/app/install/gcc/gap9
4+
ENV GAP_SDK_HOME=/app/install/gap9-sdk
5+
ENV GAP_RISCV_GCC_TOOLCHAIN=/app/install/gcc/gap9
6+
7+
WORKDIR /app
8+
9+
# Install SSH keys to access private repositories
10+
RUN mkdir -p -m 0700 ~/.ssh && \
11+
ssh-keyscan iis-git.ee.ethz.ch >> ~/.ssh/known_hosts && \
12+
ssh-keyscan github.com >> ~/.ssh/known_hosts
13+
14+
COPY Makefile ./
15+
COPY toolchain/*.patch toolchain/
16+
17+
RUN apt-get update && \
18+
apt-get upgrade -y && \
19+
apt-get install -y \
20+
sudo \
21+
rsync \
22+
build-essential \
23+
g++ \
24+
python3-dev \
25+
device-tree-compiler \
26+
bison \
27+
flex && \
28+
rm -rf /var/lib/apt/lists/*
29+
30+
RUN --mount=type=cache,target=/ccache \
31+
ccache -z && make gap9-toolchain && \
32+
rm -rf /app/toolchain/gap9-toolchain
33+
34+
RUN --mount=type=ssh \
35+
--mount=type=cache,target=/ccache \
36+
--mount=type=cache,target=/root/.cache/pip \
37+
ccache -z && \
38+
make gap9-sdk && \
39+
ccache -s && \
40+
rm -rf /app/toolchain/gap9-sdk && \
41+
rm -rf /app/install/gap9-sdk/build && \
42+
rm -rf /app/install/gap9-sdk/.git && \
43+
rm -rf /app/install/gap9-sdk/nn_menu && \
44+
find /app/install/gap9-sdk -name "*.o" -delete && \
45+
find /app/install/gap9-sdk -name "*.a" -not -path "*/lib/*" -delete

Container/Dockerfile.toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ RUN rm -rf cmake-* && \
119119
rm -rf toolchain/llvm-project && \
120120
rm -rf toolchain/minimalloc && \
121121
rm -rf toolchain/picolibc && \
122-
rm -rf toolchain/gap9-toolchain
122+
rm -rf toolchain/gap9-toolchain

Deeploy/Targets/GAP9/Bindings.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
54
"""
65
GAP9-specific bindings using cl_dma.h API instead of low-level MCHAN.
76
@@ -12,32 +11,29 @@
1211
import itertools
1312

1413
from Deeploy.AbstractDataTypes import PointerClass
14+
from Deeploy.CommonExtensions.CodeTransformationPasses.MemoryAllocation import ArgumentStructGeneration, \
15+
MemoryManagementGeneration, MemoryPassthroughGeneration
1516
from Deeploy.CommonExtensions.DataTypes import FloatDataTypes, IntegerDataTypes, SignedIntegerDataTypes, float32_t, \
1617
int8_t, int32_t, int64_t, uint8_t
1718
from Deeploy.DeeployTypes import CodeTransformation, NodeBinding
1819
from Deeploy.FutureExtension.Bindings.AutoFutureBinding import AutoFutureBinding
19-
from Deeploy.CommonExtensions.CodeTransformationPasses.MemoryAllocation import ArgumentStructGeneration, \
20-
MemoryManagementGeneration, MemoryPassthroughGeneration
2120
from Deeploy.FutureExtension.CodeTransformationPasses.FutureCodeTransformation import FutureGeneration
22-
from Deeploy.TilingExtension.CodeTransformationPasses.TilingVariableReplacement import TilingVariableReplacement, \
23-
TilingVariableReplacementUpdate
24-
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPClusterSynch import PULPSynchCoresPass
25-
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPClusterTiling import PULPClusterTiling
26-
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPL3Tiling import PULPL3Tiling
27-
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPProfileUntiled import PULPProfileUntiled
28-
from Deeploy.Targets.PULPOpen.Bindings import TilingCallClosure, ForkClosure, \
29-
MemoryAwareFunctionCallClosure, L3MemoryAwareFunctionCallClosure, MemoryAwareForkTransformer
30-
from Deeploy.Targets.PULPOpen.DataTypes import PULPDMAFuture
31-
from Deeploy.Targets.GAP9.DMA.MchanDma import GAP9MchanDma
3221
from Deeploy.Targets.GAP9.DMA.L3Dma import gap9L3DmaHack
33-
22+
from Deeploy.Targets.GAP9.DMA.MchanDma import GAP9MchanDma
3423
# Import templates from PULPOpen and Generic
3524
from Deeploy.Targets.Generic.Templates import AddTemplate, ConcatTemplate, DequantTemplate, FloatReduceMeanTemplate, \
3625
FloatReduceSumTemplate, GatherTemplate, QuantTemplate, RQSiGELUTemplate, SliceTemplate, iHardswishTemplate
3726
from Deeploy.Targets.Generic.TypeCheckers import AddChecker, ConcatChecker, ConvChecker, DequantChecker, \
3827
GatherChecker, GELUChecker, GEMMChecker, HardswishChecker, LayerNormChecker, MatMulChecker, MulChecker, \
3928
QuantChecker, ReduceMeanChecker, ReluChecker, ReshapeChecker, RQAddChecker, RQHardswishChecker, SGDChecker, \
4029
SliceChecker, SoftmaxChecker, SoftmaxCrossEntropyLossChecker, TransposeChecker
30+
from Deeploy.Targets.PULPOpen.Bindings import ForkClosure, L3MemoryAwareFunctionCallClosure, \
31+
MemoryAwareForkTransformer, MemoryAwareFunctionCallClosure, TilingCallClosure
32+
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPClusterSynch import PULPSynchCoresPass
33+
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPClusterTiling import PULPClusterTiling
34+
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPL3Tiling import PULPL3Tiling
35+
from Deeploy.Targets.PULPOpen.CodeTransformationPasses.PULPProfileUntiled import PULPProfileUntiled
36+
from Deeploy.Targets.PULPOpen.DataTypes import PULPDMAFuture
4137
from Deeploy.Targets.PULPOpen.Templates import ConvTemplate, DMASliceTemplate, FloatAddTemplate, FloatConvTemplate, \
4238
FloatGELUTemplate, FloatGemmTemplate, FloatLayernormTemplate, FloatMatMulTemplate, FloatMaxPoolTemplate, \
4339
FloatMulTemplate, FloatReluTemplate, FloatSoftmaxTemplate, GEMMTemplate, MatrixVectorTemplate, MaxPool2DTemplate, \
@@ -46,7 +42,8 @@
4642
iRMSNormTemplate, iSoftmaxTemplate
4743
from Deeploy.Targets.PULPOpen.TypeCheckers import PULPConvChecker, PULPLinearChecker, PULPMaxPoolChecker, \
4844
PULPRequantShiftChecker
49-
45+
from Deeploy.TilingExtension.CodeTransformationPasses.TilingVariableReplacement import TilingVariableReplacement, \
46+
TilingVariableReplacementUpdate
5047

5148
# GAP9-specific transformer using cl_dma.h API
5249
GAP9Transformer = CodeTransformation([
@@ -102,7 +99,6 @@
10299
MemoryPassthroughGeneration(),
103100
FutureGeneration()])
104101

105-
106102
# ===============================================================================
107103
# GAP9-specific bindings using ClDma instead of MchanDma
108104
# All bindings below use GAP9Transformer or GAP9ClusterTransformer

Deeploy/Targets/GAP9/DMA/MchanDma.py

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,31 @@
1010

1111

1212
class MchanTransferFuture(Future):
13-
"""
14-
Future implementation for GAP9's MCHAN v7 low-level API.
15-
Based on DORY's implementation: https://github.com/pulp-platform/dory
16-
17-
Uses direct hardware register access for maximum performance.
18-
"""
19-
2013
_initTemplate = NodeTemplate("int ${name} = -1;")
2114

2215
_deinitTemplate = NodeTemplate("")
2316

2417
_allocTemplate = NodeTemplate("${name} = mchan_transfer_get_id();")
2518

2619
_waitTemplate = NodeTemplate("""
27-
if (${name} >= 0) {
28-
mchan_transfer_wait(${name});
29-
mchan_transfer_free(${name});
30-
}
31-
""")
20+
if (${name} >= 0) {
21+
mchan_transfer_wait(${name});
22+
mchan_transfer_free(${name});
23+
}
24+
""")
3225

3326

3427
class GAP9MchanDma(AsyncDma):
35-
"""
36-
GAP9 Cluster DMA implementation using MCHAN v7 low-level API.
37-
38-
This implementation follows DORY's approach for GAP9:
39-
- Direct hardware register access for MCHAN v7
40-
- Manual transfer ID management
41-
- Support for 1D, 2D, and 3D transfers
42-
- Event-based or polled synchronization
43-
44-
References:
45-
- DORY GAP9: https://github.com/pulp-platform/dory/tree/master/dory/Hardware_targets/PULP/GAP9
46-
- MCHAN v7 specification in GAP9 documentation
47-
"""
4828

4929
_transferTemplates = {
50-
1: NodeTemplate("{ mchan_transfer_t __mchan_tmp = { .cmd = ${cmd}, .size = ${size}, .loc = ${loc}, .ext = ${ext} }; mchan_transfer_push_1d(__mchan_tmp); }"),
51-
2: NodeTemplate("{ mchan_transfer_t __mchan_tmp = { .cmd = ${cmd}, .size = ${size}, .loc = ${loc}, .ext = ${ext}, .ext_size_1d = ${size_1d}, .ext_stride_1d = ${stride_2d} }; mchan_transfer_push_2d(__mchan_tmp); }"),
30+
1:
31+
NodeTemplate(
32+
"{ mchan_transfer_t __mchan_tmp = { .cmd = ${cmd}, .size = ${size}, .loc = ${loc}, .ext = ${ext} }; mchan_transfer_push_1d(__mchan_tmp); }"
33+
),
34+
2:
35+
NodeTemplate(
36+
"{ mchan_transfer_t __mchan_tmp = { .cmd = ${cmd}, .size = ${size}, .loc = ${loc}, .ext = ${ext}, .ext_size_1d = ${size_1d}, .ext_stride_1d = ${stride_2d} }; mchan_transfer_push_2d(__mchan_tmp); }"
37+
),
5238
}
5339
_waitingStrategy = DirectionWaitingStrategy(MchanTransferFuture, "transfer")
5440

Deeploy/Targets/GAP9/Deployer.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
54
"""
65
GAP9-specific deployer that uses cl_dma.h API.
76
87
This deployer extends PULPDeployer to use GAP9-specific DMA (ClDma) via
98
the GAP9Bindings transformers.
109
"""
1110

12-
from typing import Callable, Dict, List, Type
11+
from typing import Callable, Dict, Type
1312

1413
import numpy as np
1514
import onnx_graphsurgeon as gs
1615

1716
from Deeploy.AbstractDataTypes import Pointer
1817
from Deeploy.CommonExtensions.NetworkDeployers.SignPropDeployer import SignPropDeployer
1918
from Deeploy.DeeployTypes import ConstantBuffer, DeploymentPlatform, NodeTemplate, TopologyOptimizer, VariableBuffer
19+
from Deeploy.Targets.GAP9.Bindings import GAP9ClusterTransformer, GAP9SimpleTransformer, GAP9Transformer
2020
from Deeploy.Targets.PULPOpen.Deployer import PULPDeployer
21-
from Deeploy.Targets.GAP9.Bindings import GAP9Transformer, GAP9ClusterTransformer, GAP9SimpleTransformer
2221

2322
# GAP9-specific L3 RAM allocation and loading templates
2423
_GAP9L3AllocTemplate = NodeTemplate("""
@@ -62,7 +61,7 @@ def __init__(self,
6261
default_channels_first = default_channels_first,
6362
deeployStateDir = deeployStateDir,
6463
inputOffsets = inputOffsets)
65-
64+
6665
# Override transformers to use GAP9-specific ones with ClDma
6766
self.Transformer = GAP9Transformer
6867
self.ClusterTransformer = GAP9ClusterTransformer
@@ -73,8 +72,7 @@ def generateBufferAllocationCode(self) -> str:
7372

7473
L3FileStr = ""
7574
globalConstBuffers = [
76-
buf for key, buf in self.ctxt.globalObjects.items()
77-
if isinstance(buf, VariableBuffer) and buf._deploy
75+
buf for key, buf in self.ctxt.globalObjects.items() if isinstance(buf, VariableBuffer) and buf._deploy
7876
]
7977
nonArenaBuffers = [buf for buf in globalConstBuffers if buf._users != []]
8078
outputBuffNames = [outputBuffer.name for outputBuffer in self.graph.outputs]
@@ -94,18 +92,10 @@ def generateBufferAllocationCode(self) -> str:
9492

9593
# Allocate L3 RAM space (for constant buffers only)
9694
if isinstance(buf, ConstantBuffer):
97-
L3FileStr += _GAP9L3AllocTemplate.generate({
98-
"locPtr": locPtr,
99-
"extName": extName,
100-
"size": size
101-
})
95+
L3FileStr += _GAP9L3AllocTemplate.generate({"locPtr": locPtr, "extName": extName, "size": size})
10296

10397
# Load data from ReadFS
104-
L3FileStr += _GAP9L3InitTemplate.generate({
105-
"locPtr": locPtr,
106-
"extName": extName,
107-
"size": size
108-
})
98+
L3FileStr += _GAP9L3InitTemplate.generate({"locPtr": locPtr, "extName": extName, "size": size})
10999

110100
retStr = retStr + L3FileStr
111101

0 commit comments

Comments
 (0)