-
Notifications
You must be signed in to change notification settings - Fork 1
[DO NOT MERGE] pr for sync #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
c22f8e5
f23d491
d202bde
f6a5e3f
e69035f
65e1d18
62a2443
bfc3aea
477b83c
58e40c3
75f561c
d24053c
72002dd
286fd62
e6799f6
81bedb3
4a176aa
cde5438
5d77c5d
b269fce
4997514
53657fe
7ea5e84
4389931
8ca3fad
d39646f
7968a0b
4f10176
9f21383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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: | ||
| # 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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,11 +23,17 @@ else | |
| V:= | ||
| endif | ||
|
|
||
| #qj add | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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? | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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`. | ||
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ enum DataTypeEnum { | |
| Float64_t, | ||
| Ptrdiff_t, | ||
| Size_t, | ||
| Void, | ||
| Not_set // Don't set for `Operator` | ||
| }; | ||
|
|
||
|
|
@@ -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; | ||
|
|
@@ -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, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"; | ||
|
|
@@ -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`. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
分成几次提交,先确保 build 阶段能正确work。test阶段先删除。