Skip to content

Commit

Permalink
mpif08: add remaining datatype constructors
Browse files Browse the repository at this point in the history
needing bigcount variants:
create_hindexed
create_hindexed_block
create_hvector
create_indexed_block

fix a problem in the fortran data type py code.
add a AINT_COUNT in type for fortran too.

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
  • Loading branch information
hppritcha committed Sep 28, 2024
1 parent 22c44cd commit 3006db4
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 173 deletions.
22 changes: 21 additions & 1 deletion ompi/mpi/bindings/ompi_bindings/fortran_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def use(self):
return [('mpi_f08_types', 'MPI_ADDRESS_KIND')]

def c_parameter(self):
count_type = 'MPI_Count' if self.bigcount else 'MPI_Fint'
count_type = 'MPI_Count' if self.bigcount else 'MPI_Aint'
return f'{count_type} *{self.name}'


Expand Down Expand Up @@ -503,6 +503,26 @@ def c_parameter(self):
return f'MPI_Aint *{self.name}'


@FortranType.add('AINT_COUNT')
class AintCountTypeIn(FortranType):
"""AINT/COUNT type with ININTENT"""
def declare(self):
if self.bigcount:
return f'INTEGER(KIND=MPI_COUNT_KIND), INTENT(IN) :: {self.name}'
else:
return f'INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: {self.name}'

def use(self):
if self.bigcount:
return [('mpi_f08_types', 'MPI_COUNT_KIND')]
else:
return [('mpi_f08_types', 'MPI_ADDRESS_KIND')]

def c_parameter(self):
type_ = 'MPI_Count' if self.bigcount else 'MPI_Aint'
return f'{type_} *{self.name}'


@FortranType.add('AINT_COUNT_INOUT')
class AintCountTypeInOut(FortranType):
"""AINT/COUNT type with INOUT INTENT"""
Expand Down
4 changes: 0 additions & 4 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ mpi_api_files = \
type_create_f90_complex_f08.F90 \
type_create_f90_integer_f08.F90 \
type_create_f90_real_f08.F90 \
type_create_hindexed_f08.F90 \
type_create_hvector_f08.F90 \
type_create_indexed_block_f08.F90 \
type_create_hindexed_block_f08.F90 \
type_create_keyval_f08.F90 \
type_create_resized_f08.F90 \
type_delete_attr_f08.F90 \
Expand Down
6 changes: 5 additions & 1 deletion ompi/mpi/fortran/use-mpi-f08/Makefile.prototype_files
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ complete_prototype_files = \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_darray.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_get_true_extent.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_subarray.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_struct.c.in
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_struct.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_hindexed.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_hindexed_block.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_indexed_block.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/type_create_hvector.c.in

# TODO: Is there any way to get EXTRA_DIST to work with absolute paths? Or,
# better yet, is there some way to make these dependencies a little
Expand Down
52 changes: 0 additions & 52 deletions ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -473,58 +473,6 @@ subroutine MPI_Type_commit_f08(datatype,ierror)
end subroutine MPI_Type_commit_f08
end interface MPI_Type_commit

interface MPI_Type_create_hindexed
subroutine MPI_Type_create_hindexed_f08(count,array_of_blocklengths, &
array_of_displacements,oldtype,newtype,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND
implicit none
INTEGER, INTENT(IN) :: count
INTEGER, INTENT(IN) :: array_of_blocklengths(count)
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: array_of_displacements(count)
TYPE(MPI_Datatype), INTENT(IN) :: oldtype
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Type_create_hindexed_f08
end interface MPI_Type_create_hindexed

interface MPI_Type_create_hvector
subroutine MPI_Type_create_hvector_f08(count,blocklength,stride,oldtype,newtype,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND
implicit none
INTEGER, INTENT(IN) :: count, blocklength
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: stride
TYPE(MPI_Datatype), INTENT(IN) :: oldtype
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Type_create_hvector_f08
end interface MPI_Type_create_hvector

interface MPI_Type_create_indexed_block
subroutine MPI_Type_create_indexed_block_f08(count,blocklength, &
array_of_displacements,oldtype,newtype,ierror)
use :: mpi_f08_types, only : MPI_Datatype
implicit none
INTEGER, INTENT(IN) :: count, blocklength
INTEGER, INTENT(IN) :: array_of_displacements(count)
TYPE(MPI_Datatype), INTENT(IN) :: oldtype
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Type_create_indexed_block_f08
end interface MPI_Type_create_indexed_block

interface MPI_Type_create_hindexed_block
subroutine MPI_Type_create_hindexed_block_f08(count,blocklength, &
array_of_displacements,oldtype,newtype,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND
implicit none
INTEGER, INTENT(IN) :: count, blocklength
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: array_of_displacements(count)
TYPE(MPI_Datatype), INTENT(IN) :: oldtype
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Type_create_hindexed_block_f08
end interface MPI_Type_create_hindexed_block

interface MPI_Type_create_resized
subroutine MPI_Type_create_resized_f08(oldtype,lb,extent,newtype,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND
Expand Down
46 changes: 46 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/type_create_hindexed.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

PROTOTYPE VOID type_create_hindexed(COUNT count,
COUNT_ARRAY array_of_blocklengths,
AINT_COUNT_ARRAY array_of_displacements,
DATATYPE oldtype,
DATATYPE_OUT newtype)
{
int c_ierr;
MPI_Datatype c_old = PMPI_Type_f2c(*oldtype);
MPI_Datatype c_new;
OMPI_ARRAY_NAME_DECL(array_of_blocklengths);

OMPI_ARRAY_FINT_2_INT(array_of_blocklengths, *count);

c_ierr = @INNER_CALL@(OMPI_FINT_2_INT(*count),
OMPI_ARRAY_NAME_CONVERT(array_of_blocklengths),
array_of_displacements, c_old,
&c_new);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

if (MPI_SUCCESS == c_ierr) {
*newtype = PMPI_Type_c2f(c_new);
}

OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_blocklengths);
}
33 changes: 33 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/type_create_hindexed_block.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2012 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2012 Inria. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/


PROTOTYPE VOID type_create_hindexed_block(COUNT count, COUNT blocklength,
AINT_COUNT_ARRAY array_of_displacements,
DATATYPE oldtype, DATATYPE_OUT newtype)
{
int c_ierr;
MPI_Datatype c_old = PMPI_Type_f2c(*oldtype);
MPI_Datatype c_new;

c_ierr = @INNER_CALL@(OMPI_FINT_2_INT(*count),
OMPI_FINT_2_INT(*blocklength),
array_of_displacements,
c_old, &c_new);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

if (MPI_SUCCESS == c_ierr) {
*newtype = PMPI_Type_c2f(c_new);
}
}
30 changes: 0 additions & 30 deletions ompi/mpi/fortran/use-mpi-f08/type_create_hindexed_block_f08.F90

This file was deleted.

30 changes: 0 additions & 30 deletions ompi/mpi/fortran/use-mpi-f08/type_create_hindexed_f08.F90

This file was deleted.

39 changes: 39 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/type_create_hvector.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

PROTOTYPE VOID type_create_hvector(COUNT count, COUNT blocklength,
AINT_COUNT stride, DATATYPE oldtype,
DATATYPE_OUT newtype)
{
int c_ierr;
MPI_Datatype c_old = PMPI_Type_f2c(*oldtype);
MPI_Datatype c_new;

c_ierr = @INNER_CALL@(OMPI_FINT_2_INT(*count),
OMPI_FINT_2_INT(*blocklength),
*stride,
c_old, &c_new);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

if (MPI_SUCCESS == c_ierr) {
*newtype = PMPI_Type_c2f(c_new);
}
}
27 changes: 0 additions & 27 deletions ompi/mpi/fortran/use-mpi-f08/type_create_hvector_f08.F90

This file was deleted.

45 changes: 45 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/type_create_indexed_block.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

PROTOTYPE VOID type_create_indexed_block(COUNT count, COUNT blocklength,
COUNT_ARRAY array_of_displacements,
DATATYPE oldtype, DATATYPE_OUT newtype)
{
int c_ierr;
MPI_Datatype c_old = PMPI_Type_f2c(*oldtype);
MPI_Datatype c_new;
OMPI_ARRAY_NAME_DECL(array_of_displacements);

OMPI_ARRAY_FINT_2_INT(array_of_displacements, *count);

c_ierr = @INNER_CALL@(OMPI_FINT_2_INT(*count),
OMPI_FINT_2_INT(*blocklength),
OMPI_ARRAY_NAME_CONVERT(array_of_displacements),
c_old, &c_new);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

if (MPI_SUCCESS == c_ierr) {
*newtype = PMPI_Type_c2f(c_new);
}

OMPI_ARRAY_FINT_2_INT_CLEANUP(array_of_displacements);
}

Loading

0 comments on commit 3006db4

Please sign in to comment.