-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from aradi/stage-1.3
Release 1.3
- Loading branch information
Showing
19 changed files
with
423 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.2.0 | ||
1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
#:include 'mpifx.fypp' | ||
#:set TYPES = NUMERIC_TYPES | ||
|
||
!> Contains routined for MPI shared memory. | ||
module mpifx_win_module | ||
use mpifx_common_module | ||
use iso_c_binding, only : c_ptr, c_f_pointer | ||
implicit none | ||
private | ||
|
||
public :: mpifx_win | ||
|
||
!> MPI shared memory window with some additional information. | ||
type mpifx_win | ||
private | ||
integer, public :: id !< Window id. | ||
integer :: comm_id !< Communicator id. | ||
contains | ||
!> Initializes an MPI shared memory window. | ||
#:for TYPE in TYPES | ||
generic :: allocate_shared => mpifx_win_allocate_shared_${TYPE_ABBREVS[TYPE]}$ | ||
#:endfor | ||
|
||
#:for TYPE in TYPES | ||
procedure, private :: mpifx_win_allocate_shared_${TYPE_ABBREVS[TYPE]}$ | ||
#:endfor | ||
|
||
!> Locks a shared memory segment. | ||
procedure :: lock => mpifx_win_lock | ||
|
||
!> Unlocks a shared memory segment. | ||
procedure :: unlock => mpifx_win_unlock | ||
|
||
!> Synchronizes shared memory across MPI ranks. | ||
procedure :: sync => mpifx_win_sync | ||
|
||
!> Deallocates memory associated with a shared memory segment. | ||
procedure :: free => mpifx_win_free | ||
|
||
end type mpifx_win | ||
|
||
contains | ||
|
||
#:def mpifx_win_allocate_shared_template(SUFFIX, TYPE) | ||
|
||
!> Initialized a window handle and returns a pointer to the address associated with a shared memory segment. | ||
!! | ||
!! \param self Handle of the shared memory window on return. | ||
!! \param mycomm MPI communicator. | ||
!! \param length Number of elements of type ${TYPE}$ in the shared memory window. | ||
!! \param shared_data Pointer to the shared data array of length 'length' on return. | ||
!! \param error Optional error code on return. | ||
!! | ||
!! \see MPI documentation (\c MPI_WIN_ALLOCATE_SHARED) | ||
!! | ||
subroutine mpifx_win_allocate_shared_${SUFFIX}$(self, mycomm, length, shared_data, error) | ||
class(mpifx_win), intent(out) :: self | ||
class(mpifx_comm), intent(in) :: mycomm | ||
integer, intent(in) :: length | ||
${TYPE}$, pointer, intent(out) :: shared_data(:) | ||
integer, intent(out), optional :: error | ||
|
||
integer :: disp_unit, error0, error1 | ||
integer(MPI_ADDRESS_KIND) :: local_length | ||
type(c_ptr) :: baseptr | ||
|
||
disp_unit = storage_size(shared_data) / 8 | ||
|
||
local_length = 0 | ||
if (mycomm%lead) then | ||
local_length = int(length, kind=MPI_ADDRESS_KIND) * disp_unit | ||
end if | ||
|
||
call mpi_win_allocate_shared(local_length, disp_unit, MPI_INFO_NULL, mycomm%id, baseptr, self%id, error0) | ||
call handle_errorflag(error0, "MPI_WIN_ALLOCATE_SHARED in mpifx_win_allocate_shared_${SUFFIX}$", error) | ||
|
||
call mpi_win_shared_query(self%id, 0, local_length, disp_unit, baseptr, error1) | ||
call handle_errorflag(error1, "MPI_WIN_SHARED_QUERY in mpifx_win_allocate_shared_${SUFFIX}$", error) | ||
|
||
self%comm_id = mycomm%id | ||
call c_f_pointer(baseptr, shared_data, [length]) | ||
|
||
end subroutine mpifx_win_allocate_shared_${SUFFIX}$ | ||
|
||
#:enddef mpifx_win_allocate_shared_template | ||
|
||
!> Locks a shared memory segment. | ||
!! | ||
!! \param self Handle of the shared memory window. | ||
!! \param error Optional error code on return. | ||
!! | ||
!! \see MPI documentation (\c MPI_WIN_LOCK_ALL) | ||
!! | ||
subroutine mpifx_win_lock(self, error) | ||
class(mpifx_win), intent(inout) :: self | ||
integer, intent(out), optional :: error | ||
|
||
integer :: error0 | ||
|
||
call mpi_win_lock_all(MPI_MODE_NOCHECK, self%id, error0) | ||
call handle_errorflag(error0, "MPI_WIN_LOCK_ALL in mpifx_win_lock", error) | ||
|
||
end subroutine mpifx_win_lock | ||
|
||
!> Unlocks a shared memory segment. | ||
!! | ||
!! \param self Handle of the shared memory window. | ||
!! \param error Optional error code on return. | ||
!! | ||
!! \see MPI documentation (\c MPI_WIN_UNLOCK_ALL) | ||
!! | ||
subroutine mpifx_win_unlock(self, error) | ||
class(mpifx_win), intent(inout) :: self | ||
integer, intent(out), optional :: error | ||
|
||
integer :: error0 | ||
|
||
call mpi_win_unlock_all(self%id, error0) | ||
call handle_errorflag(error0, "MPI_WIN_UNLOCK_ALL in mpifx_win_unlock", error) | ||
|
||
end subroutine mpifx_win_unlock | ||
|
||
!> Synchronizes shared memory across MPI ranks. | ||
!! | ||
!! \param self Handle of the shared memory window. | ||
!! \param error Optional error code on return. | ||
!! | ||
!! \see MPI documentation (\c MPI_WIN_SYNC) | ||
!! | ||
subroutine mpifx_win_sync(self, error) | ||
class(mpifx_win), intent(inout) :: self | ||
integer, intent(out), optional :: error | ||
|
||
integer :: error0, error1 | ||
|
||
call mpi_win_sync(self%id, error0) | ||
call handle_errorflag(error0, "MPI_WIN_SYNC in mpifx_win_sync", error) | ||
|
||
call mpi_barrier(self%comm_id, error1) | ||
call handle_errorflag(error1, "MPI_BARRIER in mpifx_win_sync", error) | ||
|
||
end subroutine mpifx_win_sync | ||
|
||
!> Deallocates memory associated with a shared memory segment. | ||
!! | ||
!! \param self Handle of the shared memory window. | ||
!! \param error Optional error code on return. | ||
!! | ||
!! \see MPI documentation (\c MPI_WIN_FREE) | ||
!! | ||
subroutine mpifx_win_free(self, error) | ||
class(mpifx_win), intent(inout) :: self | ||
integer, intent(out), optional :: error | ||
|
||
integer :: error0 | ||
|
||
call mpi_win_free(self%id, error0) | ||
call handle_errorflag(error0, "MPI_WIN_FREE in mpifx_win_free", error) | ||
|
||
end subroutine mpifx_win_free | ||
|
||
|
||
#:for TYPE in TYPES | ||
#:set FTYPE = FORTRAN_TYPES[TYPE] | ||
#:set SUFFIX = TYPE_ABBREVS[TYPE] | ||
|
||
$:mpifx_win_allocate_shared_template(SUFFIX, FTYPE) | ||
|
||
#:endfor | ||
|
||
end module mpifx_win_module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
set(targets | ||
set(tested | ||
test_allgather | ||
test_allgatherv | ||
test_allgatherv) | ||
|
||
set(targets | ||
${tested} | ||
test_allreduce | ||
test_bcast | ||
test_comm_split | ||
test_comm_split_type | ||
test_gather | ||
test_gatherv | ||
test_reduce | ||
test_scatter | ||
test_scatterv) | ||
test_scatterv | ||
test_win_shared_mem) | ||
|
||
set(sources-helper | ||
testhelper.f90) | ||
|
||
add_library(mpifxtesthelp ${sources-helper}) | ||
target_link_libraries(mpifxtesthelp PRIVATE MPI::MPI_Fortran MpiFx) | ||
|
||
foreach(target IN LISTS targets) | ||
add_executable(${target} ${target}.f90) | ||
target_link_libraries(${target} MpiFx) | ||
target_link_libraries(${target} MpiFx mpifxtesthelp) | ||
endforeach() | ||
|
||
foreach(target IN LISTS tested) | ||
add_test(NAME ${target} | ||
COMMAND ${MPIEXEC_EXECUTABLE} | ||
${MPIEXEC_NUMPROC_FLAG} | ||
${MPIEXEC_MAX_NUMPROCS} | ||
${MPIEXEC_PREFLAGS} | ||
${CMAKE_CURRENT_BINARY_DIR}/${target} | ||
${MPIEXEC_POSTFLAGS}) | ||
set_tests_properties(${target} PROPERTIES | ||
# test cases generate this on stdOut | ||
PASS_REGULAR_EXPRESSION "TestPASSED") | ||
set_tests_properties(${target} PROPERTIES | ||
# test cases generate this on stdOut | ||
FAIL_REGULAR_EXPRESSION "TestFAILED") | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.