Changeset 2599 for palm/trunk/SOURCE/pmc_child_mod.f90
- Timestamp:
- Nov 1, 2017 1:18:45 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/pmc_child_mod.f90
r2101 r2599 26 26 ! ----------------- 27 27 ! $Id$ 28 ! Some cleanup and commenting improvements only. 29 ! 30 ! 2101 2017-01-05 16:42:31Z suehring 28 31 ! 29 32 ! 2000 2016-08-20 18:09:15Z knoop … … 171 174 CALL MPI_COMM_SIZE( me%model_comm, me%model_npes, istat ) 172 175 CALL MPI_COMM_REMOTE_SIZE( me%inter_comm, me%inter_npes, istat ) 173 174 ! 175 !-- Intra-communicater is used for MPI_GET 176 ! 177 !-- Intra-communicator is used for MPI_GET 176 178 CALL MPI_INTERCOMM_MERGE( me%inter_comm, .TRUE., me%intra_comm, istat ) 177 179 CALL MPI_COMM_RANK( me%intra_comm, me%intra_rank, istat ) 178 180 179 181 ALLOCATE( me%pes(me%inter_npes) ) 180 181 ! 182 !-- Allocate an array of type arraydef for all parent PEs to store information 183 !-- of then transfer array 182 ! 183 !-- Allocate an array of type arraydef for all parent processes to store 184 !-- information of then transfer array 184 185 DO i = 1, me%inter_npes 185 186 ALLOCATE( me%pes(i)%array_list(pmc_max_array) ) … … 201 202 202 203 INTEGER, INTENT(OUT) :: istat !< 203 204 204 ! 205 205 !-- Local variables … … 211 211 212 212 istat = pmc_status_ok 213 214 213 ! 215 214 !-- Check length of array names … … 229 228 230 229 ! 231 !-- Broadca t to all child PEs230 !-- Broadcast to all child processes 232 231 !-- TODO: describe what is broadcast here and why it is done 233 232 CALL pmc_bcast( myname%couple_index, 0, comm=m_model_comm ) … … 236 235 CALL pmc_bcast( myname%childdesc, 0, comm=m_model_comm ) 237 236 CALL pmc_bcast( myname%nameonchild, 0, comm=m_model_comm ) 238 239 ! 240 !-- Broadcat to all parent PEs 237 ! 238 !-- Broadcast to all parent processes 241 239 !-- TODO: describe what is broadcast here and why it is done 242 240 IF ( m_model_rank == 0 ) THEN … … 263 261 264 262 LOGICAL, INTENT(IN), OPTIONAL :: lastentry !< 265 266 263 ! 267 264 !-- Local variables … … 290 287 INTEGER :: i, ierr, i2, j, nr !< 291 288 INTEGER :: indwin !< MPI window object 292 INTEGER :: indwin2 !< MPI window object289 INTEGER :: indwin2 !< MPI window object 293 290 294 291 INTEGER(KIND=MPI_ADDRESS_KIND) :: win_size !< Size of MPI window 1 (in bytes) … … 306 303 CALL MPI_WIN_CREATE( dummy, win_size, iwp, MPI_INFO_NULL, me%intra_comm, & 307 304 indwin, ierr ) 308 309 305 ! 310 306 !-- Open window on parent side 311 307 !-- TODO: why is the next MPI routine called twice?? 312 308 CALL MPI_WIN_FENCE( 0, indwin, ierr ) 313 314 309 ! 315 310 !-- Close window on parent side and open on child side … … 321 316 MPI_INTEGER, indwin, ierr ) 322 317 ENDDO 323 324 318 ! 325 319 !-- MPI_GET is non-blocking -> data in nrele is not available until MPI_FENCE is 326 320 !-- called 327 321 CALL MPI_WIN_FENCE( 0, indwin, ierr ) 328 329 322 ! 330 323 !-- Allocate memory for index array … … 344 337 ALLOCATE( myind(2*winsize) ) 345 338 winsize = 1 346 347 339 ! 348 340 !-- Local buffer used in MPI_GET can but must not be inside the MPI Window. 349 !-- Here, we use a dummy for the MPI window because the parent PEs do not access350 !-- the RMA window via MPI_GET or MPI_PUT341 !-- Here, we use a dummy for the MPI window because the parent processes do 342 !-- not access the RMA window via MPI_GET or MPI_PUT 351 343 CALL MPI_WIN_CREATE( dummy, winsize, iwp, MPI_INFO_NULL, me%intra_comm, & 352 344 indwin2, ierr ) 353 354 345 ! 355 346 !-- MPI_GET is non-blocking -> data in nrele is not available until MPI_FENCE is … … 377 368 ENDIF 378 369 ENDDO 379 380 370 ! 381 371 !-- Don't know why, but this barrier is necessary before we can free the windows … … 406 396 !-- pmc_interface 407 397 CHARACTER(LEN=*), INTENT(OUT) :: myname !< 408 409 398 ! 410 399 !-- Local variables … … 414 403 415 404 next_array_in_list = next_array_in_list + 1 416 417 ! 418 !-- Array names are the same on all child PEs, so take first PE to get the name405 ! 406 !-- Array names are the same on all child PEs, so take first process to 407 !-- get the name 419 408 ape => me%pes(1) 420 421 409 ! 422 410 !-- Check if all arrays have been processed … … 429 417 430 418 myname = ar%name 431 432 419 ! 433 420 !-- Return true if legal array … … 545 532 myindex = 0 546 533 bufsize = 8 547 548 534 ! 549 535 !-- Parent to child direction. 550 536 !-- First stride: compute size and set index 551 537 DO i = 1, me%inter_npes 552 553 538 ape => me%pes(i) 554 539 tag = 200 555 556 540 DO j = 1, ape%nr_arrays 557 558 541 ar => ape%array_list(j) 559 560 542 ! 561 543 !-- Receive index from child … … 564 546 MPI_STATUS_IGNORE, ierr ) 565 547 ar%recvindex = myindex 566 567 548 ! 568 549 !-- Determine max, because child buffer is allocated only once … … 573 554 bufsize = MAX( bufsize, ar%a_dim(1)*ar%a_dim(2) ) 574 555 ENDIF 575 576 556 ENDDO 577 578 ENDDO 579 557 ENDDO 580 558 ! 581 559 !-- Create RMA (one sided communication) data buffer. … … 584 562 CALL pmc_alloc_mem( base_array_pc, bufsize, base_ptr ) 585 563 me%totalbuffersize = bufsize*wp ! total buffer size in byte 586 587 564 ! 588 565 !-- Second stride: set buffer pointer 589 566 DO i = 1, me%inter_npes 590 591 567 ape => me%pes(i) 592 593 568 DO j = 1, ape%nr_arrays 594 569 ar => ape%array_list(j) 595 570 ar%recvbuf = base_ptr 596 571 ENDDO 597 598 ENDDO 599 572 ENDDO 600 573 ! 601 574 !-- Child to parent direction … … 605 578 606 579 DO i = 1, me%inter_npes 607 608 580 ape => me%pes(i) 609 581 tag = 300 610 611 582 DO j = 1, ape%nr_arrays 612 613 583 ar => ape%array_list(j) 614 584 IF( ar%nrdims == 2 ) THEN … … 617 587 arlen = ape%nrele*ar%a_dim(1) 618 588 ENDIF 619 620 589 tag = tag + 1 621 590 rcount = rcount + 1 … … 629 598 ar%sendindex = noindex 630 599 ENDIF 631 632 600 ! 633 601 !-- Maximum of 1024 outstanding requests 634 !-- TODO: explain where this maximum comes from (arbitrary?) 602 !-- TODO: explain where this maximum comes from (arbitrary?). 603 !-- Outstanding = pending? 635 604 IF ( rcount == 1024 ) THEN 636 605 CALL MPI_WAITALL( rcount, req, MPI_STATUSES_IGNORE, ierr ) … … 651 620 652 621 ENDDO 653 654 622 ! 655 623 !-- Create RMA (one sided communication) window for data buffer child to parent … … 670 638 CALL MPI_WIN_FENCE( 0, me%win_parent_child, ierr ) 671 639 CALL MPI_BARRIER( me%intra_comm, ierr ) 672 673 640 ! 674 641 !-- Second stride: set buffer pointer 675 642 DO i = 1, me%inter_npes 676 677 643 ape => me%pes(i) 678 679 644 DO j = 1, ape%nr_arrays 680 681 ar => ape%array_list(j) 682 645 ar => ape%array_list(j) 683 646 IF ( ape%nrele > 0 ) THEN 684 647 ar%sendbuf = C_LOC( base_array_cp(ar%sendindex) ) 685 686 648 ! 687 649 !-- TODO: if this is an error to be really expected, replace the … … 695 657 ENDIF 696 658 ENDIF 697 698 659 ENDDO 699 700 660 ENDDO 701 661 … … 743 703 waittime = t2 - t1 744 704 ENDIF 745 746 705 ! 747 706 !-- Wait for buffer is filled. … … 753 712 754 713 DO ip = 1, me%inter_npes 755 756 714 ape => me%pes(ip) 757 758 715 DO j = 1, ape%nr_arrays 759 760 716 ar => ape%array_list(j) 761 762 717 IF ( ar%nrdims == 2 ) THEN 763 718 nr = ape%nrele … … 765 720 nr = ape%nrele * ar%a_dim(1) 766 721 ENDIF 767 768 722 buf_shape(1) = nr 769 723 CALL C_F_POINTER( ar%recvbuf, buf, buf_shape ) 770 771 724 ! 772 725 !-- MPI passive target RMA … … 780 733 CALL MPI_WIN_UNLOCK( ip-1, me%win_parent_child, ierr ) 781 734 ENDIF 782 783 735 myindex = 1 784 736 IF ( ar%nrdims == 2 ) THEN 785 786 737 CALL C_F_POINTER( ar%data, data_2d, ar%a_dim(1:2) ) 787 788 738 DO ij = 1, ape%nrele 789 739 data_2d(ape%locind(ij)%j,ape%locind(ij)%i) = buf(myindex) 790 740 myindex = myindex + 1 791 741 ENDDO 792 793 742 ELSEIF ( ar%nrdims == 3 ) THEN 794 795 743 CALL C_F_POINTER( ar%data, data_3d, ar%a_dim(1:3) ) 796 797 744 DO ij = 1, ape%nrele 798 745 data_3d(:,ape%locind(ij)%j,ape%locind(ij)%i) = & … … 800 747 myindex = myindex+ar%a_dim(1) 801 748 ENDDO 802 803 ENDIF 804 749 ENDIF 805 750 ENDDO 806 807 751 ENDDO 808 752 … … 849 793 850 794 DO ip = 1, me%inter_npes 851 852 795 ape => me%pes(ip) 853 854 796 DO j = 1, ape%nr_arrays 855 856 797 ar => aPE%array_list(j) 857 798 myindex = 1 858 859 799 IF ( ar%nrdims == 2 ) THEN 860 861 800 buf_shape(1) = ape%nrele 862 801 CALL C_F_POINTER( ar%sendbuf, buf, buf_shape ) 863 802 CALL C_F_POINTER( ar%data, data_2d, ar%a_dim(1:2) ) 864 865 803 DO ij = 1, ape%nrele 866 804 buf(myindex) = data_2d(ape%locind(ij)%j,ape%locind(ij)%i) 867 805 myindex = myindex + 1 868 806 ENDDO 869 870 807 ELSEIF ( ar%nrdims == 3 ) THEN 871 872 808 buf_shape(1) = ape%nrele*ar%a_dim(1) 873 809 CALL C_F_POINTER( ar%sendbuf, buf, buf_shape ) 874 810 CALL C_F_POINTER( ar%data, data_3d, ar%a_dim(1:3) ) 875 876 811 DO ij = 1, ape%nrele 877 812 buf(myindex:myindex+ar%a_dim(1)-1) = & … … 879 814 myindex = myindex + ar%a_dim(1) 880 815 ENDDO 881 882 ENDIF 883 816 ENDIF 884 817 ENDDO 885 886 ENDDO 887 818 ENDDO 888 819 ! 889 820 !-- TODO: Fence might do it, test later
Note: See TracChangeset
for help on using the changeset viewer.