mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Use contiguous derived MPI type to avoid broadcasting counts > 2**31 - 1
This commit is contained in:
parent
277c720f54
commit
ced4c05400
2 changed files with 22 additions and 4 deletions
|
|
@ -50,6 +50,9 @@ if($ENV{FC} MATCHES "(mpi[^/]*|ftn)$")
|
|||
message("-- Detected MPI wrapper: $ENV{FC}")
|
||||
add_definitions(-DMPI)
|
||||
set(MPI_ENABLED TRUE)
|
||||
|
||||
# Get directory containing MPI wrapper
|
||||
get_filename_component(MPI_DIR $ENV{FC} DIRECTORY)
|
||||
endif()
|
||||
|
||||
# Check for Fortran 2008 MPI interface
|
||||
|
|
@ -552,7 +555,7 @@ foreach(test ${TESTS})
|
|||
add_test(NAME ${TEST_NAME}
|
||||
WORKING_DIRECTORY ${TEST_PATH}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $<TARGET_FILE:openmc>
|
||||
--mpi_exec $ENV{MPI_DIR}/bin/mpiexec)
|
||||
--mpi_exec ${MPI_DIR}/mpiexec)
|
||||
else()
|
||||
# Perform a serial test
|
||||
add_test(NAME ${TEST_NAME}
|
||||
|
|
|
|||
|
|
@ -472,8 +472,14 @@ contains
|
|||
#ifdef MPI
|
||||
integer :: n ! size of arrays
|
||||
integer :: mpi_err ! MPI error code
|
||||
integer :: count_per_filter ! number of result values for one filter bin
|
||||
integer(8) :: temp
|
||||
real(8) :: tempr(3) ! temporary array for communication
|
||||
#ifdef MPIF08
|
||||
type(MPI_Datatype) :: result_block
|
||||
#else
|
||||
integer :: result_block
|
||||
#endif
|
||||
#endif
|
||||
|
||||
! Skip if simulation was never run
|
||||
|
|
@ -498,9 +504,18 @@ contains
|
|||
! Broadcast tally results so that each process has access to results
|
||||
if (allocated(tallies)) then
|
||||
do i = 1, size(tallies)
|
||||
n = size(tallies(i) % obj % results)
|
||||
call MPI_BCAST(tallies(i) % obj % results, n, MPI_DOUBLE, 0, &
|
||||
mpi_intracomm, mpi_err)
|
||||
associate (results => tallies(i) % obj % results)
|
||||
! Create a new datatype that consists of all values for a given filter
|
||||
! bin and then use that to broadcast. This is done to minimize the
|
||||
! chance of the 'count' argument of MPI_BCAST exceeding 2**31
|
||||
n = size(results, 3)
|
||||
count_per_filter = size(results, 1) * size(results, 2)
|
||||
call MPI_TYPE_CONTIGUOUS(count_per_filter, MPI_DOUBLE, &
|
||||
result_block, mpi_err)
|
||||
call MPI_TYPE_COMMIT(result_block, mpi_err)
|
||||
call MPI_BCAST(results, n, result_block, 0, mpi_intracomm, mpi_err)
|
||||
call MPI_TYPE_FREE(result_block, mpi_err)
|
||||
end associate
|
||||
end do
|
||||
end if
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue