Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c22f8e5
Port riscv-vector-fuzzing-test for rvv intrinsic v1.0.0
XYenChi May 10, 2024
f23d491
[NFC] Auto-commit clang-format from github action
Dec 8, 2024
d202bde
Remove debug message
XYenChi Dec 9, 2024
f6a5e3f
Fix vmv decode name
XYenChi Dec 9, 2024
e69035f
Remove maskoff
XYenChi Dec 10, 2024
65e1d18
[WIP] fix rounding mode
XYenChi Dec 13, 2024
62a2443
[NFC] Auto-commit clang-format from github action
Dec 13, 2024
bfc3aea
Update CustomOperator.def: Add input and output nfield parameter
XYenChi Dec 16, 2024
477b83c
[WIP] Add segment load store and miscellaneous operator
XYenChi Dec 17, 2024
58e40c3
[WIP]Add segment load store compute{op_type}Op.h generate script
XYenChi Dec 19, 2024
75f561c
[WIP]Add segment load store compute{op_type}Op.h generate script
XYenChi Dec 19, 2024
d24053c
Add SegStoreOperation SegLoadOperation Miscellaneous in OpAttr
Liaoshihua Dec 19, 2024
72002dd
Merge pull request #1 from Liaoshihua/develop
XYenChi Dec 19, 2024
286fd62
[NFC] Auto-commit clang-format from github action
Dec 19, 2024
e6799f6
Add Miscellaneous function vreinterpret generation script
XYenChi Dec 19, 2024
81bedb3
Add Void type
XYenChi Dec 19, 2024
4a176aa
pass input_nfields and output_nfield
XYenChi Dec 19, 2024
cde5438
[WIP] add tuple type nf
XYenChi Jan 1, 2025
5d77c5d
Fix code format
XYenChi Jan 2, 2025
b269fce
Add segment load and store attribute
XYenChi Mar 24, 2025
4997514
Modify to ease dev
qjivy Mar 21, 2025
53657fe
Fix input_nfield and output_nfield generation issue
XYenChi Mar 25, 2025
7ea5e84
Fix input_nfield and output_field type issue
XYenChi Mar 25, 2025
4389931
update removed SizePtr and replacing void with vs3 type segment load …
XYenChi Mar 26, 2025
8ca3fad
Remove erroneous modifications and Add tips for use
XYenChi Mar 28, 2025
d39646f
Add build CI
XYenChi Mar 28, 2025
7968a0b
Add gcc test
XYenChi Mar 28, 2025
4f10176
Add test CI
XYenChi Mar 28, 2025
9f21383
[NFC] Auto-commit clang-format from github action
Mar 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: build
on:
push:
branches: [dev]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build generator
run: |
mkdir -p build
cd build
cmake ..
make -j $(nproc)
./tool/randomgen
- uses: actions/upload-artifact@v4
with:
name: built
path: build

test:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

分成几次提交,先确保 build 阶段能正确work。test阶段先删除。

# needs: build
runs-on: ubuntu-latest
env:
COMPILER_TAG: '2025.03.28'
strategy:
matrix:
compiler: [gcc, llvm]
steps:
- name: download compiler with v extension release
id: download
uses: robinraju/release-downloader@v1
with:
repository: XYenChi/riscv-gnu-toolchain
tag: ${{env.COMPILER_TAG}}
fileName: 'riscv64-elf-ubuntu-24.04-${{matrix.compiler}}-nightly-${{env.COMPILER_TAG}}-nightly.tar.xz'

- name: extract compiler
run: |
tar -Jxvf "${{fromJson(steps.download.outputs.downloaded_files)[0]}}"
export PATH=$PWD/riscv/bin:$PATH
case "${{matrix.compiler}}" in
"gcc")
export CC="riscv64-unknown-elf-gcc";;
"llvm")
export CC="clang";;
esac
- uses: actions/checkout@v2

- uses: actions/download-artifact@v4
with:
path: build

- name: run ${{matrix.compiler}} test
run: |
env
cd test
make clean
./rif-test --cc=$CC
make -j $(nproc)
4 changes: 2 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.12
- uses: DoozyX/clang-format-lint-action@v0.18.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format 的升级,单独一个pr,只修改这一个文件。

with:
source: '.'
extensions: 'hpp,cpp'
clangFormatVersion: 12
clangFormatVersion: 16
inplace: True
- uses: EndBug/add-and-commit@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set_property(GLOBAL PROPERTY CXX_STANDARD 17)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v --save-temps")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调试用途的不用加入到代码中。在调用cmake的时候命令行添加即可。不要添加这个修改。

set(INC ${CMAKE_CURRENT_LIST_DIR}/include)
set(SPIKE ${CMAKE_CURRENT_LIST_DIR}/riscv-isa-sim)
set(LIB ${CMAKE_CURRENT_LIST_DIR}/library)
Expand All @@ -33,7 +33,7 @@ add_custom_target(generate_headers ALL
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
URL https://github.com/google/googletest/archive/refs/tags/v1.16.0.zip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果原来的zip能work就不要修改。

)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand Down
10 changes: 8 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ else
V:=
endif

#qj add
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

作者信息体现在 git commit message 中,不要写在注释里。这是早年没有VCS版本管理工具的时候的做法。

define cmd
(set -x; $(1)) >>$@ 2>&1 \
|| (echo $(2) >> $@ && exit 1)
(set -x; $(1) && (echo "Success: $(1) finished!")) \
|| (echo $(2) && exit 1)
endef

#define cmd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果不需要了,删除掉,而不是注释掉;以后如果要恢复,用git revert。

#(set -x; $(1)) >>$@ 2>&1 \
#|| (echo $(2) >> $@ && exit 1)
#endef

all:
-$(MAKE) -k run
$(MAKE) report
Expand Down
69 changes: 35 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ This repository aims to create fuzz testing for the RVV C intrinsic.

## Usage

1. Build the random generator tool.
2. Use the test driver under test/.

### How To Build?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果不是单独大幅度重构,修改内容不要调整次序,调整次序尽量不要同时修改内容。方便我没有经验的新加入的reviewer看懂。


```
$ git clone https://github.com/sifive/riscv-vector-intrinsic-fuzzing
$ cd riscv-vector-intrinsic-fuzzing
$ cd build
$ cmake ..
$ make
$ ./tool/random_gen --help
Usage: random_gen [OPTION...]

-c, --code=FILE C code file, default filename: 'output.c'
-d, --dot=FILE Graphviz visualization file, default filename is
'output.dot'
-h Give this help list
-m, --march=ARCH_STRING Arch string for testing, default is rv64gcv
-n, --nodes-to-gen=NODES_TO_GEN
The number of nodes to generate for the graph.
-r, --root=OPERATOR_ENUM Initial node for the graph generation, default
root is 'AddVV32'
-s, --seed=RANDOM_SEED Seed for random number generator, default seed is
'0xdeadbeef'
-v, --verbose Produce verbose output
-?, --help Give this help list
--usage Give a short usage message

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
```

### How To Use?

`rif-test` is the current driver to fuzz all existing intrinsics in `include/CustomOperator.def`.
Expand Down Expand Up @@ -37,41 +70,9 @@ own simulator (QEMU), please add `${PATH_TO_QEMU_BINARY} ${CPU_CONFIGS}` of how


```
$ git clone https://github.com/sifive/rvv-intrinsic-fuzzing
$ mkdir test
$ git clone https://github.com/sifive/riscv-vector-intrinsic-fuzzing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新的pr添加 plctlab 的 repo url。从这个 repo 看到的信息就需要默认下载的 plctlab 的(同时保留 upstream 的构建信息,以后 upstream 的时候是删除/不包含 plctlab 的部分的)

$ cd test
$ ../rvv-intrinsic-fuzzing/rif-test --cc=<YOUR-COMPILER-PATH>
$ ../rif-test --cc=<YOUR-COMPILER-PATH>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit 30a75c6 看到已经没有这个修改了。是不是没有 rebase 到 develop 分支?

$ make
```



### How To Build?

```
$ git clone https://github.com/sifive/rvv-intrinsic-fuzzing
$ cd rvv-intrinsic-fuzzing
$ mkdir build; cd build
$ cmake ..
$ make
$ ./tool/random_gen --help
Usage: random_gen [OPTION...]

-c, --code=FILE C code file, default filename: 'output.c'
-d, --dot=FILE Graphviz visualization file, default filename is
'output.dot'
-h Give this help list
-m, --march=ARCH_STRING Arch string for testing, default is rv64gcv
-n, --nodes-to-gen=NODES_TO_GEN
The number of nodes to generate for the graph.
-r, --root=OPERATOR_ENUM Initial node for the graph generation, default
root is 'AddVV32'
-s, --seed=RANDOM_SEED Seed for random number generator, default seed is
'0xdeadbeef'
-v, --verbose Produce verbose output
-?, --help Give this help list
--usage Give a short usage message

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
```
27 changes: 22 additions & 5 deletions include/Basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ enum DataTypeEnum {
Float64_t,
Ptrdiff_t,
Size_t,
Void,
Not_set // Don't set for `Operator`
};

Expand Down Expand Up @@ -106,6 +107,7 @@ struct ValueBase {
const std::string dataTypeID;

std::vector<ValueBase *> inputs;
std::vector<std::vector<ValueBase *>> tuple_inputs; // todo:
std::vector<ValueBase *> outputs;

int length;
Expand Down Expand Up @@ -138,22 +140,33 @@ enum OperatorAttr : OperatorAttrT {
TailUndisturbed = 1 << 17,
MaskAgnostic = 1 << 18,
MaskUndisturbed = 1 << 19,
FRM = 1 << 20,
VXRM = 1 << 21,
Miscellaneous = 1 << 22,
SegStoreOperation = 1 << 23,
SegLoadOperation = 1 << 24,
NeedMerge = 1 << 25,
};

struct OperatorBase : ValueBase {

OperatorBase(const CustomValType &type, const std::string &typeID,
const std::string &id, const OperatorAttrT opAttr,
const unsigned numOfInputs,
const unsigned numOfInputs, // number of inputs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面的注释可以删除。

const std::initializer_list<CustomValType> inputTypes,
const unsigned input_nfield, const unsigned output_nfield,
const CustomValType outputType, int dataWidth, LmulType lmul,
TypeClass typeClass)
: ValueBase(type, typeID, id, numOfInputs, typeClass, dataWidth, lmul),
input_nfield(input_nfield), output_nfield(output_nfield),
opAttr(opAttr), inputTypes(inputTypes), outputType(outputType) {}

virtual ~OperatorBase() = default;
const unsigned input_nfield;
const unsigned output_nfield;

// returns 1 if fail
virtual ~OperatorBase() = default;
// (RIF::CustomValType, const char [8], const std::string&, unsigned int, int,
// <brace-enclosed initializer list>, unsigned int, unsigned int,
// RIF::CustomValType, int, RIF::LmulType&, RIF::TypeClass) returns 1 if fail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上述3行代码没看懂跟代码的关联,如果是老的代码,删除,不要留在注释里。如果是解释下面的代码,增加一点说明,跟上面的代码空出一行。如果是解释上面的代码,移到上面代码的上面去。

int addInput(int inputIdx, ValueBase *input) {
if (inputIdx >= inputs.size()) {
std::cerr << "addInput: inputIdx is out of range, abort.\n";
Expand Down Expand Up @@ -223,19 +236,23 @@ bool isMaskOfOperator(OperatorBase *op, ValueBase *value);
bool isMaskedoffOfOperator(OperatorBase *op, ValueBase *value);
bool isVs2OfOperator(OperatorBase *op, ValueBase *value);
bool isVs1OfOperator(OperatorBase *op, ValueBase *value);
bool isFrmOfOperator(OperatorBase *op, ValueBase *value);
bool isExistVs1Rs1(OperatorBase *op);
bool isWideningOperator(OperatorBase *op);
bool isNarrowingOperator(OperatorBase *op);
bool isWideningValue(ValueBase *x, ValueBase *y); // is X Widen of Y
bool isNarrowingValue(ValueBase *x, ValueBase *y); // is X Narrow of Y
bool isSegStoreOperation(OperatorBase *op);
bool isSegLoadOperation(OperatorBase *op);
bool isMiscellaneous(OperatorBase *op);

// Getters for input/output of an Operator
ValueBase *getVd(OperatorBase *op);
ValueBase *getMask(OperatorBase *op);
ValueBase *getMaskedoff(OperatorBase *op);
ValueBase *getVs2(OperatorBase *op);
ValueBase *getVs1(OperatorBase *op);

ValueBase *getFrm(OperatorBase *op);
/*
Set all inputs/outputs to LMUL of `op`.

Expand Down
Loading