allocate the resources of this and load the probability distribution from arr into this want to use for sampling
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(AliasSampler_t), | intent(inout) | :: | this | |||
| integer, | intent(in) | :: | rank_with_info |
The intra-node rank that contains the weights to be used all other arr of all other ranks are ignored (and can be allocated with size 0). |
||
| real(kind=dp), | intent(in) | :: | arr(:) |
subroutine setup_AliasSampler_t(this, rank_with_info, arr) class(AliasSampler_t), intent(inout) :: this integer, intent(in) :: rank_with_info !! The **intra-node** rank that contains the weights to be used !! all other arr of all other ranks are ignored (and can be allocated with size 0). real(dp), intent(in) :: arr(:) integer :: ierr block logical :: early_return(1) early_return = near_zero(sum(arr)) call MPI_Bcast(early_return, size(early_return, kind=MPIArg), MPI_LOGICAL, rank_with_info, mpi_comm_intra, ierr) if (early_return(1)) then ! probs defaults to null(), so it is not associated at this point (i.e. in a well-defined state) return end if end block ! initialize the alias table call this%table%setup(rank_with_info, arr) block integer(int64) :: arrSize(1) arrSize = size(arr, kind=int64) call MPI_Bcast(arrSize, size(arrSize, kind=MPIArg), MPI_INTEGER8, rank_with_info, mpi_comm_intra, ierr) ! allocate the probabilities call this%probs%shared_alloc(arrSize(1)) end block ! set the probabilities call this%init_probs(rank_with_info, arr) call this%probs%sync() end subroutine setup_AliasSampler_t