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

[async] Support constant folding in async mode #1778

Merged
merged 4 commits into from
Aug 26, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
finalize
  • Loading branch information
yuanming-hu committed Aug 26, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2bd534a58aae05c3812cc33d7e4dd4305e99fd18
2 changes: 1 addition & 1 deletion taichi/program/async_engine.cpp
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ void ExecutionQueue::enqueue(KernelLaunchRecord &&ker) {
auto config = kernel->program.config;
auto ir = stmt;
offload_to_executable(
ir, config, /*verbose=*/config.print_ir,
ir, config, /*verbose=*/false,
/*lower_global_access=*/true,
/*make_thread_local=*/true,
/*make_block_local=*/
2 changes: 1 addition & 1 deletion taichi/program/program.cpp
Original file line number Diff line number Diff line change
@@ -630,7 +630,7 @@ Kernel &Program::get_snode_writer(SNode *snode) {
}

uint64 Program::fetch_result_uint64(int i) {
// Precondition: caller must have already done a program synchronization.
device_synchronize();
uint64 ret;
auto arch = config.arch;
if (arch == Arch::cuda) {
3 changes: 2 additions & 1 deletion taichi/program/program.h
Original file line number Diff line number Diff line change
@@ -135,9 +135,11 @@ class Program {
context.runtime = (LLVMRuntime *)llvm_runtime;
return context;
}

void initialize_device_llvm_context();

void synchronize();

void device_synchronize();

void layout(std::function<void()> func) {
@@ -258,7 +260,6 @@ class Program {
auto runtime = tlctx->runtime_jit_module;
runtime->call<void *, Args...>("runtime_" + key, llvm_runtime,
std::forward<Args>(args)...);
device_synchronize();
return fetch_result<T>(taichi_result_buffer_runtime_query_id);
}

6 changes: 0 additions & 6 deletions taichi/transforms/constant_fold.cpp
Original file line number Diff line number Diff line change
@@ -121,9 +121,6 @@ class ConstantFold : public BasicStmtVisitor {
launch_ctx.set_arg_raw(0, lhs.val_u64);
launch_ctx.set_arg_raw(1, rhs.val_u64);
(*ker)(launch_ctx);
// Constant folding kernel is always run in sync mode, therefore we call
// device_synchronize().
current_program.device_synchronize();
ret.val_i64 = current_program.fetch_result<int64_t>(0);
return true;
}
@@ -146,9 +143,6 @@ class ConstantFold : public BasicStmtVisitor {
auto launch_ctx = ker->make_launch_context();
launch_ctx.set_arg_raw(0, operand.val_u64);
(*ker)(launch_ctx);
// Constant folding kernel is always run in sync mode, therefore we call
// device_synchronize().
current_program.device_synchronize();
ret.val_i64 = current_program.fetch_result<int64_t>(0);
return true;
}
2 changes: 1 addition & 1 deletion tests/python/test_constant_fold.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import taichi as ti


@ti.test(arch=ti.cpu, async_mode=True)
@ti.test(require=ti.extension.async_mode, async_mode=True)
def test_constant_fold():
n = 100

23 changes: 0 additions & 23 deletions tmp.py

This file was deleted.