Skip to content

Commit

Permalink
Add PATTERN option (for #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksco committed Dec 20, 2023
1 parent a6ae039 commit 5f56f7a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ VLEN = 256
XLEN = 64
SPLIT = 10000
INTEGER = 0
PATTERN = '.*'
SPIKE_INSTALL = $(RISCV)
OUTPUT = out/v$(VLEN)x$(XLEN)$(MODE)
OUTPUT_STAGE1 = $(OUTPUT)/tests/stage1/
Expand Down Expand Up @@ -62,7 +63,7 @@ unittest:

generate-stage1: clean-out build
@mkdir -p ${OUTPUT_STAGE1}
build/generator -VLEN ${VLEN} -XLEN ${XLEN} -split=${SPLIT} -integer=${INTEGER} -stage1output ${OUTPUT_STAGE1} -configs ${CONFIGS}
build/generator -VLEN ${VLEN} -XLEN ${XLEN} -split=${SPLIT} -integer=${INTEGER} -pattern='${PATTERN}' -stage1output ${OUTPUT_STAGE1} -configs ${CONFIGS}

include Makefrag

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Options:
- `XLEN`, default is 64, we do not support specifying ELEN yet, ELEN is consistent with XLEN
- `MODE`, default is `machine`, can be `machine`, `virtual` or `user`
- `INTEGER`, default is 0, set to 1 if you don't want float tests (i.e. for Zve32x or Zve64x)
- `PATTERN`, default is `.*`, set to a valid regex to generate the tests of your interests (e.g. `PATTERN='^v[ls].+\.v$'` to generate load/store tests)

For example, to generate `isa=rv32gcv varch=vlen:128,elen:32 mode=machine` tests, use `make -e VLEN=128 XLEN=32 MODE=machine -j$(nproc)`.

Expand Down
17 changes: 13 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ksco/riscv-vector-tests/generator"
"os"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
Expand All @@ -22,15 +23,19 @@ func fatalIf(err error) {
}

var vlenF = flag.Int("VLEN", 256, "")
var xlenF = flag.Int("XLEN", 64, "")
var splitF = flag.Int("split", 10000, "")
var integer = flag.Bool("integer", false, "")
var xlenF = flag.Int("XLEN", 64, "we do not support specifying ELEN yet, ELEN is consistent with XLEN.")
var splitF = flag.Int("split", 10000, "split per lines.")
var integerF = flag.Bool("integer", false, "only generate integer tests.")
var patternF = flag.String("pattern", ".*", "regex to filter out tests.")
var stage1OutputDirF = flag.String("stage1output", "", "stage1 output directory.")
var configsDirF = flag.String("configs", "configs/", "config files directory.")

func main() {
flag.Parse()

pattern, err := regexp.Compile(*patternF)
fatalIf(err)

if stage1OutputDirF == nil || *stage1OutputDirF == "" {
fatalIf(errors.New("-stage1output is required"))
}
Expand All @@ -49,7 +54,11 @@ func main() {
lk := sync.Mutex{}
wg := sync.WaitGroup{}
for _, file := range files {
if *integer && strings.HasPrefix(file.Name(), "vf") {
if *integerF && strings.HasPrefix(file.Name(), "vf") {
continue
}

if !pattern.MatchString(strings.TrimSuffix(file.Name(), ".toml")) {
continue
}

Expand Down

0 comments on commit 5f56f7a

Please sign in to comment.