Skip to content

Commit

Permalink
Merge pull request #12 from XYenChi/fix-prefix
Browse files Browse the repository at this point in the history
Add __riscv_ prefix for new intrinsic.
  • Loading branch information
XYenChi authored Oct 29, 2024
2 parents c39bc65 + d8a295b commit 30a75c6
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/
include/autogen
include/AutoGenComputeOp.h
*.pyc
test/
4 changes: 2 additions & 2 deletions include/TypeInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ struct TypeInfo {
sew.to_string()),
shortVectorTypeName((std::string(TYPE_CLASS_SHORT_STR(typeClass)) +
sew.to_string() + std::string(LMUL_STR(lmul)))),
setvlTypeName("vsetvl_e" + sew.to_string() +
setvlTypeName("__riscv_vsetvl_e" + sew.to_string() +
std::string(LMUL_STR(lmul))),
setvlmaxTypeName("vsetvlmax_e" + sew.to_string() +
setvlmaxTypeName("__riscv_vsetvlmax_e" + sew.to_string() +
std::string(LMUL_STR(lmul))) {}
};

Expand Down
5 changes: 5 additions & 0 deletions library/Basic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Basic.cpp
/*
Implementations.
The MACRO `CUSTOM_OP_TYPE` declared under `include/CustomOperator.def'
will be fed into this file for enum definition,
include/Operator.hpp for derived class definition
library/Operator.cpp for derived class member function implementation.
*/
#include "Basic.hpp"

Expand Down
34 changes: 25 additions & 9 deletions library/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ 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 @@ -214,6 +225,7 @@ Graph::getOperatorsInReverseTopologicalOrder(uint32_t seed) {
}

void Graph::emitHeader(std::ostream &os) {
os << "// generated by library/Graph.cpp Graph::emitHeader\n";
os << "#include <stdbool.h>\n";
os << "#include <stdint.h>\n";
os << "#include <stdlib.h>\n";
Expand Down Expand Up @@ -258,16 +270,19 @@ void Graph::generateCCode(std::ostream &os, uint32_t seed) {

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


// generate function calls for the operators
for (auto id : ordering) {
auto op = operatorLUT[id];

if (op->type != Initialize)
initializeLmul(op);

os << "void " << op->getNameWithType() << "() {\n";
os << "// getNameWithType \n";
op->generateCCode(os);
os << "}\n";
}
Expand All @@ -280,7 +295,6 @@ void Graph::generateCCode(std::ostream &os, uint32_t seed) {
// values that are non-intermediate results.
if (VerificationMode == "short" && op->outputs[0]->outputs.size() != 0)
continue;

os << "int golden_" << op->getNameWithType() << "() {\n";

generateVerificationCode(os, op);
Expand Down Expand Up @@ -309,9 +323,11 @@ 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

0 comments on commit 30a75c6

Please sign in to comment.