You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_mpi.py 1.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Test Message Passing Interface for cluster paralleling.
  5. Created on Wed Nov 7 17:26:40 2018
  6. @author: ljia
  7. """
  8. from mpi4py import MPI
  9. comm = MPI.COMM_WORLD
  10. rank = comm.Get_rank()
  11. import numpy as np
  12. import time
  13. size = comm.Get_size()
  14. numDataPerRank = 10
  15. data = None
  16. if rank == 0:
  17. data = np.linspace(1, size * numDataPerRank, size * numDataPerRank)
  18. recvbuf = np.empty(numDataPerRank, dtype='d')
  19. comm.Scatter(data, recvbuf, root=0)
  20. recvbuf += 1
  21. print('Rank: ', rank, ', recvbuf received: ', recvbuf, ', size: ', size, ', time: ', time.time())
  22. #if rank == 0:
  23. # data = {'key1' : [1,2, 3],
  24. # 'key2' : ( 'abc', 'xyz')}
  25. #else:
  26. # data = None
  27. #
  28. #data = comm.bcast(data, root=0)
  29. #print('Rank: ',rank,', data: ' ,data)
  30. #if rank == 0:
  31. # data = {'a': 7, 'b': 3.14}
  32. # comm.send(data, dest=1)
  33. #elif rank == 1:
  34. # data = comm.recv(source=0)
  35. # print('On process 1, data is ', data)
  36. #print('My rank is ', rank)
  37. #for i in range(0, 100000000):
  38. # print(i)

A Python package for graph kernels, graph edit distances and graph pre-image problem.