1

I am trying to use MPI_REDUCE in C (or c++) to find the minimum (and the index) in an array. I have this working for regular array, but now I want to switch to one in which the value is dynamically computed. i.e the value of arr[n] is calculated by calling fun(n). Due to memory problems I cannot compute all values an put them in a regular array.

How can I achieve this?

Thanks in advance,

1 Answer 1

2

You'll need to use MPI_Op_create() to create a custom MPI operation: in your case, this operation would compare the values obtained by calling fun() on each element of the array, and select the minimum. You can then use this custom operation in the Op argument of MPI_Reduce().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.