Skip to content

Commit

Permalink
Update eessi/testsuite/tests/apps/tensorflow/src/tf_test.py
Browse files Browse the repository at this point in the history
More elegant way of retrieving local rank

Co-authored-by: Sam Moors <[email protected]>
  • Loading branch information
casparvl and smoors authored Jul 26, 2023
1 parent 16ddf31 commit ea5414b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions eessi/testsuite/tests/apps/tensorflow/src/tf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ def get_local_rank(rank_info, rank_info_list):
# Note that rank_info_list is sorted by rank, by definition of the MPI allgather routine.
# Thus, if our current rank is the n-th item in rank_info_list for which the hostname matches,
# our local rank is n
local_rank = 0
for item in rank_info_list:
if item['hostname'] == rank_info['hostname']:
if item['rank'] == rank_info['rank']:
return local_rank
else:
local_rank += 1
for index, item in enumerate(rank_info_list):
if item['hostname'] == rank_info['hostname'] and item['rank'] == rank_info['rank']:
return index

def get_rank_info(comm=MPI.COMM_WORLD):
'''Create a dict for this worker containing rank, hostname and port to be used by this worker'''
Expand Down

0 comments on commit ea5414b

Please sign in to comment.