MPI - Error on sending argv

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications High Performance Computing MPI - Error on sending argv
# 1  
Old 04-21-2010
MPI - Error on sending argv

Hi all,
I write a simple MPI program to send a text message to another process. The code is below.
(test.c)
Code:
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]) {
    int dest, noProcesses, processId;
    MPI_Status status;
    
    char* buffer;
    
    char* text = "ABCDEF";
    
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &noProcesses);
    MPI_Comm_rank(MPI_COMM_WORLD, &processId);
    
    buffer = (char*) malloc(256 * sizeof(char));
    
    if (processId == 0) {
      fprintf(stdout, "Master: sending %s to %d\n", text, 1);
      MPI_Send((void *)&text, strlen(text) + 1, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
    } else {
      MPI_Recv(&buffer, 128, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
      fprintf(stdout, "Slave: received %s from %d\n", buffer, status.MPI_SOURCE);
    }
    MPI_Finalize();
    return 0;
}

After compiling and executing it I get the following output:
Code:
[root@cluster Desktop]# mpicc -o test test.c
[root@cluster Desktop]# mpirun -np 2 test
Master: sending ABCDEF to 1
Slave: received ABCDEF from 0

In the source code above, I replace
Code:
char* text = "ABCDEF";

by
Code:
char* text = argv[1];

then compile and execute it again with the following commands:
Code:
[root@cluster Desktop]# mpicc -o test test.c
[root@cluster Desktop]# mpirun -np 2 test ABCDEF

Then I get the following output:
Code:
Master: sending ABCDEF to 1
[cluster:03917] *** Process received signal ***
[cluster:03917] Signal: Segmentation fault (11)
[cluster:03917] Signal code: Address not mapped (1)
[cluster:03917] Failing at address: 0xbfa445a2
[cluster:03917] [ 0] [0x959440]
[cluster:03917] [ 1] /lib/libc.so.6(_IO_fprintf+0x22) [0x76be02]
[cluster:03917] [ 2] test(main+0x143) [0x80488b7]
[cluster:03917] [ 3] /lib/libc.so.6(__libc_start_main+0xdc) [0x73be8c]
[cluster:03917] [ 4] test [0x80486c1]
[cluster:03917] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 1 with PID 3917 on node cluster.hpc.org exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------

I'm very confused because the only difference between the two source codes is the difference between
Code:
char* text = "ABCDEF";

and
Code:
char* text = argv[1];

Can any one help me why the results are so different? How can I send argv[i] to another process?
Thank you very much!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

2. High Performance Computing

FFTW - ./configure --enable-mpi error.

Hello I am trying to install fftw3.3.3 on an HPC system. The system has openmpi installed ( though we can choose between a variety of mpi distributions). However, while ./configure step of fftw, there is an error. The relevant section of the output is: checking whether to build shared... (3 Replies)
Discussion started by: abhi34101
3 Replies

3. IP Networking

Getting EAGAIN error while sending

Hi Guys I am using one non blocking socket to send message to the servers.I am using Solaris OS .I am using default buffer size for the socket.The message I am sending roughly size is 20 bytes.I am sending such 18 messages.But I am getting EAGAIN error very occasionally while sending those... (5 Replies)
Discussion started by: mr_deb
5 Replies

4. Shell Programming and Scripting

Getting error while sending mail via smtp

Hi All, I used before a simple routine code in tcl to send mail. package require smtp package require mime package require Tcl proc send_simple_message {recipient email_server subject body} { set token mime::setheader $token Subject $subject smtp::sendmessage $token \ ... (0 Replies)
Discussion started by: zivsegal
0 Replies

5. High Performance Computing

MPI error message and other applicatioins

1st,I'm a newbie. I've written a mpi program to realize the parallel computing and encounter many problems. 1. When the computing scale is small, that means the communication time is short, just needs few minutes, such as 14 minutes or less. The program runs well and finished the jog. ... (0 Replies)
Discussion started by: mystline
0 Replies

6. Shell Programming and Scripting

Error while sending email from solaris

Dears, I have tried to send email, but i have following error. 051 mydomain.net: Name server timeout i have add following line to /etc/resolv.conf domain mydomain.net But didn't work, i didn't configure anything else .. Do i need to configure anything else ???? root#xxx@mydomain.net...... (0 Replies)
Discussion started by: Danish Shakil
0 Replies

7. Shell Programming and Scripting

error while sending mails through MKS

#!/bin/ksh email0="dummy@company.com" emails() { # mail Generation echo "Hi" | /mapimail -s "-(Test Mail)From Production- `date`" $email0; } emails i receive the following error IDispatch::new MSMAPI.MAPISession failed: 800401f3 at... (0 Replies)
Discussion started by: Vrgurav
0 Replies

8. Shell Programming and Scripting

sending mail error.. help

help i get this error when i sending a mail send-mail: fatal: open /etc/postfix/main.cf: No such file or directory Can't send mail: sendmail process failed this is my coding echo "$PRONAME is being restart" | mailxs "Subject:Process" "sally@$THISHOST" i wish to send this mail to my... (2 Replies)
Discussion started by: kkc
2 Replies

9. HP-UX

Sending Error msg from HP-UX to E-mail address

Sometimes, for any reason, the UX System sends messages to /var/mail/root and/or to Error Log of the guardian. I'll appreciating if you help me to configure so that those messages are also sent to the System Administrator's e-mail address. Regards Gege (1 Reply)
Discussion started by: cgege
1 Replies

10. UNIX for Dummies Questions & Answers

Error when sending mail attachment

I have been sending an email attachment from my unix box, but keep getting an error? All though the recipient still receives the email and attachment. Will this error cause problems in the future and how to I cure it? $ uuencode PReSvPRINTER.txt file | mailx -s "File" me@world.com uuencode:... (1 Reply)
Discussion started by: dbrundrett
1 Replies
Login or Register to Ask a Question