diff --git a/lib/mpifx_constants.fpp b/lib/mpifx_constants.fpp index 2266e01..48ff532 100644 --- a/lib/mpifx_constants.fpp +++ b/lib/mpifx_constants.fpp @@ -10,7 +10,7 @@ module mpifx_constants_module public :: MPI_MODE_NOSTORE, MPI_MODE_NOPUT, MPI_MODE_NOPRECEDE, MPI_MODE_NOSUCCEED public :: MPI_THREAD_SINGLE, MPI_THREAD_FUNNELED, MPI_THREAD_SERIALIZED, MPI_THREAD_MULTIPLE public :: MPI_COMM_TYPE_SHARED - public :: MPIFX_UNHANDLED_ERROR, MPIFX_ASSERT_FAILED + public :: MPIFX_UNHANDLED_ERROR, MPIFX_ASSERT_FAILED, MPIFX_SIZE_T !> Exit code for errors which were not caught due to missing optional arguments @@ -19,6 +19,8 @@ module mpifx_constants_module !> Exit code for failed assertions integer, parameter :: MPIFX_ASSERT_FAILED = 2 + integer, parameter :: MPIFX_SIZE_T = MPI_ADDRESS_KIND + end module mpifx_constants_module !> \endcond diff --git a/lib/mpifx_win.fpp b/lib/mpifx_win.fpp index f36eaf2..ef0c9f4 100644 --- a/lib/mpifx_win.fpp +++ b/lib/mpifx_win.fpp @@ -1,9 +1,11 @@ #:include 'mpifx.fypp' #:set TYPES = NUMERIC_TYPES +#:set INT_TYPES = ['int32', 'int64'] !> Contains routined for MPI shared memory windows. module mpifx_win_module use mpifx_common_module + use mpifx_constants_module, only : MPIFX_SIZE_T use iso_c_binding, only : c_ptr, c_f_pointer implicit none private @@ -18,11 +20,15 @@ module mpifx_win_module contains !> Initializes an MPI shared memory window. #:for TYPE in TYPES - generic :: allocate_shared => mpifx_win_allocate_shared_${TYPE_ABBREVS[TYPE]}$ + #:for INT_TYPE in INT_TYPES + generic :: allocate_shared => mpifx_win_allocate_shared_${TYPE_ABBREVS[TYPE]}$_${INT_TYPE}$ + #:endfor #:endfor #:for TYPE in TYPES - procedure, private :: mpifx_win_allocate_shared_${TYPE_ABBREVS[TYPE]}$ + #:for INT_TYPE in INT_TYPES + procedure, private :: mpifx_win_allocate_shared_${TYPE_ABBREVS[TYPE]}$_${INT_TYPE}$ + #:endfor #:endfor !> Locks a shared memory segment for remote access. @@ -44,7 +50,7 @@ module mpifx_win_module contains -#:def mpifx_win_allocate_shared_template(SUFFIX, TYPE) +#:def mpifx_win_allocate_shared_template(SUFFIX, TYPE, ADDRESS_KIND) !> Initialized a window handle and returns a pointer to the address associated with a shared !> memory segment. @@ -64,9 +70,9 @@ contains & local_length, local_pointer, error) class(mpifx_win), intent(out) :: self class(mpifx_comm), intent(in) :: mycomm - integer, intent(in) :: global_length + integer${ADDRESS_KIND}$, intent(in) :: global_length ${TYPE}$, pointer, intent(out) :: global_pointer(:) - integer, intent(in), optional :: local_length + integer${ADDRESS_KIND}$, intent(in), optional :: local_length ${TYPE}$, pointer, intent(out), optional :: local_pointer(:) integer, intent(out), optional :: error @@ -211,9 +217,11 @@ contains #:for TYPE in TYPES #:set FTYPE = FORTRAN_TYPES[TYPE] - #:set SUFFIX = TYPE_ABBREVS[TYPE] - $:mpifx_win_allocate_shared_template(SUFFIX, FTYPE) + #:for ADDRESS_KIND, INT_TYPE in zip(['', '(MPIFX_SIZE_T)'], INT_TYPES) + #:set SUFFIX = TYPE_ABBREVS[TYPE] + '_' + INT_TYPE + $:mpifx_win_allocate_shared_template(SUFFIX, FTYPE, ADDRESS_KIND) + #:endfor #:endfor diff --git a/test/test_win_shared_mem.f90 b/test/test_win_shared_mem.f90 index fbad591..ead4583 100644 --- a/test/test_win_shared_mem.f90 +++ b/test/test_win_shared_mem.f90 @@ -5,7 +5,9 @@ program test_win_shared_mem type(mpifx_comm) :: globalcomm, nodecomm type(mpifx_win) :: win integer, parameter :: sample_value = 42, size_rank_0 = 7, size_rank_other = 4 - integer :: global_length, local_length, rank, ii + integer(MPIFX_SIZE_T) :: global_length, local_length + integer :: global_length_int32, local_length_int32 + integer :: rank, ii integer, pointer :: global_pointer(:), local_pointer(:) call mpifx_init() @@ -77,6 +79,13 @@ program test_win_shared_mem end if end do + call win%free() + + ! Initialize again with int32 sizes + global_length_int32 = global_length + local_length_int32 = local_length + call win%allocate_shared(nodecomm, global_length_int32, global_pointer, local_length_int32, local_pointer) + call win%free() call mpifx_finalize()