-
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
A refactoring plan #518
Comments
Thanks for proposing these changes!
That's a good point. I think the whole
I know this function looks messy. However, its presence deletes a bunch of huge CUDA runtime functions, immediately after
I removed the legacy CUDA source backend a few hours ago :-) |
Meanwhile, I'm also actively working on removing the dependency on CUDA unified memory to make way for AMDGPU backend. |
I think even with "remove_useless_libdevice_functions" there are many useless functions in libdevice that will become part of the final module. I implemented libdevice linking in TVM, and I remember using |
Yeah, ultimately all the unused nv intrinsics will be eliminated during the PTX emission process. I deleted the huge libdevice functions just to accelerate this single linking step (which is even before we can analyze which nv intrinsics are used): taichi/taichi/taichi_llvm_context.cpp Line 344 in 794e923
I could be wrong though, and I'm definitely open to any better designs :-) |
do we still need this function now that legacy codegen is removed? Or is it used for compiling |
No, it's no longer used. I considered removing this, however, there is still a chance that we need a C backend in the future... |
we can at least remove nvcc bits. |
Yeah, I agree. I think the above discussions are all centered around a question: Does "demonstrating how a source2source compiler should be implemented in the future" justify the existence of certain legacy code? |
I think such legacy code can exist but should be separated from the rest of the code that is actually used. Current codebase has both legacy and current code and for newcomers it is not clear which is which. |
Yeah, that sounds like a good solution. How about just moving these to I agree that having legacy code can be very confusing. |
|
Yeah, that's just for holding nonessential random and experimental files. Thanks for the inputs. I'll gradually move the legacy code there for code clarity :-) |
regarding libdevice linking, is it possible to ship custom libdevice.bc in the taichi repo? It seems Halide does this https://github.com/halide/Halide/tree/master/src/runtime/nvidia_libdevice_bitcode. I'm not sure if there is a license or other issues. It will also enable removing libdevice.bc path finding. |
Yeah, that sounds good! I think now we ship two bc files (runtime_cuda.bc and libdevice.bc), and they should be merged with the huge nv intrinsics removed. Not sure about licenses though. I can confirm with the Halide people (e.g. Andrew Adams) to learn about what he thinks about the libdevice license issues. |
@masahi I've done several rounds of aggressive refactorings to improve code readability/maintainability. Most improvements are not actually listed in this list. Now I'll first rip off unified memory dependency and then come back to the remaining refactoring items in your list. Please feel free to propose new refactoring opportunities in the new codebase! (@k-ye @archibate my apologies in advance if I have broken any code of you guys...) |
@yuanming-hu thanks, I also want to start contributing code changes, the only problem being finding time to work on it. |
See the comment below for the context.
#412 (comment)
Starting from the easy ones, I'll add more items as I learn more about the codebase. Feel free to add what you find as well.
SNodeAllocator
in struct.h as it is not used anywhereremove_useless_libdevice_functions(...)
in taichi_llvm_context.cppKernelCodeGen::codegen()
CodeGenBase
is the base class ofStructCompiler
andKernelCodeGen
, but it doesn't seem useful. Consider restructuring the class hierarchy or just remove itcuda_context
stuff fromProgram
https://github.com/taichi-dev/taichi/blob/master/taichi/program.cpp#L36-L43cuda_context
global var (also marked as "TODO")https://github.com/taichi-dev/taichi/blob/master/taichi/backends/llvm_jit_ptx.cpp#L24
https://github.com/taichi-dev/taichi/blob/master/taichi/backends/cuda_context.h#L72
compile_module_to_ptx
fromllvm_jit_ptx.cpp
tocodegen_llvm_ptx.cpp
. Rename the rest ofllvm_jit_ptx.cpp
tocuda_context.cpp
LoopGenerator
is not used and it generates c or cuda source, so probably this is legacy code. Alsoloopgen
inStructCompiler
can be removed. https://github.com/taichi-dev/taichi/blob/master/taichi/backends/struct.h#L18generate_types
andgenerate_leaf_accessors
fromStructCompiler
https://github.com/taichi-dev/taichi/blob/master/taichi/backends/struct.cpp#L122-L130pointer_activate
etc intoPointer_activate
Stmt::adjoint
andStmt::value
.std::unique_ptr
instead ofstd::shared_ptr
in SNode for clear children ownership.The text was updated successfully, but these errors were encountered: