Skip to content

Commit 74b0ca8

Browse files
authored
[CODEGEN] Skip unrolled hint, export symbol on win32 (#547)
1 parent b20678b commit 74b0ca8

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/codegen/codegen.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ std::string PackImportsToC(const runtime::Module& mod, bool system_lib) {
4646
}
4747
// translate to C program
4848
std::ostringstream os;
49+
os << "#ifdef _WIN32\n"
50+
<< "#define TVM_EXPORT __declspec(dllexport)\n"
51+
<< "#else\n"
52+
<< "#define TVM_EXPORT\n"
53+
<< "#endif\n";
4954
os << "#ifdef __cplusplus\n"
5055
<< "extern \"C\" {\n"
5156
<< "#endif\n";
52-
os << "extern const char " << runtime::symbol::tvm_dev_mblob << "[];\n";
57+
os << "TVM_EXPORT extern const char " << runtime::symbol::tvm_dev_mblob << "[];\n";
5358
uint64_t nbytes = bin.length();
5459
os << "const char " << runtime::symbol::tvm_dev_mblob
5560
<< "[" << bin.length() + sizeof(nbytes) << "] = {\n ";
@@ -82,7 +87,6 @@ std::string PackImportsToC(const runtime::Module& mod, bool system_lib) {
8287
os << "#ifdef __cplusplus\n"
8388
<< "}\n"
8489
<< "#endif\n";
85-
8690
return os.str();
8791
}
8892
} // namespace codegen

src/codegen/llvm/codegen_cpu.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ void CodeGenCPU::VisitStmt_(const AttrStmt* op) {
697697

698698
void CodeGenCPU::VisitStmt_(const For* op) {
699699
CHECK(is_zero(op->min));
700-
if (op->for_type == ForType::Serial) {
700+
if (op->for_type == ForType::Serial ||
701+
op->for_type == ForType::Unrolled) {
701702
CodeGenLLVM::VisitStmt_(op);
702703
} else if (op->for_type == ForType::Parallel) {
703704
if (parallel_env_.penv == nullptr) {

src/codegen/llvm/codegen_llvm.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,12 @@ void CodeGenLLVM::VisitStmt_(const Store* op) {
891891

892892
void CodeGenLLVM::VisitStmt_(const For* op) {
893893
CHECK(is_zero(op->min));
894-
CHECK(op->for_type == ForType::Serial);
894+
if (op->for_type == ForType::Unrolled) {
895+
LOG(WARNING) << "Unroll hint get ignore at CodeGenLLVM backend, "
896+
<< " consider set unroll_explicit=True";
897+
} else {
898+
CHECK(op->for_type == ForType::Serial);
899+
}
895900
CreateSerialFor(MakeValue(op->min), MakeValue(op->extent),
896901
ConstInt32(1), op->loop_var, op->body);
897902
}

0 commit comments

Comments
 (0)