Skip to content

Commit

Permalink
Fix OSX test shard generation (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryevdv authored Aug 31, 2022
1 parent 7915161 commit f77ef68
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
3 changes: 2 additions & 1 deletion tests/_utils/stages/_osx/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ def compute_spec(self, config: Config, system: System) -> StageSpec:
len(system.cpus) // procs, config.requested_workers
)

return StageSpec(workers, [])
# return a dummy set of shards just for the runner to iterate over
return StageSpec(workers, [(i,) for i in range(workers)])
3 changes: 2 additions & 1 deletion tests/_utils/stages/_osx/eager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ def compute_spec(self, config: Config, system: System) -> StageSpec:
degree = min(N, 60) # ~LEGION_MAX_NUM_PROCS just in case
workers = adjust_workers(degree, config.requested_workers)

return StageSpec(workers, [])
# return a dummy set of shards just for the runner to iterate over
return StageSpec(workers, [(i,) for i in range(workers)])
3 changes: 2 additions & 1 deletion tests/_utils/stages/_osx/omp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ def compute_spec(self, config: Config, system: System) -> StageSpec:
len(system.cpus) // procs, config.requested_workers
)

return StageSpec(workers, [])
# return a dummy set of shards just for the runner to iterate over
return StageSpec(workers, [(i,) for i in range(workers)])
20 changes: 13 additions & 7 deletions tests/_utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,19 @@ def cpus(self) -> tuple[CPUInfo, ...]:
def gpus(self) -> tuple[GPUInfo, ...]:
"""A list of GPUs on the system, including total memory information."""

# This pynvml import is protected inside this method so that in case
# pynvml is not installed, tests stages that don't need gpu info (e.g.
# cpus, eager) will proceed unaffected. Test stages that do require
# gpu info will fail here with an ImportError.
import pynvml # type: ignore[import]

pynvml.nvmlInit()
try:
# This pynvml import is protected inside this method so that in
# case pynvml is not installed, tests stages that don't need gpu
# info (e.g. cpus, eager) will proceed unaffected. Test stages
# that do require gpu info will fail here with an ImportError.
import pynvml # type: ignore[import]

# Also a pynvml package is available on some platforms that won't
# have GPUs for some reason. In which case this init call will
# fail.
pynvml.nvmlInit()
except Exception:
return ()

num_gpus = pynvml.nvmlDeviceGetCount()

Expand Down

0 comments on commit f77ef68

Please sign in to comment.