0

I am getting this error:

[ranks] message

[0] fatal error
Fatal error in MPI_Iprobe: Invalid displacement argument in RMA call, error stack:
MPI_Iprobe(src=MPI_ANY_SOURCE, tag=MPI_ANY_TAG, MPI_COMM_WORLD, flag=0x0000006C0A8FF214, status=0x0000006C0A8FF238) failed
(unknown)(): Invalid displacement argument in RMA call

[1] terminated

This is the function call I am using:

MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, &status);

Edit - A complete code that produces the error:

#include<iostream>
#include "mpi.h"
#include <omp.h>
#include <process.h>

using namespace std;

int numOfProc, id;
int *arr = NULL;
MPI_Status status;
const static int tag = 1;
int provided;

void fun_1();
void fun_0();


int main(int argc, char *argv[])
{
    //MPI_Init(&argc, &argv);
    MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);


    MPI_Comm_size(MPI_COMM_WORLD, &numOfProc);
    MPI_Comm_rank(MPI_COMM_WORLD, &id);

    cout << "Hello from Process # " << id << '\n';

    if (id == 0)
        fun_0();
    else
        fun_1();

    MPI_Finalize();
}



void fun_1()
{
    omp_set_num_threads(2);
#pragma omp parallel for
    for (int i = 0; i < 2; i++)
    {

        int flag;
        int recvArr[3];
        int sendArr[3];

        while (true)
        {
            flag = 0;

            //Wait for a msg
            while (!flag)
            {
                MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, &status);
            }

            MPI_Recv(&recvArr, 3, MPI_INT, status.MPI_SOURCE, tag, MPI_COMM_WORLD, &status);

            sendArr[0] = 1;
            sendArr[1] = 2;
            sendArr[2] = 3;
            int size = 3;

            MPI_Send(sendArr, size, MPI_INT, status.MPI_SOURCE, tag, MPI_COMM_WORLD);
        }
    }
}


void fun_0()
{
    omp_set_num_threads(2);
#pragma omp parallel for
    for (int i = 0; i < 2; i++)
    {
        int num = 1;
        while (true)
        {
            if (num++ % 2 == 0)
            {
                int arr[3];

                arr[0] = 1;
                arr[1] = 2;
                arr[2] = 3;

                MPI_Send(arr, 3, MPI_INT, 1, tag, MPI_COMM_WORLD);

                MPI_Status status;
                int length;

                MPI_Probe(1, tag, MPI_COMM_WORLD, &status);

                MPI_Get_count(&status, MPI_INT, &length);

                // Allocate a buffer to hold the data
                int* recievedResult = (int*)malloc(sizeof(int) * length);

                // Now receive 
                MPI_Recv(recievedResult, length, MPI_INT, 1, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
            }
        }
    }

}

What does this error mean?

Jack
  • 131
  • 1
  • 8
  • Please provide a [mcve] – Zulan Jul 15 '17 at 09:11
  • I'll work on an example now. – Jack Jul 15 '17 at 09:14
  • I have added an example code. – Jack Jul 15 '17 at 10:07
  • Is that really the most minimal example you could conceive?! First of all, " It is the caller’s responsibility to check the value of provided, as it may be less than what was requested in required." – Zulan Jul 15 '17 at 10:57
  • Sorry, I tried! I checked the provided value it is 3 which is equal to required. – Jack Jul 15 '17 at 11:06
  • If I replace MPI_Iprobe with MPI_Probe I do not get that error. – Jack Jul 15 '17 at 11:06
  • Let me just cite this from the standard: *"Since the list of incoming messages is global among the threads of each MPI process, it can be hard to use this functionality in threaded environments \[[29](https://pdfs.semanticscholar.org/827c/634cbe32213a3de12eee96687516afcb007e.pdf), [26](https://www.cs.indiana.edu/cgi-bin/techreports/TRNNN.cgi?trnum=TR674)]."* That's probably an understatement. You will just jump from headache to headache with what you're trying. While I can't reproduce your particular error, `MPI_Get_count` sometimes gives me a `length != 3`... – Zulan Jul 15 '17 at 14:49
  • Thank you for this clarification. Now I understand that I should figure another way to do what I need. Thank you again. – Jack Jul 15 '17 at 18:23

1 Answers1

1

It was found that MPI_Iprobe does not support multiple threads.

Jack
  • 131
  • 1
  • 8