Skip to content

Commit

Permalink
removed common.h/cpp; added compile_config.h/cpp; cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanming-hu committed Feb 28, 2020
1 parent 2291d0e commit 0c3358e
Show file tree
Hide file tree
Showing 31 changed files with 150 additions and 316 deletions.
11 changes: 11 additions & 0 deletions taichi/arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,15 @@ bool arch_use_host_memory(Arch arch) {
return arch_is_cpu(arch);
}

int default_simd_width(Arch arch) {
if (arch == Arch::x64) {
return 8;
} else if (arch == Arch::cuda) {
return 32;
} else {
TI_NOT_IMPLEMENTED;
return -1;
}
}

TLANG_NAMESPACE_END
5 changes: 3 additions & 2 deletions taichi/arch.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include <string>
#include <taichi/common/util.h>
#include <taichi/common.h>
#include "taichi/lang_util.h"

TLANG_NAMESPACE_BEGIN

Expand All @@ -22,4 +21,6 @@ bool arch_is_gpu(Arch arch);

bool arch_use_host_memory(Arch arch);

int default_simd_width(Arch arch);

TLANG_NAMESPACE_END
1 change: 0 additions & 1 deletion taichi/codegen/codegen_llvm_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class CodeGenLLVMCUDA : public CodeGenLLVM {
for (auto &task : offloaded_local) {
task.cuda_func = cuda_module->lookup_function(task.name);
}
auto prog = this->prog;
return [offloaded_local, cuda_module](Context context) {
for (auto task : offloaded_local) {
TI_DEBUG("Launching kernel {}<<<{}, {}>>>", task.name, task.grid_dim,
Expand Down
1 change: 0 additions & 1 deletion taichi/codegen/codegen_metal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <taichi/common.h>
#include <taichi/constants.h>
#include <taichi/platform/metal/metal_data_types.h>
#include <taichi/platform/metal/metal_kernel_util.h>
Expand Down
5 changes: 2 additions & 3 deletions taichi/codegen/codegen_opengl.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include <taichi/common.h>
#include <taichi/constants.h>
#include <taichi/lang_util.h>
#include "taichi/constants.h"
#include "taichi/lang_util.h"

#include <string>
#include <unordered_map>
Expand Down
3 changes: 0 additions & 3 deletions taichi/common.cpp

This file was deleted.

132 changes: 0 additions & 132 deletions taichi/common.h

This file was deleted.

33 changes: 33 additions & 0 deletions taichi/compile_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "taichi/compile_config.h"

TLANG_NAMESPACE_BEGIN

CompileConfig::CompileConfig() {
arch = Arch::x64;
simd_width = default_simd_width(arch);
external_optimization_level = 3;
print_ir = false;
print_accessor_ir = false;
use_llvm = true;
print_struct_llvm_ir = false;
print_kernel_llvm_ir = false;
print_kernel_llvm_ir_optimized = false;
demote_dense_struct_fors = true;
max_vector_width = 8;
debug = false;
lazy_compilation = true;
serial_schedule = false;
simplify_before_lower_access = true;
lower_access = true;
simplify_after_lower_access = true;
default_fp = DataType::f32;
default_ip = DataType::i32;
verbose_kernel_launches = false;
enable_profiler = false;
default_cpu_block_dim = 0; // 0 = adaptive
default_gpu_block_dim = 64;
verbose = true;
fast_math = true;
}

TLANG_NAMESPACE_END
40 changes: 40 additions & 0 deletions taichi/compile_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "taichi/lang_util.h"
#include "taichi/arch.h"

TLANG_NAMESPACE_BEGIN

struct CompileConfig {
Arch arch;
bool debug;
int simd_width;
bool lazy_compilation;
int external_optimization_level;
int max_vector_width;
bool print_ir;
bool print_accessor_ir;
bool serial_schedule;
bool simplify_before_lower_access;
bool lower_access;
bool simplify_after_lower_access;
bool demote_dense_struct_fors;
bool use_llvm;
bool print_struct_llvm_ir;
bool print_kernel_llvm_ir;
bool print_kernel_llvm_ir_optimized;
bool verbose_kernel_launches;
bool enable_profiler;
bool verbose;
bool fast_math;
bool use_unified_memory;
DataType default_fp;
DataType default_ip;
std::string extra_flags;
int default_cpu_block_dim;
int default_gpu_block_dim;

CompileConfig();
};

extern CompileConfig default_compile_config;

TLANG_NAMESPACE_END
1 change: 1 addition & 0 deletions taichi/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
constexpr int taichi_max_num_indices = 8;
constexpr int taichi_max_num_args = 8;
constexpr int taichi_max_num_snodes = 1024;
constexpr int taichi_max_gpu_block_dim = 1024;
constexpr std::size_t taichi_global_tmp_buffer_size = 1024 * 1024;
constexpr int taichi_max_num_mem_requests = 1024 * 64;
constexpr std::size_t taichi_page_size = 4096;
2 changes: 1 addition & 1 deletion taichi/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "constants.h"

#if defined(TI_RUNTIME_HOST)
#include "common.h"
#include "taichi/constants.h"

namespace taichi::Tlang {
using namespace taichi;
Expand Down
4 changes: 2 additions & 2 deletions taichi/extension.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "taichi/arch.h"

#include <string>
#include <taichi/common.h>
#include <taichi/arch.h>

TLANG_NAMESPACE_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion taichi/ir/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ FrontendForStmt::FrontendForStmt(const ExprGroup &loop_var,
if (cfg.arch == Arch::cuda) {
vectorize = 1;
parallelize = 1;
TI_ASSERT(block_dim <= max_gpu_block_dim);
TI_ASSERT(block_dim <= taichi_max_gpu_block_dim);
} else {
// cpu
if (block_dim == 0)
Expand Down
9 changes: 5 additions & 4 deletions taichi/ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include <atomic>
#include <unordered_map>
#include <taichi/common/util.h>
#include <taichi/common/bit.h>
#include "taichi/common/util.h"
#include "taichi/common/bit.h"
#include "taichi/lang_util.h"
#include "snode.h"
#include "expr.h"
#include "taichi/ir/snode.h"
#include "taichi/ir/expr.h"
#include "taichi/compile_config.h"
#include "taichi/llvm/llvm_fwd.h"

TLANG_NAMESPACE_BEGIN
Expand Down
29 changes: 0 additions & 29 deletions taichi/ir/snode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,6 @@ SNode &SNode::create_node(std::vector<Index> indices,
return new_node;
}

void SNode::clear_data() {
if (clear_func == nullptr) {
if (clear_kernel == nullptr) {
clear_kernel = &kernel([&]() {
current_ast_builder().insert(Stmt::make<ClearAllStmt>(this, false));
});
}
(*(Kernel *)clear_kernel)();
} else {
clear_func(0);
}
}

void SNode::clear_data_and_deactivate() {
if (clear_func == nullptr) {
if (clear_and_deactivate_kernel == nullptr) {
clear_and_deactivate_kernel = &kernel([&]() {
current_ast_builder().insert(Stmt::make<ClearAllStmt>(this, true));
});
}
(*(Kernel *)clear_and_deactivate_kernel)();
} else {
clear_func(1);
}
}

void SNode::lazy_grad() {
if (this->type == SNodeType::place)
return;
Expand Down Expand Up @@ -223,8 +197,6 @@ SNode::SNode(int depth, SNodeType t) : depth(depth), type(t) {
num_active_indices = 0;
std::memset(taken_bits, 0, sizeof(taken_bits));
std::memset(physical_index_position, -1, sizeof(physical_index_position));
access_func = nullptr;
stat_func = nullptr;
parent = nullptr;
_verbose = false;
_multi_threaded = false;
Expand All @@ -234,7 +206,6 @@ SNode::SNode(int depth, SNodeType t) : depth(depth), type(t) {
_morton = false;
_bitmasked = false;

clear_func = nullptr;
clear_kernel = nullptr;
clear_and_deactivate_kernel = nullptr;

Expand Down
Loading

0 comments on commit 0c3358e

Please sign in to comment.