Skip to content

Commit

Permalink
rename ranks to ranks_per_node
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinz committed Oct 17, 2023
1 parent 1d93617 commit a167173
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion legate/tester/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

feature_opts.add_argument(
"--ranks-per-node",
dest="ranks",
dest="ranks_per_node",
type=int,
default=DEFAULT_RANKS_PER_NODE,
help="Number of ranks per node to use",
Expand Down
2 changes: 1 addition & 1 deletion legate/tester/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, argv: ArgList) -> None:
self.gpu_delay = args.gpu_delay
self.ompthreads = args.ompthreads
self.numamem = args.numamem
self.ranks = args.ranks
self.ranks_per_node = args.ranks_per_node
self.launcher = args.launcher
self.launcher_extra = args.launcher_extra
self.nodes = args.nodes
Expand Down
13 changes: 7 additions & 6 deletions legate/tester/stages/_linux/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def shard_args(self, shard: Shard, config: Config) -> ArgList:
"--cpu-bind",
str(shard),
]
if config.ranks > 1:
if config.ranks_per_node > 1:
args += [
"--ranks-per-node",
str(config.ranks),
str(config.ranks_per_node),
]
if config.nodes > 1:
args += [
Expand All @@ -81,16 +81,17 @@ def compute_spec(self, config: Config, system: TestSystem) -> StageSpec:

procs = config.cpus + config.utility + int(config.cpu_pin == "strict")
workers = adjust_workers(
len(cpus) // (procs * config.ranks), config.requested_workers
len(cpus) // (procs * config.ranks_per_node),
config.requested_workers,
)

shards: list[Shard] = []
for i in range(workers):
rank_shards = []
for j in range(config.ranks):
for j in range(config.ranks_per_node):
shard_cpus = range(
(j + i * config.ranks) * procs,
(j + i * config.ranks + 1) * procs,
(j + i * config.ranks_per_node) * procs,
(j + i * config.ranks_per_node + 1) * procs,
)
shard = chain.from_iterable(cpus[k].ids for k in shard_cpus)
rank_shards.append(tuple(sorted(shard)))
Expand Down
16 changes: 9 additions & 7 deletions legate/tester/stages/_linux/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def shard_args(self, shard: Shard, config: Config) -> ArgList:
"--gpu-bind",
str(shard),
]
if config.ranks > 1:
if config.ranks_per_node > 1:
args += [
"--ranks-per-node",
str(config.ranks),
str(config.ranks_per_node),
]
if config.nodes > 1:
args += [
Expand All @@ -80,7 +80,7 @@ def shard_args(self, shard: Shard, config: Config) -> ArgList:

def compute_spec(self, config: Config, system: TestSystem) -> StageSpec:
N = len(system.gpus)
degree = N // (config.gpus * config.ranks)
degree = N // (config.gpus * config.ranks_per_node)

fbsize = min(gpu.total for gpu in system.gpus) / (1 << 20) # MB
oversub_factor = int(fbsize // (config.fbmem * config.bloat_factor))
Expand All @@ -91,15 +91,17 @@ def compute_spec(self, config: Config, system: TestSystem) -> StageSpec:
shards: list[Shard] = []
for i in range(degree):
rank_shards = []
for j in range(config.ranks):
for j in range(config.ranks_per_node):
shard_gpus = range(
(j + i * config.ranks) * config.gpus,
(j + i * config.ranks + 1) * config.gpus,
(j + i * config.ranks_per_node) * config.gpus,
(j + i * config.ranks_per_node + 1) * config.gpus,
)
shard = tuple(shard_gpus)
rank_shards.append(shard)
shards.append(Shard(rank_shards))

shard_factor = workers if config.ranks == 1 else oversub_factor
shard_factor = (
workers if config.ranks_per_node == 1 else oversub_factor
)

return StageSpec(workers, shards * shard_factor)
13 changes: 7 additions & 6 deletions legate/tester/stages/_linux/omp.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def shard_args(self, shard: Shard, config: Config) -> ArgList:
"--cpu-bind",
str(shard),
]
if config.ranks > 1:
if config.ranks_per_node > 1:
args += [
"--ranks-per-node",
str(config.ranks),
str(config.ranks_per_node),
]
if config.nodes > 1:
args += [
Expand All @@ -87,16 +87,17 @@ def compute_spec(self, config: Config, system: TestSystem) -> StageSpec:
omps * threads + config.utility + int(config.cpu_pin == "strict")
)
workers = adjust_workers(
len(cpus) // (procs * config.ranks), config.requested_workers
len(cpus) // (procs * config.ranks_per_node),
config.requested_workers,
)

shards: list[Shard] = []
for i in range(workers):
rank_shards = []
for j in range(config.ranks):
for j in range(config.ranks_per_node):
shard_cpus = range(
(j + i * config.ranks) * procs,
(j + i * config.ranks + 1) * procs,
(j + i * config.ranks_per_node) * procs,
(j + i * config.ranks_per_node + 1) * procs,
)
shard = chain.from_iterable(cpus[k].ids for k in shard_cpus)
rank_shards.append(tuple(sorted(shard)))
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/legate/tester/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_ompthreads(self) -> None:
def test_numamem(self) -> None:
assert m.parser.get_default("numamem") == DEFAULT_NUMAMEM

def test_ranks(self) -> None:
assert m.parser.get_default("ranks") == DEFAULT_RANKS_PER_NODE
def test_ranks_per_node(self) -> None:
assert m.parser.get_default("ranks_per_node") == DEFAULT_RANKS_PER_NODE

def test_launcher(self) -> None:
assert m.parser.get_default("launcher") == "none"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/legate/tester/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_default_init(self) -> None:
assert c.bloat_factor == DEFAULT_GPU_BLOAT_FACTOR
assert c.omps == DEFAULT_OMPS_PER_NODE
assert c.ompthreads == DEFAULT_OMPTHREADS
assert c.ranks == DEFAULT_RANKS_PER_NODE
assert c.ranks_per_node == DEFAULT_RANKS_PER_NODE
assert c.launcher == "none"
assert c.launcher_extra == []
assert c.nodes == DEFAULT_NODES
Expand Down

0 comments on commit a167173

Please sign in to comment.