Changeset 13602


Ignore:
Timestamp:
10/10/12 23:00:39 (12 years ago)
Author:
Eric.Larour
Message:

CHG: more changes to switch from my_rank and num_procs to IssmComm::GetSize and IssmComm::GetRank

Location:
issm/trunk-jpl/src/c/toolkits
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp

    r13558 r13602  
    66#include <math.h>
    77#include "../../../shared/shared.h"
     8#include "../../../include/types.h"
    89
    9 int DetermineLocalSize(int global_size){
     10int DetermineLocalSize(int global_size,COMM comm){
    1011
    1112        /*output: */
     
    1819
    1920        /*from MPI: */
    20         extern int num_procs;
    21         extern int my_rank;
     21        int num_procs2;
     22        int my_rank2;
     23
     24        /*recover my_rank2*/
     25        MPI_Comm_rank(comm,&my_rank2);
     26        MPI_Comm_size(comm,&num_procs2);
     27
    2228       
    2329        /*We are  not bound by any library, just use what seems most logical*/
    24         num_local_rows=xNew<int>(num_procs);   
     30        num_local_rows=xNew<int>(num_procs2);   
    2531
    26         for (i=0;i<num_procs;i++){
     32        for (i=0;i<num_procs2;i++){
    2733                /*Here, we use floor. We under distribute rows. The rows
    2834                  left  are then redistributed, therefore resulting in a
    2935                  more even distribution.*/
    30                 num_local_rows[i]=(int)floor((double)global_size/(double)num_procs);
     36                num_local_rows[i]=(int)floor((double)global_size/(double)num_procs2);
    3137        }
    3238       
    3339        /*There may be some rows left. Distribute evenly.*/
    34         row_rest=global_size - num_procs*(int)floor((double)global_size/(double)num_procs);
     40        row_rest=global_size - num_procs2*(int)floor((double)global_size/(double)num_procs2);
    3541        for (i=0;i<row_rest;i++){
    3642                num_local_rows[i]++;
    3743        }
    38         local_size=num_local_rows[my_rank];
     44        local_size=num_local_rows[my_rank2];
    3945       
    4046        /*free ressources: */
  • issm/trunk-jpl/src/c/toolkits/mpi/patches/mpipatches.h

    r13559 r13602  
    66#ifndef MPI_PATCHES_H_
    77#define MPI_PATCHES_H_
    8 int DetermineLocalSize(int global_size);
     8
     9#include "../../../include/types.h"
     10
     11int DetermineLocalSize(int global_size,COMM comm);
     12
    913#endif
  • issm/trunk-jpl/src/c/toolkits/petsc/patches/NewMat.cpp

    r13596 r13602  
    3232
    3333        /*Determine local sizes: */
    34         m=DetermineLocalSize(M);
    35         n=DetermineLocalSize(N);
     34        m=DetermineLocalSize(M,comm);
     35        n=DetermineLocalSize(N,comm);
    3636       
    3737        nnz=(int)((double)M*(double)N*sparsity); //number of non zeros.
     
    6060
    6161        /*Determine local sizes: */
    62         m=DetermineLocalSize(M);
    63         n=DetermineLocalSize(N);
     62        m=DetermineLocalSize(M,comm);
     63        n=DetermineLocalSize(N,comm);
    6464       
    6565        nnz=(int)((double)M*(double)N*sparsity); //number of non zeros.
     
    9999
    100100        /*Determine local sizes: */
    101         m=DetermineLocalSize(M);
    102         n=DetermineLocalSize(N);
     101        m=DetermineLocalSize(M,comm);
     102        n=DetermineLocalSize(N,comm);
    103103
    104104        /*Figure out number of non zeros per row: */
  • issm/trunk-jpl/src/c/toolkits/petsc/patches/NewVec.cpp

    r13599 r13602  
    3030        }
    3131        else{
    32                 local_size=DetermineLocalSize(size);
     32                local_size=DetermineLocalSize(size,comm);
    3333        }
    3434       
Note: See TracChangeset for help on using the changeset viewer.