-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Taichi CMake Overhaul #4832
Comments
Cool! Could you also provide a dependency graph. https://excalidraw.com/ could be your friend (@ailzhang recommended) |
Nice graph! IIUC, |
At the moment yes. Nevertheless,
agree, any suggestions? |
Currently in
|
Would be great to separate out the unified device API! I'd call it |
Discussion: We should later distinguish between public headers vs private headers (currently we don't). I think the recommended way is: For public headers, we always include by its absolute path (which means relative path from Taichi project's root). For private headers, we can go with relative path from it's target's include folder. As long as it's guaranteed by a unique path per header file. |
Agree. It's common that AOT glue codes mistakenly refer to unexported functions leading to linking problems. |
Note that right now also everything is grouped in a two-level namespace: |
Update:
Next steps:
|
Ideally Line 530 in 4bc6f0c
|
@qiao-bo |
OK, that makes it cleaner, thanks for the info. |
Update together with @ailzhang: In addition to taichi/taichi/backends/metal/kernel_utils.h Lines 105 to 156 in 5b890f9
|
FYI @PGZXB #5889 introduced an extra dependency from |
We would like to share our proposal for modernizing Taichi's CMake-based build system. By embracing the target-based approach, we can enforce a good modular design in our code base. This brings us benefits such as reduced (re-)compilation time. By being explicit and untangling the dependencies in current code base, code (target) that do not depend on others can be isolated and built independently (target level parallelism). Changes on one target would not incur the rebuild of others.
This is ongoing work. Previously some efforts have been spent on cleaning up the code base:
Related issues
Proposal
The proposed changes mainly consist of two parts: First, we would like to maintain a list of targets that Taichi uses and being built upon. Each of these targets should have its own
CMakeList.txt
that specifies the build requirements as well as the usage requirements of this target. This may require some shuffling in our code base. Second, replacing many of our current CMake functions that have a global scope with target-based APIs. For example,include_directories
should be replaced withtarget_include_directories
to reduce hidden dependencies on header files to its minimum. Here, we share the outcome of some preliminary discussions:Targets
Current Taichi C++ code base (https://github.com/taichi-dev/taichi/tree/master/taichi) could be split into the following build targets (names TBD):
program
: Core module that calls other targets in order. (https://github.com/taichi-dev/taichi/tree/master/taichi/program)ir
: Include ir, analysis, transform. This may depend ontype
,snode
etc.codegen
: Current location is (https://github.com/taichi-dev/taichi/tree/master/taichi/backends), We can further divide intoLlvmCodegen
andSpirvCodegen
.codegen
should depend onruntime
.runtime
: At the moment shares the same location ascodegen
. Need code shuffling to split out.artifact
: This information is required by bothcodegen
andruntime
. One example in the context of AOT is KernelAttributes:taichi/taichi/backends/metal/kernel_utils.h
Lines 105 to 156 in 5b890f9
As a first step, we can move this information from
codegen
toruntime
such thatruntime
does not depend oncodegen
.common
: Include logging, macro and such things. This target is shared among all targets.type
: Many targets may depend on this.snode
: Ideally we want one snode target that others can depend on. Currently, code are spread in ir, struct etc. We can have an snode builder such that an implemented snode no longer contains its constructor information.gui
: Taichi_core's peripheral targets.python
: Pybind related code.system
: Includesplatform
This dependency graph provides an overview of the mentioned targets:
API Changes
include_directories
->target_include_directories
,link_directories
->target_link_directories
, etc. Targets in sub-directories can be added byadd_subdirectory()
.private
for build requirement andinterface
orpublic
for usage requirements. For example,-Wall
is a build requirement not a usage requirement.target_source
function.taichi/cmake/TaichiCore.cmake
Lines 89 to 103 in 5b890f9
File glob is not recommended in modern CMake. More importantly, avoid using
TI_WITH_XX
to guard the inclusion of source files. This leads to the pollution of manyTI_WITH_XX
in Taichi core target. Such astaichi/taichi/program/program.cpp
Lines 78 to 112 in 91d6f60
Implementation Roadmap
Phase one we would like to divide the current core target, namely
taichi_isolated_core
, into a few major build targets includingprogram
,codegen
,runtime
,ir
,python
.taichi/cmake/TaichiCore.cmake
Lines 244 to 245 in 91d6f60
runtime
from the backends dir. (Defineruntime
targets)codegen
from the backends dir. (Definecodegen
targets)ir
target. Resolve the dependencies onprogram
,backends
etc.Phase two we can further split the shared and peripheral targets from e.g.
program
. This also includesartifact
andsnode
. In addition, we can move header files to a separatetaichi/include
directory. This allows us to distribute libraries with headers.Tasks here will be continuously updated.
The text was updated successfully, but these errors were encountered: