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

[misc] Add "make_block_local" option to "CompileConfig" #1727

Merged
merged 5 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion taichi/program/async_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ void ExecutionQueue::enqueue(KernelLaunchRecord &&ker) {
/*lower_global_access=*/true,
/*make_thread_local=*/true,
/*make_block_local=*/
is_extension_supported(config.arch, Extension::bls));
is_extension_supported(config.arch, Extension::bls) &&
config.make_block_local);
}
auto codegen = KernelCodeGen::create(kernel->arch, kernel, stmt);
auto func = codegen->codegen();
Expand Down
1 change: 1 addition & 0 deletions taichi/program/compile_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CompileConfig::CompileConfig() {
async_mode = false;
flatten_if = false;
make_thread_local = true;
make_block_local = true;

saturating_grid_dim = 0;
max_block_dim = 0;
Expand Down
1 change: 1 addition & 0 deletions taichi/program/compile_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct CompileConfig {
bool async_mode;
bool flatten_if;
bool make_thread_local;
bool make_block_local;
DataType default_fp;
DataType default_ip;
std::string extra_flags;
Expand Down
6 changes: 5 additions & 1 deletion taichi/program/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "taichi/backends/cuda/cuda_driver.h"
#include "taichi/ir/transforms.h"
#include "taichi/util/action_recorder.h"
#include "taichi/program/extension.h"

TLANG_NAMESPACE_BEGIN

Expand Down Expand Up @@ -81,7 +82,10 @@ void Kernel::lower(bool to_executable) { // TODO: is a "Lowerer" class
irpass::compile_to_executable(
ir.get(), config, /*vectorize*/ arch_is_cpu(arch), grad,
/*ad_use_stack*/ true, verbose, /*lower_global_access*/ to_executable,
/*make_thread_local*/ true, /*make_block_local*/ arch == Arch::cuda);
/*make_thread_local*/ config.make_thread_local,
/*make_block_local*/
is_extension_supported(config.arch, Extension::bls) &&
config.make_block_local);
} else {
irpass::compile_to_offloads(ir.get(), config, verbose,
/*vectorize=*/arch_is_cpu(arch), grad,
Expand Down
1 change: 1 addition & 0 deletions taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void export_lang(py::module &m) {
.def_readwrite("async_mode", &CompileConfig::async_mode)
.def_readwrite("flatten_if", &CompileConfig::flatten_if)
.def_readwrite("make_thread_local", &CompileConfig::make_thread_local)
.def_readwrite("make_block_local", &CompileConfig::make_block_local)
.def_readwrite("cc_compile_cmd", &CompileConfig::cc_compile_cmd)
.def_readwrite("cc_link_cmd", &CompileConfig::cc_link_cmd);

Expand Down
8 changes: 4 additions & 4 deletions taichi/transforms/constant_fold.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "taichi/ir/ir.h"
#include "taichi/ir/transforms.h"
#include "taichi/ir/visitors.h"
#include "taichi/program/program.h"
#include <deque>
#include <set>
#include <cmath>
#include <thread>

#include "taichi/ir/ir.h"
#include "taichi/ir/transforms.h"
#include "taichi/ir/visitors.h"
#include "taichi/program/program.h"
#include "taichi/ir/ir.h"
#include "taichi/program/program.h"
#include "taichi/ir/snode.h"
Expand Down
26 changes: 1 addition & 25 deletions taichi/transforms/insert_scratch_pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

TLANG_NAMESPACE_BEGIN

// Figure out accessed snodes, and their ranges in this for stmt
// Figure out accessed SNodes, and their ranges in this for stmt
class AccessAnalysis : public BasicStmtVisitor {
using BasicStmtVisitor::visit;

Expand Down Expand Up @@ -59,14 +59,6 @@ class AccessAnalysis : public BasicStmtVisitor {
auto ptr = stmt->as<GlobalPtrStmt>();
for (int l = 0; l < stmt->width(); l++) {
auto snode = ptr->snodes[l];
// std::vector<SNode *> snodes;
/*
for (auto it: pads->pads) {
//snodes.push_back(it.first);
TI_P(it.first->node_type_name);
}
TI_P(snode->node_type_name);
*/
if (!pads->has(snode)) {
continue;
}
Expand All @@ -80,27 +72,11 @@ class AccessAnalysis : public BasicStmtVisitor {
if (diff.linear_related()) {
offsets[i].first = diff.low;
offsets[i].second = diff.high;
/*
TI_P(ptr->name());
TI_P(diff.low);
TI_P(diff.high);
*/
} else {
/*
TI_P(i);
TI_P(for_stmt->loop_vars[i]->raw_name());
TI_P(ptr->indices[i]->raw_name());
*/
matching_indices = false;
}
}
if (matching_indices) {
/*
TI_INFO("Detected regular access");
for (int i = 0; i < num_indices; i++) {
TI_P(offsets[i]);
}
*/
for (const auto &bind : block_indices) {
std::function<void(std::vector<int>, int)> visit =
[&](std::vector<int> ind, int depth) {
Expand Down