Skip to content

Commit

Permalink
Unify all Taichi macros: they should all start with TI_ instead of TC_
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanming-hu committed Feb 16, 2020
1 parent f2792a6 commit 97dbf64
Show file tree
Hide file tree
Showing 182 changed files with 2,087 additions and 2,087 deletions.
2 changes: 1 addition & 1 deletion ci_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_shell_rc_name():

def get_username():
if build_type == 'ci':
os.environ['TC_CI'] = '1'
os.environ['TI_CI'] = '1'
username = 'travis'
else:
assert get_os_name() != 'win'
Expand Down
14 changes: 7 additions & 7 deletions cmake/TaichiCXXFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
message("Using C++ compiler: " ${CMAKE_CXX_COMPILER})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTC_ISE_NONE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_ISE_NONE")

option(BUILD_WITH_ADDRESS_SANITIZER "Build with clang address sanitizer" OFF)

Expand Down Expand Up @@ -49,19 +49,19 @@ if (USE_STDCPP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTC_PASS_EXCEPTION_TO_PYTHON")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_PASS_EXCEPTION_TO_PYTHON")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTC_INCLUDED")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_INCLUDED")

if ($ENV{TC_USE_DOUBLE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTC_USE_DOUBLE")
if ($ENV{TI_USE_DOUBLE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_USE_DOUBLE")
message("Using float64 (double) precision as real")
else()
message("Using float32 (single) precision as real")
endif()

if (TC_USE_MPI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTC_USE_MPI")
if (TI_USE_MPI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_USE_MPI")
message("Using MPI")
endif ()

Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Naming
--------------------------------------------------------------------------
- Variable names should consist of lowercase words connected by underscores, e.g. ``llvm_context``.
- Class and struct names should consist of words with first letters capitalized, e.g. ``CodegenLLVM``.
- Macros should be capital start with ``TC``, such as ``TC_INFO``, ``TC_IMPLEMENTATION``.
- Macros should be capital start with ``TC``, such as ``TI_INFO``, ``TI_IMPLEMENTATION``.

- We do not encourage the use of macro, although there are cases where macros are inevitable.

Expand Down
24 changes: 12 additions & 12 deletions docs/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,45 @@ Serialization

The serialization module of taichi allows you to serialize/deserialize objects into/from binary strings.

You can use ``TC_IO`` macros to explicit define fields necessary in Taichi.
You can use ``TI_IO`` macros to explicit define fields necessary in Taichi.

.. code-block:: cpp
// TC_IO_DEF
// TI_IO_DEF
struct Particle {
Vector3f position, velocity;
real mass;
string name;
TC_IO_DEF(position, velocity, mass, name);
TI_IO_DEF(position, velocity, mass, name);
}
// TC_IO_DECL
// TI_IO_DECL
struct Particle {
Vector3f position, velocity;
real mass;
bool has_name
string name;
TC_IO_DECL() {
TC_IO(position);
TC_IO(velocity);
TC_IO(mass);
TC_IO(has_name);
TI_IO_DECL() {
TI_IO(position);
TI_IO(velocity);
TI_IO(mass);
TI_IO(has_name);
// More flexibility:
if (has_name) {
TC_IO(name);
TI_IO(name);
}
}
}
// TC_IO_DEF_VIRT();
// TI_IO_DEF_VIRT();
Progress Notification
----------------------------------

The taichi messager can send an email to ``$TC_MONITOR_EMAIL`` when the task finished or crashed.
The taichi messager can send an email to ``$TI_MONITOR_EMAIL`` when the task finished or crashed.
To enable:

.. code-block:: python
Expand Down
12 changes: 6 additions & 6 deletions examples/cpp/cnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <taichi/visual/gui.h>
#include <taichi/system/profiler.h>

TC_NAMESPACE_BEGIN
TI_NAMESPACE_BEGIN

using namespace Tlang;

Expand All @@ -12,10 +12,10 @@ constexpr int n = 256;
constexpr int num_ch1 = 16, num_ch2 = 16;

auto cnn = [](std::vector<std::string> cli_param) {
TC_WARN(
TI_WARN(
"After refactoring the Texture class from Taichi is removed. Need to "
"read from the raw bunny binary.");
TC_NOT_IMPLEMENTED
TI_NOT_IMPLEMENTED
#if (0)
CoreState::set_trigger_gdb_when_crash(true);
auto param = parse_param(cli_param);
Expand All @@ -24,7 +24,7 @@ auto cnn = [](std::vector<std::string> cli_param) {
auto cache_l1 = param.get("cache_l1", true);
auto use_dense = param.get("use_dense", false);
auto write_input_voxel = param.get("write_input", true);
TC_P(use_dense);
TI_P(use_dense);

Program prog(gpu ? Arch::gpu : Arch::x86_64);
prog.config.simplify_before_lower_access = opt;
Expand Down Expand Up @@ -228,6 +228,6 @@ auto cnn = [](std::vector<std::string> cli_param) {
#endif
#endif
};
TC_REGISTER_TASK(cnn);
TI_REGISTER_TASK(cnn);

TC_NAMESPACE_END
TI_NAMESPACE_END
34 changes: 17 additions & 17 deletions examples/cpp/diff_conv.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#include <taichi/util.h>

TC_NAMESPACE_BEGIN
TI_NAMESPACE_BEGIN

auto diff_conv = [](const std::vector<std::string> args) {
int grid_resolution = 254;
TC_ASSERT(args.size() == 3);
TI_ASSERT(args.size() == 3);
float th = std::stof(args[2]);
TC_P(th);
TI_P(th);
auto f = fopen(args[0].c_str(), "rb");

int n = pow<3>(grid_resolution);
TC_ASSERT(f);
TI_ASSERT(f);

std::vector<float32> ret1(n);
trash(std::fread(ret1.data(), sizeof(float32), ret1.size(), f));
std::fclose(f);

f = fopen(args[1].c_str(), "rb");
TC_ASSERT(f);
TI_ASSERT(f);
std::vector<float32> ret2(n);
trash(std::fread(ret2.data(), sizeof(float32), ret2.size(), f));
std::fclose(f);
Expand Down Expand Up @@ -53,19 +53,19 @@ auto diff_conv = [](const std::vector<std::string> args) {
// fprintf(stderr, "ret1:%f, ret2:%f\n", ret1[i], ret2[i]);
//}
}
TC_INFO("same {} {}%", counter[0], 100.0f * counter[0] / n);
TC_INFO("non zero same {} {}%", counter[0],
TI_INFO("same {} {}%", counter[0], 100.0f * counter[0] / n);
TI_INFO("non zero same {} {}%", counter[0],
100.0f * counter[1] / total_non_zero);
TC_P(sum1 / n);
TC_P(sum2 / n);
TC_P(sum1 / total_non_zero);
TC_P(sum2 / total_non_zero);
TC_P(max1);
TC_P(max2);
TC_P(non_zero1);
TC_P(non_zero2);
TI_P(sum1 / n);
TI_P(sum2 / n);
TI_P(sum1 / total_non_zero);
TI_P(sum2 / total_non_zero);
TI_P(max1);
TI_P(max2);
TI_P(non_zero1);
TI_P(non_zero2);
};

TC_REGISTER_TASK(diff_conv);
TI_REGISTER_TASK(diff_conv);

TC_NAMESPACE_END
TI_NAMESPACE_END
50 changes: 25 additions & 25 deletions examples/cpp/fem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <taichi/visual/texture.h>
#include <deque>

TC_NAMESPACE_BEGIN
TI_NAMESPACE_BEGIN

#include "fem_coeff.h"

Expand All @@ -30,30 +30,30 @@ auto fem = [](std::vector<std::string> cli_param) {
auto param = parse_param(cli_param);

bool gpu = param.get("gpu", false);
TC_P(gpu);
TI_P(gpu);
bool vectorization = param.get("vec", true);
TC_P(vectorization);
TI_P(vectorization);
int threads = param.get("threads", 8);
TC_P(threads);
TI_P(threads);
bool use_cache = param.get("cache", true);
TC_P(use_cache);
TI_P(use_cache);
bool compute_gt = param.get("compute_gt", false);
TC_P(compute_gt);
TI_P(compute_gt);
Program prog(gpu ? Arch::gpu : Arch::x86_64);
prog.config.simplify_before_lower_access = param.get("simp1", true);
TC_P(prog.config.simplify_before_lower_access);
TI_P(prog.config.simplify_before_lower_access);
prog.config.lower_access = param.get("lower_access", true);
TC_P(prog.config.lower_access);
TI_P(prog.config.lower_access);
prog.config.print_ir = param.get("print_ir", false);
TC_P(prog.config.print_ir);
TI_P(prog.config.print_ir);
prog.config.simplify_after_lower_access = param.get("simp2", true);
TC_P(prog.config.simplify_after_lower_access);
TI_P(prog.config.simplify_after_lower_access);
prog.config.attempt_vectorized_load_cpu = param.get("vec_load_cpu", true);
TC_P(prog.config.attempt_vectorized_load_cpu);
TI_P(prog.config.attempt_vectorized_load_cpu);
bool use_pointer = param.get("use_pointer", true);
TC_P(use_pointer);
TI_P(use_pointer);
bool block_soa = param.get("block_soa", true);
TC_P(block_soa);
TI_P(block_soa);
prog.config.lazy_compilation = false;

Vector x(DataType::f32, dim), r(DataType::f32, dim), p(DataType::f32, dim),
Expand Down Expand Up @@ -261,7 +261,7 @@ auto fem = [](std::vector<std::string> cli_param) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
for (int k = 0; k < n - 1; k++) {
TC_ASSERT(!active[i][j][k]);
TI_ASSERT(!active[i][j][k]);
}
}
}
Expand All @@ -275,16 +275,16 @@ auto fem = [](std::vector<std::string> cli_param) {
auto old_rTr = sum.val<float32>();

for (int i = 0; i < 1000; i++) {
TC_P(i);
TI_P(i);
compute_Ap();
sum.val<float32>() = 0;
reduce_pAp();
auto pAp = sum.val<float32>();
// alpha = rTr / pTAp
alpha.val<float32>() = old_rTr / pAp;
TC_P(old_rTr);
// TC_P(pAp);
// TC_P(alpha.val<float32>());
TI_P(old_rTr);
// TI_P(pAp);
// TI_P(alpha.val<float32>());
// x = x + alpha p
update_x();
// r = r - alpha Ap
Expand All @@ -293,12 +293,12 @@ auto fem = [](std::vector<std::string> cli_param) {
sum.val<float32>() = 0;
reduce_r();
auto new_rTr = sum.val<float32>();
// TC_P(new_rTr);
// TI_P(new_rTr);
if (new_rTr < 1e-5f)
break;
// beta = new rTr / old rTr
beta.val<float32>() = new_rTr / old_rTr;
// TC_P(beta.val<float32>());
// TI_P(beta.val<float32>());
// p = r + beta p
update_p();
old_rTr = new_rTr;
Expand Down Expand Up @@ -326,7 +326,7 @@ auto fem = [](std::vector<std::string> cli_param) {
}
}
}
TC_P(residual);
TI_P(residual);
auto difference = 0.0f;
auto difference_max = 0.0f;
for (int i = 0; i < n; i++) {
Expand All @@ -341,8 +341,8 @@ auto fem = [](std::vector<std::string> cli_param) {
}
}
}
TC_P(difference);
TC_P(difference_max);
TI_P(difference);
TI_P(difference_max);

int gui_res = 512;
GUI gui("FEM", Vector2i(gui_res + 200, gui_res), false);
Expand Down Expand Up @@ -371,6 +371,6 @@ auto fem = [](std::vector<std::string> cli_param) {
gui.update();
}
};
TC_REGISTER_TASK(fem);
TI_REGISTER_TASK(fem);

TC_NAMESPACE_END
TI_NAMESPACE_END
Loading

0 comments on commit 97dbf64

Please sign in to comment.