• 0

[MPI]mpi_Isend help


Question

Hello,

I am totally new to mpi and i installed openMPI on ubuntu... i am having a compilation problem when using mpi_Isend.

CountArray.c:(.text+0x12c): undefined reference to `MPI_ISend'

Here is my code... I know it's far from being perfect.. but im still discovering...

#include <stdio.h>
#include <mpi.h>

	int numbers[10000]; //the numbers we need to get their average
	int data[5000]; //the aray in which we will send the numbers to the threads.
	int count, to, tag, from;

   MPI_Request	send_request,recv_request;
int main (argc, argv)
	int argc;
	char *argv[];
{
  int rank, size;

//start by filling the numbers array
	int i=0;
	int j=0; //index to the numbers to be sent
for(i=0; i<10000; i++)
	numbers[i] = i;

  MPI_Status status;
  MPI_Init (&argc, &argv);	/* starts MPI */
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
  MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */

if(rank ==0){
  printf( "Hello world from Main process %d of %d\n", rank, size );
	//the manager
	//put the numbers in the data array:

	count = 5000;
	to = 1;
	tag = 2001;
	for(j; j<5000; j++){
		data[j] = numbers[j];	
	}

	MPI_ISend(data, count, MPI_INT, to, tag, MPI_COMM_WORLD, &send_request); //HERE IS THE ERROR.. I NEED TO SEND THE DATA ARRAY WHICH CONTAINS 5000 ELEMENTS FROM PROCESS 0 TO PROCESS 1


}else{
printf( "Hello world from  process %d of %d\n", rank, size );
from = MPI_ANY_SOURCE;
//MPI_IRecv(data, count, MPI_INT, 0, tag, MPI_COMM_WORLD, &recv_request);

//printf("Received data info\nFrom process: &d, count: &d", from, 1000);

}


  MPI_Finalize();
  return 0;
}

THANKS IN ADVANCE FOR ANY HELP :D

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

looks to me like you're missing a library, what GCC arguments are you using?

Edit: Wait a sec, you'll probs be using mpicc to compile

Link to comment
Share on other sites

  • 0

Very quick look because I'm at work, but shouldn't it be MPI_Isend() ?

According to here.

int MPI_Isend( void *buf, int count, MPI_Datatype datatype, int dest, int tag,
               MPI_Comm comm, MPI_Request *request )

Link to comment
Share on other sites

  • 0

Very quick look because I'm at work, but shouldn't it be MPI_Isend() ?

According to here.

int MPI_Isend( void *buf, int count, MPI_Datatype datatype, int dest, int tag,
               MPI_Comm comm, MPI_Request *request )

MPI_ISend(data, count, MPI_INT, to, tag, MPI_COMM_WORLD, &send_request);

yeah that's what i've been using...

10x anyway

looks to me like you're missing a library, what GCC arguments are you using?

Edit: Wait a sec, you'll probs be using mpicc to compile

yes im using mpicc... here is the terminal extract.. u think im missing something?

elio@ubuntu:~$ cd Desktop
elio@ubuntu:~/Desktop$ mpicc -o numbers CountArray.c
/tmp/ccDhwA0d.o: In function `main':
CountArray.c:(.text+0x12c): undefined reference to `MPI_ISend'
collect2: ld returned 1 exit status

Link to comment
Share on other sites

  • 0

Request MPI::Comm::Isend(const void* buf, int count,
           const Datatype& datatype, int dest, int tag) const;

what is this line!!...

Link to comment
Share on other sites

  • 0

You missed my point. You're using MPI_ISend() when it should be MPI_Isend(). Case is important. The 'S' should be lower case.

Link to comment
Share on other sites

  • 0

You missed my point. You're using MPI_ISend() when it should be MPI_Isend(). Case is important. The 'S' should be lower case.

yeah ur right.. lol fixed it but still have errors

note: expected ?struct ompi_request_t **? but argument is of type ?MPI_Request?

#include <stdio.h>
#include <mpi.h>

#define send_data_tag 2001

int rank, size, num_to_send, ierr, i, elio_khattar[2], num_rows_to_send, child_id;
int main (argc, argv)
	int argc;
	char *argv[];
{
	num_to_send = 100;


		elio_khattar[0] = 100;
	elio_khattar[1] = 200;




	MPI_Status status;
	MPI_Request request;

	MPI_Init (&argc, &argv);	/* starts MPI */
	MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
	MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */



	if(rank ==0){
		printf("Hello world from main process %d\n",rank);
		num_rows_to_send = 2;
		child_id = 1;
ierr = MPI_Isend( &num_rows_to_send, 1 , MPI_INT, child_id, send_data_tag, MPI_COMM_WORLD, request);
	}else{

		printf("Hello world from process %d\n",rank);
	}

	MPI_Finalize();
	return 0;
}

It's one of the rare times when i feel stupid in programming lol

Link to comment
Share on other sites

  • 0

Can you post all the compiler warnings and errors?

The only obvious thing I see from looking at the prototype for MPI_Isend() is:

ierr = MPI_Isend( &num_rows_to_send, 1 , MPI_INT, child_id, send_data_tag, MPI_COMM_WORLD, request);

should be

ierr = MPI_Isend( &num_rows_to_send, 1 , MPI_INT, child_id, send_data_tag, MPI_COMM_WORLD, &request);

(&request, instead of request)

I'm not sure where struct ompi_request_t is coming from.

Link to comment
Share on other sites

  • 0

Can you post all the compiler warnings and errors?

The only obvious thing I see from looking at the prototype for MPI_Isend() is:

ierr = MPI_Isend( &num_rows_to_send, 1 , MPI_INT, child_id, send_data_tag, MPI_COMM_WORLD, request);

should be

ierr = MPI_Isend( &num_rows_to_send, 1 , MPI_INT, child_id, send_data_tag, MPI_COMM_WORLD, &request);

(&request, instead of request)

I'm not sure where struct ompi_request_t is coming from.

Wow.. the & thing worked... thanks so much (new to c also :p )

Link to comment
Share on other sites

  • 0

Wow.. the & thing worked... thanks so much (new to c also :p )

No problem :) It's been a while since I touched MPI, last time was at Uni.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.