Skip to content

api/reduce#7

Draft
maxwilliams94 wants to merge 7 commits into
fix_proposed_structurefrom
api/REDUCE
Draft

api/reduce#7
maxwilliams94 wants to merge 7 commits into
fix_proposed_structurefrom
api/REDUCE

Conversation

@maxwilliams94
Copy link
Copy Markdown
Collaborator

MPI_REDUCE wrapped by interface mplib20_reduce - basic (probably wrong) implementations for int_scalar and int_vec (rank 1)

Max Williams added 2 commits February 13, 2021 09:57
- build/ directory
- any compiled objects
Current TODOs (in-file)
* Unravel how MPI_Datatype operates
* Overload for MPI_IN_PLACE?
* Testing
@maxwilliams94 maxwilliams94 added WIP work in progress no-merge don't merge labels Feb 14, 2021
@maxwilliams94 maxwilliams94 marked this pull request as draft February 14, 2021 13:24
…wing overiding of the default master rank within mpilib20_init_finalise.
@AlexBuccheri AlexBuccheri changed the base branch from master to fix_proposed_structure February 17, 2021 16:27
Copy link
Copy Markdown
Owner

@AlexBuccheri AlexBuccheri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done the first pass. I guess you'd really like me to hurry up and finish the MPI testing such that you can start writing tests as you go

Comment thread src/routines/generic_templates.md Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
!> Variable to receive reduced set
type(MPI_Datatype), intent(inout) :: recvbuf
!> MPI Operation
type(MPI_Op), intent(in) :: operation
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to pass the operation. This should be inferable from the input data type.

Copy link
Copy Markdown
Collaborator Author

@maxwilliams94 maxwilliams94 Feb 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would MPI_MAX and MPI_MIN be infered? Same with MPI_PRODUCT and MPI_SUM?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think we could make operation optional and have default behaviour as sum. My feeling is the majority of use cases are sum. Would also be easy to change.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • make operation optional and have sum as default.

Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
Comment thread src/routines/mpilib20_reduce.F90 Outdated
!> Wrapping of the MPI_REDUCE methods
!> TODOs
!> Unravel how MPI_Datatype operates
!> Overload for MPI_IN_PLACE?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure how MPI_IN_PLACE works. For a single communicator, it's a pointless operation. Once they're split, we'd need to consider its use

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MPI_IN_PLACE is actually quite complicated to overload - MPI_IN_PLACE replaces sendbuf for the root process (indicating that the sendbuf and recvbuf are the same) BUT on non-root processes, there needs to be a variable passed via sendbuf. Not sure what this means for overloading for when sendbuf is MPI_IN_PLACE, probably would have MPI_IN_PLACE as an optional logical with logic to ensure correct filling of the (in this case) sendbuf and recvbuf variables for MPI_REDUCE.

https://stackoverflow.com/questions/17741574/in-place-mpi-reduce-crashes-with-openmpi

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, makes sense to ignore in the first instance and add an issue to address. I've never needed to use personally and only seen it recently

  • Create issue

!> Reduces values on all processes to a single value
!> on process defined by process_id
!> TODO usage examples
subroutine mpilib20_reduce_int_scalar(sendbuf, recvbuf, &
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we want to line-split (to keep lines below 90 characters(?)). Here I've split after argument 2 because otherwise one goes over 90, but then operation (potentially being removed soon anyway) and mpi_env are grouped. I've put optional arguments on their own line

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not going over 90 (unless a comment) sounds sensible. I often like to put inputs and outputs on different lines but if we retain a consistent arg ordering with MPI commands, then clearly we can't. In which case do whatever looks neat. Not a fan of putting optionals on their own line.

More broadly we should introduce fprettify and set it up how we like, then we can just run it to apply consistent formatting

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 90 characters sounds good. Do what you think looks readable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it neat without putting optional arguments on their own line.

Sounds good re fprettify. We should get a config file written for it relatively soon. Once I commit these PR changes I'll have a good and see what get produced.

- remove generic_template file - useful locally if useful during development
- mpilib20_REDUCE interface -> mpilib20_reduce
- global imports moved to module scope
- recvbuf (receiving buffer) for integer case -> intent(out)
- use_rank (integer) renamed to process_id. Persistent rank is then renamed to process in calls.
- reduce verbosity when inferring dimension of buffers. Use size(recvbuf) rather than storing in `count` variable.
- add assert to check that sendbuf and recvbuf are equal dimension
- update todos at module docs (remaining types etc)
- update todos at subroutine level: usage examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-merge don't merge WIP work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants