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
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
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This repository aims to create fuzz testing for the RVV C intrinsic.

```
./rif-test --help
usage: rif-test [-h] [--gen {random_gen,fused_gen}] [--sim SIM] [--cc CC]
usage: rif-test [-h] [--gen {random_gen,fused_gen}] [--sim SIM] [--cc CC]
[--mode {full,fast}] [--node NODE] [--arch ARCH] [--abi ABI]
[--cflags CFLAGS] [--seed SEED] [--random {on,off}] [--has-policy]

Expand Down Expand Up @@ -74,4 +74,4 @@ Usage: random_gen [OPTION...]

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
```
```
2 changes: 2 additions & 0 deletions include/Basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ enum OperatorAttr : OperatorAttrT {
TailUndisturbed = 1 << 17,
MaskAgnostic = 1 << 18,
MaskUndisturbed = 1 << 19,
FRM = 1 << 20,
VXRM = 1 << 21,
};

struct OperatorBase : ValueBase {
Expand Down
16,717 changes: 2,626 additions & 14,091 deletions include/CustomOperator.def

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions include/CustomValue.def
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ CUSTOM_SCALAR_TYPE(Float64, float64_t, 64, FLOAT, 0, +20000000)
// machine dependent
CUSTOM_SCALAR_TYPE(IntXLen, ptrdiff_t, 32, SIGNED_INT, 0, 10000000)
CUSTOM_SCALAR_TYPE(UIntXLen, size_t, 32, UNSIGNED_INT, 0, 10000000)

// rounding mode
CUSTOM_SCALAR_TYPE(UIntStatus, uint8_t, 8, CONSTANT_INT, 0, 3)
18 changes: 9 additions & 9 deletions include/Decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ typedef unsigned __int128 uint128_t;
}

#define VI_VV_MERGE_LOOP(BODY) \
auto use_first = dataA[i]; \
auto vs2 = dataB[i]; \
auto vs1 = dataC[i]; \
auto use_first = dataC[i]; \
auto vs2 = dataA[i]; \
auto vs1 = dataB[i]; \
auto &vd = dataOut[i]; \
BODY

#define VI_VX_MERGE_LOOP(BODY) \
auto use_first = dataA[i]; \
auto vs2 = dataB[i]; \
auto rs1 = *dataC; \
auto use_first = dataC[i]; \
auto vs2 = dataA[i]; \
auto rs1 = *dataB; \
auto &vd = dataOut[i]; \
BODY

#define VI_VF_MERGE_LOOP(BODY) \
bool use_first = dataA[i]; \
RIF::RawDatumOperand vs2(dataB[i]); \
RIF::RawDatumOperand rs1(*dataC); \
bool use_first = dataC[i]; \
RIF::RawDatumOperand vs2(dataA[i]); \
RIF::RawDatumOperand rs1(*dataB); \
RIF::RawDatumOperand vd; \
BODY; \
dataOut[i] = vd;
Expand Down
5 changes: 4 additions & 1 deletion include/TypeInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ enum TypeClass {
FLOAT,
BOOL,
NumberOfTypeClasses,
CONSTANT_INT,
};

#define TYPE_CLASS_STR(TC) \
(TC) == SIGNED_INT ? "int" \
: (TC) == UNSIGNED_INT ? "uint" \
: (TC) == FLOAT ? "float" \
: (TC) == BOOL ? "bool" \
: (assert("Unknown type class!?"), "<SOME_THING_WRONG>")
: (TC) == CONSTANT_INT \
? "const_int" \
: (assert("Unknown type class!?"), "<SOME_THING_WRONG>")

#define TYPE_CLASS_SHORT_STR(TC) \
(TC) == SIGNED_INT ? "i" \
Expand Down
11 changes: 8 additions & 3 deletions library/Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool isScalarValue(const ValueBase *value) {

bool isOneDValue(const ValueBase *value) {
if (value->typeID.find("Op") != std::string::npos) {
std::cerr << "[isScalarValue] Should not feed operator to isOneDValue\n";
std::cerr << "[isOneDValue] Should not feed operator to isOneDValue\n";
exit(1);
}
return value->typeID.find("OneD") != std::string::npos;
Expand Down Expand Up @@ -61,7 +61,8 @@ DataTypeEnum getDataTypeEnum(const char *dataTypeString) {
else if (strcmp(dataTypeString, "size_t") == 0)
return DataTypeEnum::Size_t;
else
assert(false && "Unhandled type");
std::cerr << "Unhandled type: " << dataTypeString << std::endl;
assert(false && "Unhandled type");
}

bool isIntegral(DataTypeEnum dt) {
Expand Down Expand Up @@ -94,6 +95,10 @@ bool isNarrowingValue(ValueBase *x, ValueBase *y) {
return x->typeInfo->sew.to_int() * 2 == y->typeInfo->sew.to_int();
}

bool isFRM(OperatorBase *op) { return op->opAttr & FRM; }

bool isVXRM(OperatorBase *op) { return op->opAttr & VXRM; }

bool hasMask(const OperatorBase *op) { return op->opAttr & MaskedOperation; }

bool hasNonmask(const OperatorBase *op) {
Expand Down Expand Up @@ -202,7 +207,7 @@ ValueBase *getVs1(OperatorBase *op) {
vs1 = hasTU(op) ? op->inputs[3] : op->inputs[2];
} else
vs1 = hasMask(op)
? (op->opAttr & NoMaskedOff ? op->inputs[2] : op->inputs[3])
? (op->opAttr & NoMaskedOff ? op->inputs[1] : op->inputs[2])
: hasTU(op) ? op->inputs[2]
: op->inputs[1];
}
Expand Down
58 changes: 34 additions & 24 deletions library/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,13 @@ struct OpDefinition {
CustomValType outputType;
int numOfInputs;
std::vector<CustomValType> inputTypes;
OpDefinition(CustomValType opType,
std::string &&opTypeStr,
std::string &&opId,
int sew,
TypeClass typeClass,
uint32_t opAttr,
CustomValType outputType,
int numOfInputs,
OpDefinition(CustomValType opType, std::string &&opTypeStr,
std::string &&opId, int sew, TypeClass typeClass,
uint32_t opAttr, CustomValType outputType, int numOfInputs,
std::vector<CustomValType> inputTypes)
: opType(opType),
opTypeStr(std::move(opTypeStr)),
opId(std::move(opId)),
sew(sew),
typeClass(typeClass),
opAttr(opAttr),
outputType(outputType),
numOfInputs(numOfInputs),
inputTypes(inputTypes) {}
: opType(opType), opTypeStr(std::move(opTypeStr)), opId(std::move(opId)),
sew(sew), typeClass(typeClass), opAttr(opAttr), outputType(outputType),
numOfInputs(numOfInputs), inputTypes(inputTypes) {}
};

bool Graph::isConstructedUseDefineCandidate = false;
Expand Down Expand Up @@ -241,6 +230,31 @@ void Graph::emitHeader(std::ostream &os) {
"0x007FFFFF))\n";
os << "#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == "
"0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))\n";
std::random_device rd; // ramdom seed
std::mt19937 gen(rd()); // Pseudorandom number generator
std::uniform_int_distribution<> dist(0, 19); // scale [0, 19]

int random_number = dist(gen);
if (random_number % 4 == 0) {
os << "#define vxrm 0\n";
} else if (random_number % 4 == 1) {
os << "#define vxrm 1\n";
} else if (random_number % 4 == 2) {
os << "#define vxrm 2\n";
} else {
os << "#define vxrm 3\n";
}
if (random_number % 5 == 0) {
os << "#define frm 0\n";
} else if (random_number % 5 == 1) {
os << "#define frm 1\n";
} else if (random_number % 5 == 2) {
os << "#define frm 2\n";
} else if (random_number % 5 == 3) {
os << "#define frm 3\n";
} else {
os << "#define frm 4\n";
}
}

void Graph::generateData(uint32_t seed) {
Expand Down Expand Up @@ -269,11 +283,9 @@ void Graph::generateCCode(std::ostream &os, uint32_t seed) {
emitHeader(os);

// declare values in global (avoid stack overflow)
for (auto value : values)
{
value->generateCCode(os);
}

for (auto value : values) {
value->generateCCode(os);
}

// generate function calls for the operators
for (auto id : ordering) {
Expand Down Expand Up @@ -323,11 +335,9 @@ void Graph::generateCCode(std::ostream &os, uint32_t seed) {
}

// return 1 if any there is any failure in the operator
os << "// generated by library/Graph.cpp Graph::generateCCode";
os << "int ret = 1; // 1 = success\n";
for (auto id : ordering) {
auto op = operatorLUT[id];
os << "// operatorLUT[id] = " << operatorLUT[id] << "\n";
os << "ret &= golden_" << op->getNameWithType() << "();\n";
}
os << "if (!ret) return 1;\n";
Expand Down
Loading