Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,61 @@
name: Zeonica Test

on: push
on:
push:
pull_request:

jobs:
permissions:
contents: read

compile:
name: Compilation
jobs:
test:
name: Build, lint, and test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Check formatting
run: test -z "$(gofmt -l $(git ls-files '*.go'))"

- name: Check module files
run: go mod tidy -diff

- name: Build
run: go build ./...

- name: Vet
run: go vet ./...

- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.64.8
args: --timeout=10m

- name: Install Ginkgo
run: go install github.com/onsi/ginkgo/v2/ginkgo
- name: Unit tests
run: go test ./... -count=1

- name: Unit Test
run: ginkgo -r
integration-test:
name: Integration test
runs-on: ubuntu-latest
steps:
- name: Checkout with test fixtures
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Go Test
run: go test ./...
- name: FFT integration test
run: go test -tags=integration ./test/testbench/fft -count=1
40 changes: 5 additions & 35 deletions core/emu.go
Original file line number Diff line number Diff line change
Expand Up @@ -3186,55 +3186,23 @@
return results
}

func (i instEmulator) runSgtExport(inst Operation, state *coreState) map[Operand]cgra.Data {
func (i instEmulator) runLTExport(inst Operation, state *coreState) map[Operand]cgra.Data {
src1 := inst.SrcOperands.Operands[0]
src2 := inst.SrcOperands.Operands[1]

src1Struct := i.readOperand(src1, state)
src2Struct := i.readOperand(src2, state)
src1Val := src1Struct.First()
src2Val := src2Struct.First()

src1Pred := src1Struct.Pred
src2Pred := src2Struct.Pred
resultPred := src1Pred && src2Pred

finalPred := resultPred

//o
src1Signed := int32(src1Val)
src2Signed := int32(src2Val)

results := make(map[Operand]cgra.Data)
if src1Signed > src2Signed {
for _, dst := range inst.DstOperands.Operands {
results[dst] = cgra.NewScalarWithPred(1, finalPred)
}
} else {
for _, dst := range inst.DstOperands.Operands {
results[dst] = cgra.NewScalarWithPred(0, finalPred)
}
}
Trace("Inst", "Time", state.CurrentTime, "OpCode", inst.OpCode, "ID", inst.ID, "X", state.TileX, "Y", state.TileY, "Pred", finalPred)
// elect no next PC
return results
}

func (i instEmulator) runLTExport(inst Operation, state *coreState) map[Operand]cgra.Data {
src1 := inst.SrcOperands.Operands[0]
src2 := inst.SrcOperands.Operands[1]

src1Struct := i.readOperand(src1, state)
src2Struct := i.readOperand(src2, state)
src1Val := src1Struct.First()
src2Val := src2Struct.First()
src1Pred := src1Struct.Pred
src2Pred := src2Struct.Pred
resultPred := src1Pred && src2Pred

finalPred := resultPred
results := make(map[Operand]cgra.Data)
if src1Val < src2Val {
if src1Signed < src2Signed {
for _, dst := range inst.DstOperands.Operands {
results[dst] = cgra.NewScalarWithPred(1, finalPred)
}
Expand All @@ -3259,10 +3227,12 @@
src1Pred := src1Struct.Pred
src2Pred := src2Struct.Pred
resultPred := src1Pred && src2Pred
src1Signed := int32(src1Val)
Comment thread
n0thingNoob marked this conversation as resolved.
Dismissed
src2Signed := int32(src2Val)
Comment thread
n0thingNoob marked this conversation as resolved.
Dismissed

finalPred := resultPred
results := make(map[Operand]cgra.Data)
if src1Val > src2Val {
if src1Signed > src2Signed {
for _, dst := range inst.DstOperands.Operands {
results[dst] = cgra.NewScalarWithPred(1, finalPred)
}
Expand Down
30 changes: 25 additions & 5 deletions core/execution_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"log/slog"
"os"
"strings"
"testing"
)
Expand Down Expand Up @@ -780,10 +779,31 @@ func TestRunInstructionGroupWithSyncOpsReadyHeldOccurrenceIndexIncrements(t *tes
}

func TestLoadProgramFileFromYAMLPreservesTimeStep(t *testing.T) {
filePath := "../test/testbench/stonneGEMM8x8/gemm.yaml"
if _, err := os.Stat(filePath); os.IsNotExist(err) {
t.Skipf("test file does not exist: %s", filePath)
}
filePath := writeTestFile(t, "timesteps.yaml", `
array_config:
rows: 1
columns: 1
cores:
- row: 0
column: 0
core_id: "0"
entries:
- entry_id: entry
type: normal
instructions:
- operations:
- opcode: MOV
src_operands: [{operand: "#1", color: RED}]
dst_operands: [{operand: "$0", color: RED}]
id: 1
time_step: 0
- operations:
- opcode: ADD
src_operands: [{operand: "$0", color: RED}, {operand: "#1", color: RED}]
dst_operands: [{operand: "$1", color: RED}]
id: 2
time_step: 1
`)

programMap := LoadProgramFileFromYAML(filePath)
program, ok := programMap["(0,0)"]
Expand Down
37 changes: 19 additions & 18 deletions core/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ type returnOpcodeFunc func(Operation, *coreState, float64) map[Operand]cgra.Data

func (i instEmulator) scalarOpcodeFuncs() map[string]opcodeFunc {
return map[string]opcodeFunc{
"ADD": i.runAdd, // ADD, ADDI, INC, SUB, DEC
"SUB": i.runSub,
"SHL": i.runSHL,
"LRS": i.runLRS,
"MUL": i.runMul, // MULI
"MUL_ADD": i.runMulAdd, // dst = src0 * src1 + src2
"DIV": i.runDiv,
"OR": i.runOR,
"XOR": i.runXOR, // XOR XORI
"AND": i.runAND,
"MOV": i.runMov,
"JMP": i.runJmp,
"BNE": i.runBne,
"BEQ": i.runBeq, // BEQI
"BLT": i.runBlt,
"PHI_CONST": i.runPhiConst, // backward compatibility
"SEXT": i.runMov, // identity operation by now
"ZEXT": i.runMov, // identity operation by now
"ADD": i.runAdd, // ADD, ADDI, INC, SUB, DEC
"SUB": i.runSub,
"SHL": i.runSHL,
"LRS": i.runLRS,
"MUL": i.runMul, // MULI
"MUL_ADD": i.runMulAdd, // dst = src0 * src1 + src2
"DIV": i.runDiv,
"OR": i.runOR,
"XOR": i.runXOR, // XOR XORI
"AND": i.runAND,
"MOV": i.runMov,
"JMP": i.runJmp,
"BNE": i.runBne,
"BEQ": i.runBeq, // BEQI
"BLT": i.runBlt,
"PHI_CONST": i.runPhiConst, // backward compatibility
"SEXT": i.runMov, // identity operation by now
"ZEXT": i.runMov, // identity operation by now
"CAST_TRUNC": i.runMov, // scalar data path is uint32, so truncation is identity

"FADD": i.runFAdd, // FADDI
"FSUB": i.runFSub,
Expand Down
Loading
Loading