MCPcopy Create free account
hub / github.com/pytorch/pytorch / decide_parallel_depth

Method decide_parallel_depth

torch/_inductor/codegen/cpp.py:1509–1528  ·  view source on GitHub ↗
(self, ranges, threads)

Source from the content-addressed store, hash-verified

1507 return "TORCH_CHECK"
1508
1509 def decide_parallel_depth(self, ranges, threads):
1510 seq = self.size_hint()
1511 par = 1
1512 depth = 0
1513 for expr in ranges:
1514 hint = V.graph.sizevars.size_hint(expr, fallback=8192)
1515 if par >= 2 * threads or par == threads:
1516 break
1517 if seq // threads < config.cpp.min_chunk_size:
1518 # not enough work
1519 break
1520 depth += 1
1521 par *= hint
1522 seq /= hint
1523 # if we assume thread number is dynamic, make sure we
1524 # have at least one parallel scope and let OMP runtime
1525 # to manage the serial vs. parallel.
1526 if config.cpp.dynamic_threads and depth == 0 and len(ranges) > 0:
1527 depth = 1
1528 return depth
1529
1530 @contextlib.contextmanager
1531 def write_to_suffix(self):

Callers 1

codegen_loops_implMethod · 0.95

Calls 1

size_hintMethod · 0.95

Tested by

no test coverage detected