Skip to content

Commit

Permalink
Merge pull request #4 from taichi-dev/master
Browse files Browse the repository at this point in the history
Merge from taichi-dev
  • Loading branch information
archibate authored Feb 17, 2020
2 parents 954a7fe + 62aaaca commit d628cec
Show file tree
Hide file tree
Showing 201 changed files with 2,521 additions and 2,286 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(taichi)

SET(TI_VERSION_MAJOR 0)
SET(TI_VERSION_MINOR 5)
SET(TI_VERSION_PATCH 0)
SET(TI_VERSION_PATCH 1)

execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
Expand Down
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ python3 -m pip install taichi-nightly-cuda-10-0
python3 -m pip install taichi-nightly-cuda-10-1
```

## [Contribution Guidelines](https://taichi.readthedocs.io/en/latest/contributor_guide.html)

|| **Linux (CUDA)** | **OS X (10.14+)** | **Windows** |
|:------|:-----|:-----|:-----|
|**Build**|[![Build Status](http://f11.csail.mit.edu:8080/job/taichi/badge/icon)](http://f11.csail.mit.edu:8080/job/taichi/)| [![Build Status](https://travis-ci.com/taichi-dev/taichi.svg?branch=master)](https://travis-ci.com/taichi-dev/taichi) | [![Build status](https://ci.appveyor.com/api/projects/status/yxm0uniin8xty4j7/branch/master?svg=true)](https://ci.appveyor.com/project/yuanming-hu/taichi/branch/master)|
|**PyPI**|[![Build Status](https://travis-ci.com/yuanming-hu/taichi-wheels-test.svg?branch=master)](https://travis-ci.com/yuanming-hu/taichi-wheels-test)|[![Build Status](https://travis-ci.com/yuanming-hu/taichi-wheels-test.svg?branch=master)](https://travis-ci.com/yuanming-hu/taichi-wheels-test)|[![Build status](https://ci.appveyor.com/api/projects/status/39ar9wa8yd49je7o?svg=true)](https://ci.appveyor.com/project/IteratorAdvance/taichi-wheels-test)|

## [Contribution Guidelines](https://taichi.readthedocs.io/en/latest/contributor_guide.html)

## Related papers
- [**(SIGGRAPH Asia 2019) High-Performance Computation on Sparse Data Structures**](http://taichi.graphics/wp-content/uploads/2019/09/taichi_lang.pdf) [[Video]](https://youtu.be/wKw8LMF3Djo) [[BibTex]](https://raw.githubusercontent.com/yuanming-hu/taichi/master/misc/taichi_bibtex.txt)
- by *Yuanming Hu, Tzu-Mao Li, Luke Anderson, Jonathan Ragan-Kelley, and Frédo Durand*
- [**(ICLR 2020) Differentiable Programming for Physical Simulation**](https://arxiv.org/abs/1910.00935) [[Video]](https://www.youtube.com/watch?v=Z1xvAZve9aE) [[BibTex]](https://raw.githubusercontent.com/yuanming-hu/taichi/master/misc/difftaichi_bibtex.txt) [[Code]](https://github.com/yuanming-hu/difftaichi)
- by *Yuanming Hu, Luke Anderson, Tzu-Mao Li, Qi Sun, Nathan Carr, Jonathan Ragan-Kelley, and Frédo Durand*

<div align="center">
<img width="800px" src="https://github.com/taichi-dev/taichi/blob/master/docs/life_of_kernel_lowres.jpg">
</div>

## Short-term goals
- (Done) Fully implement the LLVM backend to replace the legacy source-to-source C++/CUDA backends (By Dec 2019)
- The only missing features compared to the old source-to-source backends:
Expand All @@ -46,6 +36,14 @@ python3 -m pip install taichi-nightly-cuda-10-1
- (WIP) Tune the performance of the LLVM backend to match that of the legacy source-to-source backends (Hopefully by mid Feb, 2020. Current progress: setting up/tuning for final benchmarks)

## Updates
- (Feb 16, 2020) v0.5.1 released
- Keyboard and mouse events supported in the GUI system. Check out [mpm128.py](https://github.com/taichi-dev/taichi/blob/master/examples/mpm128.py) for a interactive demo! (by **Yubin Peng [archibate] and Ye Kuang [k-ye]**)
- Basic algebraic simplification passes (by **Mingkuan Xu [xumingkuan]**)
- (For developers) `ti` (`ti.exe`) command supported on Windows after setting `%PATH%` correctly (by **Mingkuan Xu [xumingkuan]**)
- General power operator `x ** y` now supported in Taichi kernels (by **Yubin Peng [archibate]**)
- `.dense(...).pointer()` now abbreviated as `.pointer(...)`. `pointer` now stands for a dense pointer array. This leads to cleaner code and better performance. (by **Kenneth Lozes [KLozes]**)
- (Advanced struct-fors only) `for i in X` now iterates all child instances of `X` instead of `X` itself. Skip this if you only use `X=leaf node` such as `ti.f32/i32/Vector/Matrix`.
- Fixed cuda random number generator racing conditions
- (Feb 14, 2020) **v0.5.0 released with a new Apple Metal GPU backend for Mac OS X users!** (by **Ye Kuang [k-ye]**)
- Just initialize your program with `ti.init(..., arch=ti.metal)` and run Taichi on your Mac GPUs!
- A few takeaways if you do want to use the Metal backend:
Expand Down Expand Up @@ -103,3 +101,14 @@ python3 -m pip install taichi-nightly-cuda-10-1
- Doc updated

- [Full changelog](changelog.md)


## Related papers
- [**(SIGGRAPH Asia 2019) High-Performance Computation on Sparse Data Structures**](http://taichi.graphics/wp-content/uploads/2019/09/taichi_lang.pdf) [[Video]](https://youtu.be/wKw8LMF3Djo) [[BibTex]](https://raw.githubusercontent.com/yuanming-hu/taichi/master/misc/taichi_bibtex.txt)
- by *Yuanming Hu, Tzu-Mao Li, Luke Anderson, Jonathan Ragan-Kelley, and Frédo Durand*
- [**(ICLR 2020) Differentiable Programming for Physical Simulation**](https://arxiv.org/abs/1910.00935) [[Video]](https://www.youtube.com/watch?v=Z1xvAZve9aE) [[BibTex]](https://raw.githubusercontent.com/yuanming-hu/taichi/master/misc/difftaichi_bibtex.txt) [[Code]](https://github.com/yuanming-hu/difftaichi)
- by *Yuanming Hu, Luke Anderson, Tzu-Mao Li, Qi Sun, Nathan Carr, Jonathan Ragan-Kelley, and Frédo Durand*

<div align="center">
<img width="800px" src="https://github.com/taichi-dev/taichi/blob/master/docs/life_of_kernel_lowres.jpg">
</div>
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ skip_commits:
- '.*'

build_script:
- set TAICHI_REPO_DIR=C:\taichi
# - 'if %PYTHON% %TAICHI_REPO_DIR%\misc\appveyor_filter.py; then exit 0; fi'
- cd C:\
- curl --retry 10 --retry-delay 5 https://github.com/yuanming-hu/taichi_assets/releases/download/llvm8/taichi-llvm-8.0.1-msvc2017.zip -LO
- 7z x taichi-llvm-8.0.1-msvc2017.zip -otaichi_llvm
- curl --retry 10 --retry-delay 5 https://github.com/yuanming-hu/taichi_assets/releases/download/llvm8/clang-7.0.1-win.zip -LO
- 7z x clang-7.0.1-win.zip -otaichi_clang
- set PATH=C:\taichi_llvm\bin;%PATH%;
- set PATH=C:\taichi_clang\bin;%PATH%
- set TAICHI_REPO_DIR=C:\taichi
- set PYTHONPATH=%TAICHI_REPO_DIR%/python
- set PATH=%TAICHI_REPO_DIR%\bin;%PATH%
- clang --version
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/fill_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def benchmark_nested_struct():

@ti.layout
def place():
ti.root.dense(ti.ij, [N, N]).pointer().dense(ti.ij, [8, 8]).place(a)
ti.root.pointer(ti.ij, [N, N]).dense(ti.ij, [8, 8]).place(a)

@ti.kernel
def fill():
Expand All @@ -24,7 +24,7 @@ def benchmark_nested_struct_fill_and_clear():

@ti.layout
def place():
ti.root.dense(ti.ij, [N, N]).pointer().dense(ti.ij, [8, 8]).place(a)
ti.root.pointer(ti.ij, [N, N]).dense(ti.ij, [8, 8]).place(a)

@ti.kernel
def fill():
Expand Down
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
4 changes: 2 additions & 2 deletions cmake/TaichiCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (TI_WITH_CUDA)
message("Building with CUDA ${CUDA_VERSION}")
set(CUDA_ARCH 61)
message("Found CUDA. Arch = ${CUDA_ARCH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_FOUND -DTI_WITH_CUDA")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_WITH_CUDA")
if (MSVC)
include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include)
target_link_libraries(${LIBRARY_NAME} ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64/cudart.lib ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64/cuda.lib)
Expand Down Expand Up @@ -83,7 +83,7 @@ llvm_map_components_to_libnames(llvm_libs
)
target_link_libraries(${LIBRARY_NAME} ${llvm_libs})

if (CUDA_FOUND)
if (TI_WITH_CUDA)
llvm_map_components_to_libnames(llvm_ptx_libs NVPTX)
target_link_libraries(${LIBRARY_NAME} ${llvm_ptx_libs})
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
2 changes: 1 addition & 1 deletion docs/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
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
Loading

0 comments on commit d628cec

Please sign in to comment.