Skip to content

Commit

Permalink
[CINN] Fix compile bug in cuda 12.3 (PaddlePaddle#64832)
Browse files Browse the repository at this point in the history
* fix compile bug in cuda 12.3

* refine
  • Loading branch information
chen2016013 authored Jun 4, 2024
1 parent 09ce1b8 commit d15b227
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion paddle/cinn/backends/codegen_device_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ std::string Predicate2String(ir::Expr predicate) {
return ss.str();
}

static std::string CurTailFnName(const std::string &origin_fn_name) {
const int MaxStrLength = 16383;
if (origin_fn_name.length() <= MaxStrLength) {
return origin_fn_name;
}
VLOG(6) << "Funtion name too long. Curtail and concat hash.";
const std::string new_fn_name =
origin_fn_name.substr(0, MaxStrLength) +
std::to_string(std::hash<std::string>()(origin_fn_name));
return new_fn_name;
}

std::string
detail::CollectBucketStrategyHostFunctionVisitor::GenDeviceKernelName(
const std::string &fn_name, ir::Expr predicate) {
Expand All @@ -80,7 +92,10 @@ detail::CollectBucketStrategyHostFunctionVisitor::GenDeviceKernelName(
pos = cond_str.find("-", pos + replacement.length());
}
VLOG(3) << "predicate string: " << cond_str;
return fn_name + "__COND_" + cond_str + "__kernel";
// NOTE(chenxi67): The kernel name is too long to be supported in cuda12.3 so
// we need to curtail it.
const std::string new_fn_name = CurTailFnName(fn_name);
return new_fn_name + "__COND_" + cond_str + "__kernel";
}

void detail::CollectBucketStrategyHostFunctionVisitor::ProcessLoweredFunc(
Expand Down

0 comments on commit d15b227

Please sign in to comment.