Advertisement
Guest User

mpi.py

a guest
Oct 9th, 2010
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys
  4.  
  5. try:
  6.     from ctypes import CDLL, pythonapi, c_int, POINTER, c_char_p, byref, RTLD_GLOBAL
  7.     from ctypes.util import find_library
  8. except ImportError:
  9.     print 'ERROR! La libreria *ctypes* para Python no esta disponible!'
  10.     sys.exit(-1)
  11.  
  12. libc = CDLL('libc.so.6')
  13.  
  14. print libc._handle, libc._name
  15.  
  16. f = pythonapi.Py_GetArgcArgv
  17. argc = c_int()
  18. argv = POINTER(c_char_p)()
  19. f(byref(argc), byref(argv))
  20.  
  21. mpi = CDLL(find_library('mpi'), RTLD_GLOBAL)
  22. print mpi._handle, mpi._name
  23.  
  24. myrank = c_int();
  25. nprocs = c_int();
  26.  
  27. opt_flag = c_int.in_dll(pythonapi, "MPI_COMM_WORLD") # Aqui falla al acceder a MPI_COMM_WORLD
  28.  
  29. #mpi.MPI_Comm_size(mpi.MPI_COMM_WORLD, byref(nprocs)); # Lo necesito aqui, pero no funciona MPI_COMM_WORLD
  30.  
  31. libc.printf("Hello from processor %d of %d\n", myrank, nprocs);
  32.  
  33. mpi.MPI_Finalize()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement