Skip to content

Commit

Permalink
[CODEGEN] Skip unrolled hint, export symbol on win32 (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored Oct 13, 2017
1 parent b20678b commit 74b0ca8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/codegen/codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ std::string PackImportsToC(const runtime::Module& mod, bool system_lib) {
}
// translate to C program
std::ostringstream os;
os << "#ifdef _WIN32\n"
<< "#define TVM_EXPORT __declspec(dllexport)\n"
<< "#else\n"
<< "#define TVM_EXPORT\n"
<< "#endif\n";
os << "#ifdef __cplusplus\n"
<< "extern \"C\" {\n"
<< "#endif\n";
os << "extern const char " << runtime::symbol::tvm_dev_mblob << "[];\n";
os << "TVM_EXPORT extern const char " << runtime::symbol::tvm_dev_mblob << "[];\n";
uint64_t nbytes = bin.length();
os << "const char " << runtime::symbol::tvm_dev_mblob
<< "[" << bin.length() + sizeof(nbytes) << "] = {\n ";
Expand Down Expand Up @@ -82,7 +87,6 @@ std::string PackImportsToC(const runtime::Module& mod, bool system_lib) {
os << "#ifdef __cplusplus\n"
<< "}\n"
<< "#endif\n";

return os.str();
}
} // namespace codegen
Expand Down
3 changes: 2 additions & 1 deletion src/codegen/llvm/codegen_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ void CodeGenCPU::VisitStmt_(const AttrStmt* op) {

void CodeGenCPU::VisitStmt_(const For* op) {
CHECK(is_zero(op->min));
if (op->for_type == ForType::Serial) {
if (op->for_type == ForType::Serial ||
op->for_type == ForType::Unrolled) {
CodeGenLLVM::VisitStmt_(op);
} else if (op->for_type == ForType::Parallel) {
if (parallel_env_.penv == nullptr) {
Expand Down
7 changes: 6 additions & 1 deletion src/codegen/llvm/codegen_llvm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,12 @@ void CodeGenLLVM::VisitStmt_(const Store* op) {

void CodeGenLLVM::VisitStmt_(const For* op) {
CHECK(is_zero(op->min));
CHECK(op->for_type == ForType::Serial);
if (op->for_type == ForType::Unrolled) {
LOG(WARNING) << "Unroll hint get ignore at CodeGenLLVM backend, "
<< " consider set unroll_explicit=True";
} else {
CHECK(op->for_type == ForType::Serial);
}
CreateSerialFor(MakeValue(op->min), MakeValue(op->extent),
ConstInt32(1), op->loop_var, op->body);
}
Expand Down

0 comments on commit 74b0ca8

Please sign in to comment.