mirror of https://github.com/Jittor/Jittor
add progress for core compiling
This commit is contained in:
parent
f1a40bc826
commit
3989c7f19a
|
@ -77,7 +77,7 @@ def compile(compiler, flags, inputs, output, combind_build=False):
|
||||||
cc = nvcc_path
|
cc = nvcc_path
|
||||||
cmd = f"{cc} {input} {nflags} -c {lto_flags} -o {obj_file}"
|
cmd = f"{cc} {input} {nflags} -c {lto_flags} -o {obj_file}"
|
||||||
cmds.append(cmd)
|
cmds.append(cmd)
|
||||||
jit_utils.run_cmds(cmds, cache_path, jittor_path)
|
jit_utils.run_cmds(cmds, cache_path, jittor_path, "compiling")
|
||||||
cmd = f"{compiler} {' '.join(obj_files)} {flags} {lto_flags} {link} -o {output}"
|
cmd = f"{compiler} {' '.join(obj_files)} {flags} {lto_flags} {link} -o {output}"
|
||||||
return do_compile(cmd)
|
return do_compile(cmd)
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ def check_pybt(gdb_path, python_path):
|
||||||
# TODO: prev we use below code to check has py-bt or nor
|
# TODO: prev we use below code to check has py-bt or nor
|
||||||
# but it is too slow, so we comment it,
|
# but it is too slow, so we comment it,
|
||||||
# find a better way to check py-bt exist
|
# find a better way to check py-bt exist
|
||||||
|
|
||||||
# ret = sp.getoutput(f"{gdb_path} --batch {python_path} -ex 'help py-bt'")
|
# ret = sp.getoutput(f"{gdb_path} --batch {python_path} -ex 'help py-bt'")
|
||||||
# if 'python frame' in ret:
|
# if 'python frame' in ret:
|
||||||
# LOG.v("py-bt found in gdb.")
|
# LOG.v("py-bt found in gdb.")
|
||||||
|
|
|
@ -60,6 +60,20 @@ class LogWarper:
|
||||||
def e(self, *msg): self._log('e', 0, *msg)
|
def e(self, *msg): self._log('e', 0, *msg)
|
||||||
def f(self, *msg): self._log('f', 0, *msg)
|
def f(self, *msg): self._log('f', 0, *msg)
|
||||||
|
|
||||||
|
class DelayProgress:
|
||||||
|
def __init__(self, msg, n):
|
||||||
|
self.msg = msg
|
||||||
|
self.n = n
|
||||||
|
self.time = time.time()
|
||||||
|
|
||||||
|
def update(self, i):
|
||||||
|
if LOG.log_silent:
|
||||||
|
return
|
||||||
|
used = time.time() - self.time
|
||||||
|
if used > 2:
|
||||||
|
eta = used / (i+1) * (self.n-i-1)
|
||||||
|
print(f"{self.msg}({i+1}/{self.n}) used: {used:.3f}s eta: {eta:.3f}s", end='\r')
|
||||||
|
|
||||||
# check is in jupyter notebook
|
# check is in jupyter notebook
|
||||||
def in_ipynb():
|
def in_ipynb():
|
||||||
try:
|
try:
|
||||||
|
@ -134,7 +148,7 @@ def do_compile(args):
|
||||||
|
|
||||||
pool_size = 0
|
pool_size = 0
|
||||||
|
|
||||||
def run_cmds(cmds, cache_path, jittor_path):
|
def run_cmds(cmds, cache_path, jittor_path, msg="run_cmds"):
|
||||||
global pool_size
|
global pool_size
|
||||||
if pool_size == 0:
|
if pool_size == 0:
|
||||||
mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
|
mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
|
||||||
|
@ -146,7 +160,10 @@ def run_cmds(cmds, cache_path, jittor_path):
|
||||||
mp.current_process()._config['daemon'] = False
|
mp.current_process()._config['daemon'] = False
|
||||||
try:
|
try:
|
||||||
with Pool(pool_size) as p:
|
with Pool(pool_size) as p:
|
||||||
p.map(do_compile, cmds)
|
n = len(cmds)
|
||||||
|
dp = DelayProgress(msg, n)
|
||||||
|
for i,_ in enumerate(p.imap_unordered(do_compile, cmds)):
|
||||||
|
dp.update(i)
|
||||||
finally:
|
finally:
|
||||||
mp.current_process()._config['daemon'] = bk
|
mp.current_process()._config['daemon'] = bk
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue