Skip to content
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

[misc] Add auto-profiling to IR passes #1255

Merged
merged 2 commits into from
Jun 16, 2020
Merged

Conversation

xumingkuan
Copy link
Contributor

@xumingkuan xumingkuan commented Jun 16, 2020

Related issue = #926

Usage: ti.core.print_profile_info()

Example:
taichi_elements/demo_2d.py

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[Profiler thread 5444]
      1.674  s taichi::lang::TaichiLLVMContext::clone_runtime_module [1 x   1.674  s]
          1.581  s 94.43%  taichi::lang::compile_runtime_bitcode [1 x   1.581  s]
          0.033  s  1.95%  taichi::lang::module_from_bitcode_file [1 x  32.674 ms]
          0.060  s  3.60%  clone module          [1 x  60.314 ms]
    605.888 ms taichi::lang::StructCompilerLLVM::run [1 x 605.888 ms]
          0.217 ms  0.04%  taichi::lang::StructCompilerLLVM::generate_types [33 x   6.576 us]
          0.458 ms  0.08%  taichi::lang::StructCompilerLLVM::generate_child_accessors [1 x 458.000 us]
             71.000 us 15.50%  taichi::lang::StructCompilerLLVM::generate_refine_coordinates [1 x  71.000 us]
            384.000 us 83.84%  taichi::lang::StructCompilerLLVM::generate_child_accessors [7 x  54.857 us]
                192.000 us 50.00%  taichi::lang::StructCompilerLLVM::generate_refine_coordinates [7 x  27.429 us]
                139.000 us 36.20%  taichi::lang::StructCompilerLLVM::generate_child_accessors [25 x   5.560 us]
                 53.000 us 13.80%  [unaccounted]
              3.000 us  0.66%  [unaccounted]
         13.805 ms  2.28%  taichi::lang::TaichiLLVMContext::clone_struct_module [1 x  13.805 ms]
          2.006 ms  0.33%  taichi::lang::TaichiLLVMContext::eliminate_unused_functions [1 x   2.006 ms]
        414.628 ms 68.43%  taichi::lang::JITSessionCPU::global_optimize_module_cpu [1 x 414.628 ms]
             10.094 ms  2.43%  llvm_function_pass    [1 x  10.094 ms]
            398.991 ms 96.23%  llvm_module_pass      [1 x 398.991 ms]
              5.543 ms  1.34%  [unaccounted]
        174.774 ms 28.85%  [unaccounted]
      4.163  s taichi::lang::Program::compile [19 x 219.123 ms]
          1.498  s 35.98%  taichi::lang::irpass::compile_to_offloads [19 x  78.841 ms]
              0.101  s  6.72%  taichi::lang::irpass::lower [19 x   5.300 ms]
              0.022  s  1.45%  taichi::lang::irpass::typecheck [76 x 285.053 us]
              0.028  s  1.89%  taichi::lang::irpass::analysis::verify [304 x  93.352 us]
              0.000  s  0.00%  taichi::lang::irpass::loop_vectorize [19 x   3.421 us]
              0.000  s  0.00%  taichi::lang::irpass::vector_split [19 x   2.421 us]
              0.312  s 20.84%  taichi::lang::irpass::simplify [19 x  16.434 ms]
                  0.807 ms  0.26%  taichi::lang::irpass::typecheck [84 x   9.607 us]
                311.438 ms 99.74%  [unaccounted]
              0.342  s 22.80%  taichi::lang::irpass::variable_optimization [38 x   8.989 ms]
              0.000  s  0.03%  taichi::lang::irpass::flag_access [57 x   7.807 us]
              0.650  s 43.41%  taichi::lang::irpass::full_simplify [38 x  17.113 ms]
                  2.777 ms  0.43%  taichi::lang::irpass::extract_constant [79 x  35.152 us]
                  1.253 ms  0.19%  taichi::lang::irpass::binary_op_simplify [79 x  15.861 us]
                 61.359 ms  9.44%  taichi::lang::irpass::constant_fold [79 x 776.696 us]
                     56.805 ms 92.58%  taichi::lang::Program::compile [2 x  28.403 ms]
                          0.295 ms  0.52%  taichi::lang::irpass::compile_to_offloads [2 x 147.500 us]
                             11.000 us  3.73%  taichi::lang::irpass::lower [2 x   5.500 us]
                             10.000 us  3.39%  taichi::lang::irpass::typecheck [2 x   5.000 us]
                             21.000 us  7.12%  taichi::lang::irpass::analysis::verify [4 x   5.250 us]
                            245.000 us 83.05%  taichi::lang::irpass::offload [2 x 122.500 us]
                                 13.000 us  5.31%  taichi::lang::irpass::typecheck [4 x   3.250 us]
                                232.000 us 94.69%  [unaccounted]
                              8.000 us  2.71%  [unaccounted]
                         56.487 ms 99.44%  taichi::lang::KernelCodeGen::compile [2 x  28.244 ms]
                             56.483 ms 99.99%  taichi::lang::CodeGenCPU::codegen [2 x  28.242 ms]
                                 26.030 ms 46.08%  taichi::lang::TaichiLLVMContext::clone_struct_module [2 x  13.015 ms]
                                  0.004 ms  0.01%  taichi::lang::CodeGenLLVMCPU::CodeGenLLVMCPU [2 x   2.000 us]
                                  0.165 ms  0.29%  taichi::lang::CodeGenLLVM::emit_to_module [2 x  82.500 us]
                                 30.249 ms 53.55%  taichi::lang::CodeGenLLVM::compile_module_to_executable [2 x  15.125 ms]
                                      3.346 ms 11.06%  taichi::lang::TaichiLLVMContext::eliminate_unused_functions [2 x   1.673 ms]
                                     21.673 ms 71.65%  taichi::lang::JITSessionCPU::global_optimize_module_cpu [2 x  10.837 ms]
                                          4.268 ms 19.69%  llvm_function_pass    [2 x   2.134 ms]
                                         11.527 ms 53.19%  llvm_module_pass      [2 x   5.764 ms]
                                          5.878 ms 27.12%  [unaccounted]
                                      5.230 ms 17.29%  [unaccounted]
                      4.554 ms  7.42%  [unaccounted]
                  2.298 ms  0.35%  taichi::lang::irpass::alg_simp [79 x  29.089 us]
                 29.233 ms  4.50%  taichi::lang::irpass::die [237 x 123.346 us]
                462.993 ms 71.20%  taichi::lang::irpass::whole_kernel_cse [79 x   5.861 ms]
                 89.967 ms 13.83%  taichi::lang::irpass::simplify [79 x   1.139 ms]
                     16.684 ms 18.54%  taichi::lang::irpass::typecheck [74 x 225.459 us]
                     73.283 ms 81.46%  [unaccounted]
              0.020  s  1.31%  taichi::lang::irpass::offload [19 x   1.030 ms]
                  5.742 ms 29.33%  taichi::lang::irpass::typecheck [38 x 151.105 us]
                 13.836 ms 70.67%  [unaccounted]
              0.005  s  0.34%  taichi::lang::irpass::die [19 x 269.053 us]
              0.007  s  0.46%  taichi::lang::irpass::demote_atomics [19 x 362.789 us]
                  3.390 ms 49.18%  taichi::lang::irpass::typecheck [19 x 178.421 us]
                  3.503 ms 50.82%  [unaccounted]
              0.000  s  0.03%  taichi::lang::irpass::cfg_optimization [19 x  23.421 us]
              0.011  s  0.70%  [unaccounted]
          2.665  s 64.01%  taichi::lang::KernelCodeGen::compile [19 x 140.262 ms]
              2.665  s 100.00%  taichi::lang::CodeGenCPU::codegen [19 x 140.260 ms]
                  0.291  s 10.90%  taichi::lang::TaichiLLVMContext::clone_struct_module [19 x  15.293 ms]
                  0.000  s  0.00%  taichi::lang::CodeGenLLVMCPU::CodeGenLLVMCPU [19 x   1.368 us]
                  0.007  s  0.28%  taichi::lang::CodeGenLLVM::emit_to_module [19 x 387.789 us]
                  2.367  s 88.80%  taichi::lang::CodeGenLLVM::compile_module_to_executable [19 x 124.553 ms]
                      0.037  s  1.58%  taichi::lang::TaichiLLVMContext::eliminate_unused_functions [19 x   1.970 ms]
                      1.929  s 81.51%  taichi::lang::JITSessionCPU::global_optimize_module_cpu [19 x 101.523 ms]
                          0.093  s  4.82%  llvm_function_pass    [19 x   4.896 ms]
                          1.777  s 92.13%  llvm_module_pass      [19 x  93.535 ms]
                          0.059  s  3.05%  [unaccounted]
                      0.400  s 16.91%  [unaccounted]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[Click here for the format server]


Comment on lines -97 to -99
irpass::constant_fold(ir);
print("Constant folded");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this cause it's already done in Simplified II?

Copy link
Contributor Author

@xumingkuan xumingkuan Jun 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. (Removing to avoid printing a line 0.000 s 0.00% taichi::lang::irpass::constant_fold under the tab taichi::lang::irpass::compile_to_offloads.)

@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #1255 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1255   +/-   ##
=======================================
  Coverage   84.78%   84.78%           
=======================================
  Files          18       18           
  Lines        3267     3267           
  Branches      613      613           
=======================================
  Hits         2770     2770           
  Misses        360      360           
  Partials      137      137           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1448ca9...3c509a8. Read the comment docs.

@xumingkuan xumingkuan requested a review from TH3CHARLie June 16, 2020 03:07
@xumingkuan xumingkuan merged commit 035bcb9 into taichi-dev:master Jun 16, 2020
@FantasyVR FantasyVR mentioned this pull request Jun 17, 2020
@xumingkuan xumingkuan deleted the prof branch June 17, 2020 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants