Skip to content

Commit

Permalink
[cases] add eval.chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
SharzyL committed Oct 6, 2024
1 parent 7bd42e0 commit af9f6ce
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ let
codegen = casesSelf.callPackage ./codegen { };
rvv_bench = casesSelf.callPackage ./rvv_bench { };
pytorch = casesSelf.callPackage ./pytorch { };
eval = casesSelf.callPackage ./eval { };
}));

# remove non-case attributes in scope
scopeStripped = {
inherit (scope) mlir intrinsic asm perf codegen rvv_bench pytorch;
inherit (scope) mlir intrinsic asm perf codegen rvv_bench pytorch eval;
};

# This derivation is for internal CI use only.
Expand Down
27 changes: 27 additions & 0 deletions tests/eval/chaining/chaining.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.text
.balign 16
.globl test

test:
la t1, test_src_start # t1 = addr
la t2, test_src_end
sub t2, t2, t1 # t2 = remaining length
loop_start:
vsetvli t0, t2, e8, m8, ta, ma # t0 = vl
vle8.v v8, (t1)
vadd.vx v16, v8, t2 # v8 from last vle
vmul.vv v24, v16, v8 # v16 from last instr
vsub.vv v8, v24, v16 # v16 from last 2 instr, v24 from last instr
vse8.v v8, (t1)

add t1, t1, t0 # incr addr
sub t2, t2, t0 # decr length
bnez t2, loop_start

ret

.section .vbss, "aw", @nobits
.balign 64
test_src_start:
.zero 8192 # 8KB
test_src_end:
35 changes: 35 additions & 0 deletions tests/eval/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ lib
, linkerScript
, makeBuilder
, findAndBuild
, t1main
, getTestRequiredFeatures
}:

let
builder = makeBuilder { casePrefix = "eval"; };
build = { caseName, sourcePath }:
builder {
inherit caseName;

src = sourcePath;

passthru.featuresRequired = getTestRequiredFeatures sourcePath;
isFp = lib.pathExists (lib.path.append sourcePath "isFp");

buildPhase = ''
runHook preBuild
$CC -T${linkerScript} \
${caseName}.S \
${t1main} \
-o $pname.elf
runHook postBuild
'';

meta.description = "test case '${caseName}', written in C assembly";
};
in
findAndBuild ./. build

0 comments on commit af9f6ce

Please sign in to comment.