Skip to content

Commit

Permalink
only intialize and finalize on DLIOMPI (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan authored Aug 13, 2024
1 parent bd12736 commit 5aec234
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,4 @@ dmypy.json
.DS_Store
/.idea/
/venv-quartz/
venv-openmpi
21 changes: 10 additions & 11 deletions dlio_benchmark/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"""
import os
import math
from mpi4py import MPI
comm = MPI.COMM_WORLD
import logging
from time import time, sleep
import json
Expand Down Expand Up @@ -50,8 +48,7 @@
from dlio_benchmark.utils.utility import Profile, PerfTrace

dlp = Profile(MODULE_DLIO_BENCHMARK)
# To make sure the output folder is the same in all the nodes. We have to do this.
comm.Barrier()
# To make sure the output folder is the same in all the nodes. We have to do this.
import hydra

class DLIOBenchmark(object):
Expand Down Expand Up @@ -383,19 +380,21 @@ def finalize(self):
self.comm.barrier()
self.args.finalize_dftracer(self.dftracer)


@hydra.main(version_base=None, config_path="configs", config_name="config")
def main(cfg: DictConfig) -> None:

"""
The main method to start the benchmark runtime.
"""
DLIOMPI.get_instance().initialize()
def run_benchmark(cfg: DictConfig):
benchmark = DLIOBenchmark(cfg['workload'])
os.environ["DARSHAN_DISABLE"] = "1"
benchmark.initialize()
benchmark.run()
benchmark.finalize()


def main() -> None:
"""
The main method to start the benchmark runtime.
"""
DLIOMPI.get_instance().initialize()
run_benchmark()
DLIOMPI.get_instance().finalize()

if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions dlio_benchmark/utils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ def iter(self, a):

# MPI cannot be initialized automatically, or read_thread spawn/forkserver
# child processes will abort trying to open a non-existant PMI_fd file.
import mpi4py
mpi4py.rc.initialize = False
from mpi4py import MPI

import mpi4py
p = psutil.Process()


Expand Down Expand Up @@ -112,6 +110,7 @@ def classname(cls):
return cls.__qualname__

def initialize(self):
from mpi4py import MPI
if self.mpi_state == MPIState.UNINITIALIZED:
# MPI may have already been initialized by dlio_benchmark_test.py
if not MPI.Is_initialized():
Expand Down Expand Up @@ -181,6 +180,7 @@ def nnodes(self):
else:
return self.mpi_size//self.mpi_ppn
def finalize(self):
from mpi4py import MPI
if self.mpi_state == MPIState.MPI_INITIALIZED and MPI.Is_initialized():
MPI.Finalize()

Expand Down

0 comments on commit 5aec234

Please sign in to comment.