--------------------------------------------------------------------------------------------------------------------- Explicits patch movement regarding new patch distribution stored in smpi->patch_count - compute send_patch_id_ - compute recv_patch_id_ - create empty (not really, created like at t0) new patch in recv_patches_ -----------------------------------------------------------------------
| 2967 | // - create empty (not really, created like at t0) new patch in recv_patches_ |
| 2968 | // --------------------------------------------------------------------------------------------------------------------- |
| 2969 | void VectorPatch::createPatches( Params ¶ms, SmileiMPI *smpi, SimWindow *simWindow ) |
| 2970 | { |
| 2971 | unsigned int n_moved( 0 ); |
| 2972 | recv_patches_.resize( 0 ); |
| 2973 | |
| 2974 | // Set Index of the 1st patch of the vector yet on current MPI rank |
| 2975 | // Is this really necessary ? It should be done already ... |
| 2976 | setRefHindex(); |
| 2977 | |
| 2978 | // Current number of patch |
| 2979 | int nPatches_now = this->size() ; |
| 2980 | |
| 2981 | // When going to openMP, these two vectors must be stored by patch and not by vectorPatch. |
| 2982 | recv_patch_id_.clear(); |
| 2983 | send_patch_id_.clear(); |
| 2984 | |
| 2985 | // istart = Index of the futur 1st patch |
| 2986 | int istart( 0 ); |
| 2987 | for( int irk=0 ; irk<smpi->getRank() ; irk++ ) { |
| 2988 | istart += smpi->patch_count[irk]; |
| 2989 | } |
| 2990 | |
| 2991 | // recv_patch_id_ = vector of the hindex this process must own at the end of the exchange. |
| 2992 | for( int ipatch=0 ; ipatch<smpi->patch_count[smpi->getRank()] ; ipatch++ ) { |
| 2993 | recv_patch_id_.push_back( istart+ipatch ); |
| 2994 | } |
| 2995 | |
| 2996 | |
| 2997 | // Loop on current patches to define patch to send |
| 2998 | for( int ipatch=0 ; ipatch < nPatches_now ; ipatch++ ) { |
| 2999 | //if current hindex < future refHindex OR current hindex > future last hindex... |
| 3000 | if( ( refHindex_+ipatch < recv_patch_id_[0] ) || ( refHindex_+ipatch > recv_patch_id_.back() ) ) { |
| 3001 | // Put this patch in the send list. |
| 3002 | send_patch_id_.push_back( ipatch ); |
| 3003 | } |
| 3004 | } |
| 3005 | |
| 3006 | |
| 3007 | // Backward loop on future patches to define suppress patch in receive list |
| 3008 | // before this loop, recv_patch_id_ stores all patches index define in SmileiMPI::patch_count |
| 3009 | int existing_patch_id = -1; |
| 3010 | for( int ipatch=recv_patch_id_.size()-1 ; ipatch>=0 ; ipatch-- ) { |
| 3011 | //if future patch hindex >= current refHindex AND future patch hindex <= current last hindex |
| 3012 | if( ( recv_patch_id_[ipatch]>=refHindex_ ) && ( recv_patch_id_[ipatch] <= refHindex_ + nPatches_now - 1 ) ) { |
| 3013 | //Store an existing patch id for cloning. |
| 3014 | existing_patch_id = recv_patch_id_[ipatch]; |
| 3015 | //Remove this patch from the receive list because I already own it. |
| 3016 | recv_patch_id_.erase( recv_patch_id_.begin()+ipatch ); |
| 3017 | } |
| 3018 | } |
| 3019 | |
| 3020 | |
| 3021 | // Get an existing patch that will be used for cloning |
| 3022 | if( existing_patch_id<0 ) { |
| 3023 | ERROR( "No patch to clone. This should never happen!" ); |
| 3024 | } |
| 3025 | Patch *existing_patch = ( *this )( existing_patch_id-refHindex_ ); |
| 3026 |
no test coverage detected