Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CUDA] Fix serial code in kernel #568

Merged
merged 1 commit into from
Nov 9, 2023
Merged
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
15 changes: 11 additions & 4 deletions src/codegen/code_gen_cuda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,20 @@ bool CodeGenCUDA::canRunInKernel(const Stmt &stmt) {
// No VarDef here, because memory are more likely to be wasted
// (allocated in a more conservative way) inside a kernel due to lack of
// synchronization

// TODO: If we are going to implement hybrid CPU-GPU parallelization, we
// also need to reject any OpenMP scope here

return false;
}

for (auto &&_loop : findAllStmt(stmt, "<For>")) {
auto &&loop = _loop.as<ForNode>();
// If some inner loops is already parallelized, we can't safely extend
// the kernel scope, otherwise a barrier at the end of each kernel
// launch is ignored. This branch also reject OpenMP scopes for (maybe
// future) hybrid CPU-GPU parallelization.
if (loop->property_->parallel_ != serialScope) {
return false;
}
}

for (auto &&var : allUses(stmt)) {
auto mtype = buffer(var)->mtype();
if (mtype != MemType::GPULocal && mtype != MemType::GPUWarp &&
Expand Down
Loading