run_all.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from benchmarks.communication.utils import *
  2. from benchmarks.communication.all_reduce import run_all_reduce
  3. from benchmarks.communication.all_gather import run_all_gather
  4. from benchmarks.communication.all_to_all import run_all_to_all
  5. from benchmarks.communication.pt2pt import run_pt2pt
  6. from benchmarks.communication.broadcast import run_broadcast
  7. from benchmarks.communication.constants import *
  8. # For importing
  9. def main(args, rank):
  10. init_processes(local_rank=rank, args=args)
  11. ops_to_run = []
  12. if args.all_reduce:
  13. ops_to_run.append('all_reduce')
  14. if args.all_gather:
  15. ops_to_run.append('all_gather')
  16. if args.broadcast:
  17. ops_to_run.append('broadcast')
  18. if args.pt2pt:
  19. ops_to_run.append('pt2pt')
  20. if args.all_to_all:
  21. ops_to_run.append('all_to_all')
  22. if len(ops_to_run) == 0:
  23. ops_to_run = ['all_reduce', 'all_gather', 'all_to_all', 'broadcast', 'pt2pt']
  24. for comm_op in ops_to_run:
  25. if comm_op == 'all_reduce':
  26. run_all_reduce(local_rank=rank, args=args)
  27. if comm_op == 'all_gather':
  28. run_all_gather(local_rank=rank, args=args)
  29. if comm_op == 'all_to_all':
  30. run_all_to_all(local_rank=rank, args=args)
  31. if comm_op == 'pt2pt':
  32. run_pt2pt(local_rank=rank, args=args)
  33. if comm_op == 'broadcast':
  34. run_broadcast(local_rank=rank, args=args)
  35. # For directly calling benchmark
  36. if __name__ == "__main__":
  37. args = benchmark_parser().parse_args()
  38. rank = args.local_rank
  39. main(args, rank)