Ignore:
Timestamp:
05/30/18 20:08:15 (6 years ago)
Author:
yushan
Message:

save dev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/ep_dev/main.cpp

    r1506 r1511  
    680680 
    681681 
    682     MPI_Barrier(comm); 
    683     { 
    684     int rank, size; 
    685     MPI_Comm_rank(comm, &rank); 
    686     MPI_Comm_size(comm, &size); 
    687  
    688     //int tab_color[16]={2,2,2,3,0,1,1,3,2,1,3,0,0,2,0,0};     // OK 
    689     //int tab_key[16]={3,11,10,5,6,8,15,7,2,1,9,13,4,14,12,0}; // OK  
    690      
    691  
    692     int tab_color[16]={2,2,1,1,1,1,0,1,1,1,0,1,1,1,2,0}; 
    693     //int tab_key[16]={3,11,12,4,6,15,10,5,2,8,14,7,13,9,1,0}; 
    694     int tab_key[16]={3,11,7,7,6,15,10,5,2,8,14,7,13,9,1,0}; 
    695      
    696     int color = tab_color[rank]; 
    697     int key = tab_key[rank]; 
    698    
    699     MPI_Comm split_comm; 
    700     MPI_Comm_split(comm, color, key, &split_comm); 
    701  
    702  
    703      
    704     int split_rank; 
    705     MPI_Comm_rank(split_comm, &split_rank); 
    706      
    707     printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first); 
    708  
    709  
    710     MPI_Barrier(comm); 
    711     if(rank == 0) printf("\tMPI_Comm_split OK\n"); 
    712     MPI_Barrier(comm); 
    713 /* 
    714     MPI_Comm inter_comm; 
    715     //MPI_Intercomm_create(sub_comm, 0, comm, (color+1)%2, 99, &inter_comm); 
    716     MPI_Intercomm_create(sub_comm, 0, comm, remote_leader, 99, &inter_comm); 
    717  
    718     MPI_Barrier(comm); 
    719     if(rank == 0) printf("\tMPI_Intercomm_create OK\n"); 
    720     MPI_Barrier(comm); 
    721  
    722      
    723  
    724     int high=color; 
    725     MPI_Comm intra_comm; 
    726     MPI_Intercomm_merge(inter_comm, high, &intra_comm); 
    727      
    728     int intra_rank, intra_size; 
    729     MPI_Comm_rank(intra_comm, &intra_rank); 
    730     MPI_Comm_size(intra_comm, &intra_size); 
    731  
    732     MPI_Barrier(comm); 
    733     if(rank == 0) printf("\tMPI_Intercomm_merge OK\n"); 
    734     MPI_Barrier(comm); 
    735      
    736      
    737  
    738     //check_test_gatherv(comm); 
    739 */ 
    740     MPI_Barrier(comm); 
    741     MPI_Comm_free(&split_comm); 
    742  
    743  
    744     //MPI_Barrier(comm); 
    745     //MPI_Comm_free(&inter_comm); 
    746  
    747  
     682    // TEST OF COMM_SPLIT 
     683    { 
     684 
     685      MPI_Barrier(comm); 
     686      int rank, size; 
     687      MPI_Comm_rank(comm, &rank); 
     688      MPI_Comm_size(comm, &size); 
     689     
     690      int color = rand()%3; 
     691      int key = rand()%5; 
     692       
     693      int color2 = rand()%3; 
     694      int key2 = rand()%5; 
     695   
     696      MPI_Comm split_comm; 
     697      MPI_Comm_split(comm, color, key, &split_comm); 
     698 
     699       
     700      MPI_Comm split_comm2; 
     701      MPI_Comm_split(comm, color2, key2, &split_comm2); 
     702 
     703 
     704     
     705      int split_rank, split_size; 
     706      MPI_Comm_rank(split_comm, &split_rank); 
     707      MPI_Comm_size(split_comm, &split_size); 
     708     
     709#ifdef _Memory_check     
     710      printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first); 
     711#endif 
     712 
     713      MPI_Barrier(comm); 
     714      MPI_Barrier(comm); 
     715      MPI_Barrier(comm); 
     716       
     717      if(rank == 0) printf("            \t tMPI_Comm_split \t OK\n"); 
     718       
     719      MPI_Barrier(comm); 
     720      MPI_Barrier(comm); 
     721       
     722      int bcast_buf_size=100; 
     723       
     724      std::vector<int> bcast_buf(bcast_buf_size, 0); 
     725       
     726      if(split_rank==0) bcast_buf.assign(bcast_buf_size, (color+1)*split_size); 
     727       
     728      MPI_Bcast(bcast_buf.data(), bcast_buf_size, MPI_INT, 0, split_comm); 
     729       
     730      int bcast_test = 0; 
     731      for(int i=0; i<bcast_buf_size; i++) 
     732      { 
     733        if(bcast_buf[i] != (color+1)*split_size) 
     734          bcast_test = 1; 
     735      } 
     736   
     737      int bcast_result; 
     738   
     739      MPI_Reduce(&bcast_test, &bcast_result, 1, MPI_INT, MPI_SUM, 0, comm); 
     740   
     741      MPI_Barrier(split_comm); 
     742      MPI_Comm_free(&split_comm); 
     743       
     744      MPI_Barrier(split_comm2); 
     745      MPI_Comm_free(&split_comm2); 
     746       
     747       
     748      if(bcast_result == 0 && rank == 0)  printf("            \t test MPI_Bcast for split comm\t OK\n"); 
     749      if(bcast_result != 0 && rank == 0)  printf("            \t test MPI_Bcast for split comm\t FAILED %d\n", bcast_result); 
     750       
     751    } 
     752     
     753    MPI_Barrier(comm); 
     754    MPI_Barrier(comm); 
     755    MPI_Barrier(comm); 
     756     
     757    // TESE OF INTERCOMM_CREATE 
     758    { 
     759      MPI_Barrier(comm); 
     760       
     761      int rank, size; 
     762      MPI_Comm_rank(comm, &rank); 
     763      MPI_Comm_size(comm, &size); 
     764       
     765      int tab_color[16] = {2, 2, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1}; 
     766      int tab_key[16]   = {2, 1, 4, 1, 0, 4, 3, 3, 4, 3, 4, 4, 4, 0, 0, 2}; 
     767 
     768      int color = tab_color[rank]; 
     769      int key = tab_key[rank]; 
     770       
     771   
     772      MPI_Comm split_comm; 
     773      MPI_Comm_split(comm, color, key, &split_comm); 
     774 
     775     
     776      int split_rank, split_size; 
     777      MPI_Comm_rank(split_comm, &split_rank); 
     778      MPI_Comm_size(split_comm, &split_size); 
     779 
     780 
     781      printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first); 
     782 
     783      MPI_Barrier(comm); 
     784      MPI_Barrier(comm); 
     785       
     786      if(rank == 0) printf("            \t MPI_Comm_split \t OK\n"); 
     787       
     788      MPI_Barrier(comm); 
     789      MPI_Barrier(comm); 
     790       
     791       
     792       
     793       
     794       
     795      int local_leader = 0; 
     796      int remote_leader = color==2? 13: 4; 
     797 
     798      MPI_Comm peer_comm = comm; 
     799 
     800      MPI_Comm inter_comm; 
     801      MPI_Intercomm_create(split_comm, local_leader, peer_comm, remote_leader, 99, &inter_comm); 
     802       
     803 
     804 
     805      MPI_Barrier(comm); 
     806      MPI_Barrier(comm); 
     807 
     808      MPI_Barrier(split_comm); 
     809      MPI_Comm_free(&split_comm); 
     810 
     811 
     812      /* 
     813      MPI_Barrier(comm); 
     814      if(rank == 0) printf("\tMPI_Intercomm_create OK\n"); 
     815      MPI_Barrier(comm); 
     816 
     817     
     818 
     819      int high=color; 
     820      MPI_Comm intra_comm; 
     821      MPI_Intercomm_merge(inter_comm, high, &intra_comm); 
     822     
     823      int intra_rank, intra_size; 
     824      MPI_Comm_rank(intra_comm, &intra_rank); 
     825      MPI_Comm_size(intra_comm, &intra_size); 
     826 
     827      MPI_Barrier(comm); 
     828      if(rank == 0) printf("\tMPI_Intercomm_merge OK\n"); 
     829      MPI_Barrier(comm); 
     830     
     831     
     832 
     833      //check_test_gatherv(comm); 
     834       
     835      MPI_Barrier(comm); 
     836      MPI_Comm_free(&inter_comm); 
     837      */ 
     838    } 
     839   
    748840    MPI_Barrier(comm); 
    749841    MPI_Comm_free(&comm); 
    750   } 
    751842  } 
    752843 
Note: See TracChangeset for help on using the changeset viewer.