Quantcast
Channel: Clusters and HPC Technology
Viewing all articles
Browse latest Browse all 927

MPI - Code hangs when send/recv large data

$
0
0

Hi all,

I have been confused by the strange behaviour of intel mpi library for days. When I send small data, everything is fine. However, when I send large data, the following code hangs.

 

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


int main(){
	int length = MSG_LENGTH;
	char* buf = malloc(length);
	int size, rank;

	MPI_Init(0, NULL);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &size);

	if(rank == 0){
		MPI_Send(buf, length, MPI_BYTE, 1, 0, MPI_COMM_WORLD);
		printf("Sent");
	}else{
		MPI_Recv(buf, length, MPI_BYTE, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
		printf("Received");
	}
	free(buf);
	return 0;
}

 

This is the test makefile:

 

default: compile test-small test-large

compile:
	mpiicc mpi.c -DMSG_LENGTH=1024 -o mpi-small
	mpiicc mpi.c -DMSG_LENGTH=1048576 -o mpi-large

test-small: compile
	@echo "Testing Recv/Send with small data"
	mpiexec.hydra -n 2 ./mpi-small
	@echo "Test done"

test-large: compile
	@echo "Testing Recv/Send with large data"
	mpiexec.hydra -n 2 ./mpi-large
	@echo "Test done"

 

Thank you very much!


Viewing all articles
Browse latest Browse all 927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>