taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.49k stars 2.28k forks source link

[Bug] [win] kernel_profiler output incorrect on Windows #1881

Open archibate opened 4 years ago

archibate commented 4 years ago

Describe the bug kernel_profiler is yielding very werid result on Windows, but I can't reproduce the same on Linux.

To Reproduce


import taichi as ti

ti.init(kernel_profiler=True)

@ti.kernel
def func():
    print(42)

func()
ti.kernel_profiler_print()

Log/Screenshots Please post the full log of the program (instead of just a few lines around the error message, unless the log is > 1000 lines). This will help us diagnose what's happening. For example:

PS F:\Documents\toyc>  cd 'f:\Documents\toyc'; & 'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe' 'c:\Users\Administrator\.vscode\extensions\ms-python.python-2020.8.109390\pythonFiles\lib\python\debugpy\launcher' '11273' '--' 'f:\Documents\test_profiler.py' 
[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5
[Taichi] Starting on arch=x64
[Taichi] materializing...
0
x64 Profiler
=========================================================================
[      %     total   count |      min       avg       max   ] Kernel name
[100.00%   0.000 s      1x |    0.440     0.440     0.440 ms] func_c4_0_kernel_0_range_for
-------------------------------------------------------------------------
[100.00%] Total kernel execution time:   0.000 s   number of records: 1
=========================================================================

Additional comments

PS F:\Documents\toyc> ti diagnose
[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5

*******************************************
**      Taichi Programming Language      **
*******************************************

Docs:   https://taichi.rtfd.io/zh_CN/latest
GitHub: https://github.com/taichi-dev/taichi
Forum:  https://forum.taichi.graphics

Taichi system diagnose:

python: 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
system: win32
executable: c:\users\administrator\appdata\local\programs\python\python38\python.exe
platform: Windows-10-10.0.19041-SP0
architecture: 64bit WindowsPE
`uname` not available: [WinError 2] 系统找不到指定的文件。

locale: zh_CN.cp936
PATH: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;F:\Git\cmd;C:\Users\Administrator\AppData\Local\Programs\Python\Python38;C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files\nodejs\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk-11.0.2\bin;;F:\Program Files\Microsoft VS Code\bin;C:\Users\Administrator\AppData\Roaming\npm;F:\Program Files (x86)\GitHub CLI\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Lib\site-packages\taichi\core\../lib

`lsb_release` not available: [WinError 2] 系统找不到指定的文件。
TAICHI_REPO_DIR=

import: ERROR list index out of range

cc: ERROR list index out of range
cpu: ERROR list index out of range
metal: ERROR list index out of range
opengl: ERROR list index out of range
cuda: ERROR list index out of range

`glewinfo` not available: [WinError 2] 系统找不到指定的文件。

`nvidia-smi` not available: [WinError 2] 系统找不到指定的文件。
[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5

[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5
[Taichi] Starting on arch=x64

[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5
[Taichi] Starting on arch=opengl

[W 09/19/20 23:45:56.448] [__init__.py:adaptive_arch_select@565] Arch=[Arch.cuda] is not supported, falling back to CPU
[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5
[Taichi] Starting on arch=x64

[Taichi] mode=release
[Taichi] version 0.6.34, llvm 10.0.0, commit cbbef943, win, python 3.8.5

*******************************************
**      Taichi Programming Language      **
*******************************************

Docs:   https://taichi.rtfd.io/zh_CN/latest
GitHub: https://github.com/taichi-dev/taichi
Forum:  https://forum.taichi.graphics

Running example minimal ...
[Taichi] Starting on arch=x64
[Taichi] materializing...
>>> Running time: 0.49s
42

Consider attaching this log when maintainers ask about system information.
>>> Running time: 6.80s
PS F:\Documents\toyc> 
xumingkuan commented 4 years ago

Thanks for reporting this, but I can't reproduce it on my end:

(base) C:\Users\xmk\Desktop\python_test>python test2.py
[Taichi] mode=development
[Taichi] <dev mode>, llvm 10.0.0, commit f2a798d1, win, python 3.7.4
[W 09/20/20 15:59:48.381] [shell.py:<module>@7] `sourceinspect` not installed!
[W 09/20/20 15:59:48.382] [shell.py:<module>@9] Without this package Taichi may not function well in Python IDLE interactive shell, Blender scripting module and Python native shell.
[W 09/20/20 15:59:48.383] [shell.py:<module>@11] Please run `python3 -m pip install sourceinspect` to install.
[I 09/20/20 15:59:48.384] [shell.py:_shell_pop_print@30] Graphical python shell detected, using wrapped sys.stdout
[Taichi] Starting on arch=x64
[T 09/20/20 15:59:48.814] [program.cpp:taichi::lang::Program::Program@64] Program initializing...
[T 09/20/20 15:59:48.814] [memory_pool.cpp:taichi::lang::MemoryPool::MemoryPool@10] Memory pool created. Default buffer size per allocator = 1024 MB
[T 09/20/20 15:59:48.815] [llvm_context.cpp:taichi::lang::TaichiLLVMContext::TaichiLLVMContext@60] Creating Taichi llvm context for arch: x64
[T 09/20/20 15:59:48.815] [llvm_context.cpp:taichi::lang::TaichiLLVMContext::get_this_thread_data@727] Creating thread local data for thread 12556
[T 09/20/20 15:59:48.817] [llvm_context.cpp:taichi::lang::TaichiLLVMContext::TaichiLLVMContext@85] Taichi llvm context created.
[T 09/20/20 15:59:48.818] [program.cpp:taichi::lang::Program::Program@192] Program (0x151b4c0f080) arch=x64 initialized.
[Taichi] materializing...
[T 09/20/20 15:59:48.821] [impl.py:materialize@226] Materializing layout...
[T 09/20/20 15:59:49.767] [llvm_context.cpp:taichi::lang::compile_runtime_bitcode@184] Compiling runtime module bitcode...
[T 09/20/20 15:59:55.342] [llvm_context.cpp:taichi::lang::compile_runtime_bitcode@200] Runtime module bitcode compiled.
[T 09/20/20 15:59:55.639] [unified_allocator.cpp:taichi::lang::UnifiedAllocator::UnifiedAllocator@53] Allocating virtual address space of size 1024 MB
[T 09/20/20 15:59:55.639] [unified_allocator.cpp:taichi::lang::UnifiedAllocator::UnifiedAllocator@62] Memory allocated. Allocation time = 0.000448 s
[T 09/20/20 15:59:55.640] [program.cpp:taichi::lang::Program::initialize_runtime_system@281] Allocating data structure of size 0 B
[T 09/20/20 15:59:55.640] [program.cpp:taichi::lang::Program::initialize_runtime_system@282] Allocating 0 random states (used by CUDA only)
[T 09/20/20 15:59:55.734] [program.cpp:taichi::lang::Program::initialize_runtime_system@291] LLVMRuntime initialized
[T 09/20/20 15:59:55.734] [program.cpp:taichi::lang::Program::initialize_runtime_system@293] LLVMRuntime pointer fetched
[D 09/20/20 15:59:55.736] [memory_pool.cpp:taichi::lang::MemoryPool::daemon@102] Processing memory alloc request 0
[D 09/20/20 15:59:55.737] [memory_pool.cpp:taichi::lang::MemoryPool::daemon@109]   Allocating memory 8232 B (alignment 4096B) 
[D 09/20/20 15:59:55.738] [memory_pool.cpp:taichi::lang::MemoryPool::daemon@111]   Allocated. Ptr = 0x151b6548000
[D 09/20/20 15:59:55.740] [memory_pool.cpp:taichi::lang::MemoryPool::daemon@102] Processing memory alloc request 1
[D 09/20/20 15:59:55.741] [memory_pool.cpp:taichi::lang::MemoryPool::daemon@109]   Allocating memory 3145728 B (alignment 4096B) 
[D 09/20/20 15:59:55.741] [memory_pool.cpp:taichi::lang::MemoryPool::daemon@111]   Allocated. Ptr = 0x151b654b000
[T 09/20/20 15:59:55.741] [program.cpp:taichi::lang::Program::materialize_layout@363] materialize_layout called
[T 09/20/20 15:59:55.744] [kernel.py:materialize@311] Compiling kernel func_c4_0...
[T 09/20/20 15:59:55.774] [codegen_llvm.cpp:taichi::lang::CodeGenLLVM::compile_module_to_executable::<lambda_2fba9f90b5a54f3520e06143b19b5106>::operator ()@1626] Launching kernel func_c4_0_kernel
42
x64 Profiler
=========================================================================
[      %     total   count |      min       avg       max   ] Kernel name
[100.00%   0.000 s      1x |    0.301     0.301     0.301 ms] func_c4_0_kernel_0_serial
-------------------------------------------------------------------------
[100.00%] Total kernel execution time:   0.000 s   number of records: 1
=========================================================================
[T 09/20/20 15:59:55.799] [program.cpp:taichi::lang::Program::finalize@665] Program finalizing...
[T 09/20/20 15:59:55.876] [program.cpp:taichi::lang::Program::finalize@710] Program (0x151b4c0f080) finalized.

(base) C:\Users\xmk\Desktop\python_test>