[petsc-users] question of a Brazilian student about the use of "PETSC" in a cluster

Marcelo Guterres m.guterres at gmail.com
Thu Dec 13 04:55:10 CST 2012


Hello,

My name is Marcelo Guterres and I am PhD student in Brazil.

I use the PETSC in a cluster with 11 computers, each with 8 processors 
"Xeon 2.8GHz", "16GB RAM" and "4 HD SAS" from "146GB".

My question is about the PETSc following functions:

/    -> Ierr = MPI_Comm_rank (MPI_COMM_WORLD, & rank); CHKERRQ (ierr);
     -> Ierr = MPI_Comm_size (MPI_COMM_WORLD, & size); CHKERRQ (ierr);/


For example, using only MPI:

----------------------------------------------------------------------------------------------

// Program hello word using MPI

#include <iostream>
using namespace std;
#include <mpi.h>

int main(int argc, char *argv[])

{
    int size, rank;
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD,&size);
    MPI_Comm_rank(MPI_COMM_WORLD,&rank);

    cout << "hello. I am process " << rank << " of " << size << endl;

    if ( rank == 0)
    {
        cout << "\nFinish !!" << endl;
    }

    MPI_Finalize();
}



*****  running the command has the following output:*

[guterres at stratus hello]$ mpirun -np 3 ./hello

hello. I am process 1 of 3
hello. I am process 0 of 3

Finish !!
hello. I am process 2 of 3


CONCLUSION: int size = 3;

----------------------------------------------------------------------------------------------


using only the PETSC

----------------------------------------------------------------------------------------------


static char help[] ="\n\n hello word PETSC !!";
#include <iostream>
#include <petscsys.h>
using namespace std;

int main( int argc, char *argv[] )
{
    PetscErrorCode  ierr;

    PetscMPIInt  size,
                        rank;

    ierr = PetscInitialize(&argc,&argv,(char *)0,help);CHKERRQ(ierr);
    ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank); CHKERRQ(ierr);
    ierr = MPI_Comm_size(MPI_COMM_WORLD,&size); CHKERRQ(ierr);

    cout << "hello. I am process " << rank << " of " << size << endl;

    if ( rank == 0)
    {
        cout << "\nfinish !!" << endl;
    }


    ierr =  PetscFinalize( ); CHKERRQ(ierr);
    return 0;
}


*****  running the command has the following output:*


[guterres at stratus hello_petsc]$ mpirun -np 3 ./hello

hello. I am process 0 of 1
finish !!

hello. I am process 0 of 1
finish !!

hello. I am process 0 of 1
finish !!


----------------------------------------------------------------------------------------------


*MY QUESTION IS:*


THE OUTPUT OF THE PROGRAM WITH PETSC CORRECT???

the variable value PetscMPIInt  size = np ??

The correct output should not be:


[guterres at stratus hello_petsc]$ mpirun -np 3 ./hello

hello. I am process 0 of 3

hello. I am process 1 of 3

hello. I am process 2 of 3

finish !!

CONCLUSION: PetscMPIInt size = 3 ??


Thank you for your attention and excuse my writing in English.


Marcelo Guterres
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121213/8c07310c/attachment.html>


More information about the petsc-users mailing list