Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 4 characters in body
Source Link
je4d
  • 7.9k
  • 35
  • 46

I'm studying a bit of MPI, and decided to do a test by making a program that calls objects, eg main.c main.c -> main program, function.cfunction.c -> any function

function.c that will only use the MPI. compiling I as follows. gcc-c main.c:

gcc-c main.c 

to create main.o mpicc-cmain.o, mpicc-c to create function.c function.ofunction.c function.o, of course I create the file function.hfunction.h too.

I compile with mpicc-ompicc-o program main.o function.omain.o function.o

here main.cHere is main.c

#include <stdio.h> #include "function.h" void main(int argc, char *argv[]) { printf("Hello\n"); function(); printf("Bye\n"); } 

just function has the MPI code, but when i'mI'm running the program mpiexe -np 2 program impiexe -np 2 I get

Hello Hello ----- function job here ----- Bye Bye 

butBut I wanted it to be

Hello ------ function job ----- Bye 

whatWhat can iI do?

sorry my bad english :)

I'm studying a bit of MPI, and decided to do a test by making a program that calls objects, eg main.c -> main program, function.c -> any function

function.c that will only use the MPI. compiling I as follows. gcc-c main.c to create main.o mpicc-c to create function.c function.o, of course I create the file function.h too.

I compile with mpicc-o program main.o function.o

here main.c

#include <stdio.h> #include "function.h" void main(int argc, char *argv[]) { printf("Hello\n"); function(); printf("Bye\n"); } 

just function has the MPI code, but when i'm running the program mpiexe -np 2 program i get

Hello Hello ----- function job here ----- Bye Bye 

but I wanted it to be

Hello ------ function job ----- Bye 

what can i do?

sorry my bad english :)

I'm studying a bit of MPI, and decided to do a test by making a program that calls objects, eg main.c -> main program, function.c -> any function

function.c that will only use the MPI. compiling I as follows:

gcc-c main.c 

to create main.o, mpicc-c to create function.c function.o, of course I create the file function.h too.

I compile with mpicc-o program main.o function.o

Here is main.c

#include <stdio.h> #include "function.h" void main(int argc, char *argv[]) { printf("Hello\n"); function(); printf("Bye\n"); } 

just function has the MPI code, but when I'm running the program mpiexe -np 2 I get

Hello Hello ----- function job here ----- Bye Bye 

But I wanted it to be

Hello ------ function job ----- Bye 

What can I do?

Source Link
Fabricio
  • 343
  • 1
  • 5
  • 11

MPI 2x printing

I'm studying a bit of MPI, and decided to do a test by making a program that calls objects, eg main.c -> main program, function.c -> any function

function.c that will only use the MPI. compiling I as follows. gcc-c main.c to create main.o mpicc-c to create function.c function.o, of course I create the file function.h too.

I compile with mpicc-o program main.o function.o

here main.c

#include <stdio.h> #include "function.h" void main(int argc, char *argv[]) { printf("Hello\n"); function(); printf("Bye\n"); } 

just function has the MPI code, but when i'm running the program mpiexe -np 2 program i get

Hello Hello ----- function job here ----- Bye Bye 

but I wanted it to be

Hello ------ function job ----- Bye 

what can i do?

sorry my bad english :)