1

I need to find the supremum norm (maximal element of vector) of a vector. I can implement is using norm function of linear algebra library of mpi4py.

x = np.linspace(0, 100, n)
mxnorm_x = norm(x, np.inf)
print "mxnorm-x", mxnorm_x

However, I need to find this supremum norm using MPI Reduce operation. Is it really possible to find this norm using comm.Reduce and the Op MAX or MAXLOC?

mirzapinku
  • 61
  • 8
  • 1
    Please describe more clearly how the data is distributed. Also your specific operation is not clear as your description does not match how supremum norm is defined. `MPI_Reduce` does not reduce arrays, it reduces distributed data. It may help to add a specific programming language tag. On the other hand, this question probably is *not* specific to Open MPI. – Zulan Nov 20 '18 at 15:43
  • Thank you for your comment. Description updated. The programming language is Python (though the problem is not related to python). And yes its not specific Open MPI problem, but MPI. As I know, there are several operations we can perform with Reduce operation like SUM, MAX, MIN etc. – mirzapinku Nov 20 '18 at 17:05

1 Answers1

1

I found the solution myself. Here is the update -

#divide up/ scatter the vector to all the process as sub vectors 
comm.Scatterv([x, sendTuple, disTuple, MPI.DOUBLE], local_x)

#compute max of that sub-vector (local_x)
local_max = np.max(local_x)

#find overall MAX
comm.Reduce(local_max, max, op = MPI.MAX)

#data will be stored in max
print "Maximum Value:", max[0]
mirzapinku
  • 61
  • 8