Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github:jrs65/PyScalapack into kiyo

  • Loading branch information...
commit aa91a005a1d8daa46f4d492e6786f2c38437cd66 2 parents 2de83c5 + 7b1dffc
@kiyo-masui kiyo-masui authored
Showing with 39 additions and 8 deletions.
  1. +34 −5 bin/mpi-io-2.py
  2. +5 −3 pyscalapack/blockcyclic.py
View
39 bin/mpi-io-2.py
@@ -17,20 +17,49 @@
-arr = np.arange(gshape[0]*gshape[1]).astype(np.float64).reshape(gshape, order='F')
-arr.tofile("testarr.dat")
+arr = np.arange(gshape[0]*gshape[1]).astype(np.float64).reshape(gshape)
+arr.tofile("testarr_c.dat")
+np.asfortranarray(arr).tofile("testarr_f.dat")
-local_array = blockcyclic.mpi_readmatrix("testarr.dat", comm, gshape, np.float64, blocksize, pshape, order='F')
+local_array_c = blockcyclic.mpi_readmatrix("testarr_c.dat", comm, gshape, np.float64, blocksize, pshape, order='C')
+local_array_f = blockcyclic.mpi_readmatrix("testarr_f.dat", comm, gshape, np.float64, blocksize, pshape, order='F')
for i in range(size):
comm.Barrier()
if rank == i:
print [int(rank / pshape[1]), int(rank % pshape[1])]
- print local_array.flags
- print local_array
+ #print local_array.flags
+ #print local_array
+
+ print "Fortran ordered."
+ print local_array_f
+ print
+ print "C ordered."
+ print local_array_c
+ print
+
+blockcyclic.mpi_writematrix("testarr2_c.dat", local_array_c, comm, gshape, np.float64, blocksize, pshape, order='C')
+blockcyclic.mpi_writematrix("testarr2_f.dat", local_array_f, comm, gshape, np.float64, blocksize, pshape, order='F')
+
+
+if rank == 0:
+
+ arr1_c = np.fromfile("testarr_c.dat")
+ arr2_c = np.fromfile("testarr2_c.dat")
+
+ arr1_f = np.fromfile("testarr_f.dat")
+ arr2_f = np.fromfile("testarr2_f.dat")
+
+ print "F ordered"
+ print arr1_f
+ print arr2_f
+ print
+ print "C ordered"
+ print arr1_c
+ print arr2_c
MPI.Finalize()
View
8 pyscalapack/blockcyclic.py
@@ -142,7 +142,7 @@ def mpi_readmatrix(fname, comm, gshape, dtype, blocksize, process_grid, order='F
if order not in ['F', 'C']:
raise Exception("Order must be 'F' (Fortran) or 'C'")
- mpiorder = MPI.ORDER_FORTRAN # Check what we need to do here for loading C
+ mpiorder = MPI.ORDER_FORTRAN if order=='F' else MPI.ORDER_C # Check what we need to do here for loading C
# ordered files.
@@ -228,7 +228,7 @@ def mpi_writematrix(fname, local_array, comm, gshape, dtype,
if order not in ['F', 'C']:
raise Exception("Order must be 'F' (Fortran) or 'C'")
- mpiorder = MPI.ORDER_FORTRAN # Check what we need to do here for loading C
+ mpiorder = MPI.ORDER_FORTRAN if order=='F' else MPI.ORDER_C # Check what we need to do here for loading C
# ordered files.
@@ -252,7 +252,9 @@ def mpi_writematrix(fname, local_array, comm, gshape, dtype,
raise Exception("Local array size is not consistent with array description.")
# Length of filename required for write (in bytes).
- filelength = displacement + darr.Get_size()
+ filelength = displacement + gshape[0]*gshape[1]
+
+ print filelength, darr.Get_size()
# Open the file, and read out the segments
f = MPI.File.Open(comm, fname, MPI.MODE_RDWR | MPI.MODE_CREATE)
Please sign in to comment.
Something went wrong with that request. Please try again.