Dealii: pass MPI_Comm by value or reference?

Created on 26 Oct 2020  路  6Comments  路  Source: dealii/dealii

We currently have a mixture of ways to pass an MPI_Comm to functions.
Unscientific statistic:

$ git grep MPI_Comm include/ | wc -l
394
$ git grep MPI_Comm include/ | grep "&" | wc -l
258

pros for by value:

  • it is likely (always?) an int, so passing by value if more efficient

pros for by ref:

  • we use it in more places
  • we don't make assumptions about the size of the struct

I don't really care which way we go, but being consistent makes sense.

Before I go and make all of them const &: any opinions?

(prompted by #11074)

Most helpful comment

I think we should follow the C convention

Alright, I am proposing a vote:

  • const & :+1:
  • by value: :-1:
  • I don't care :rocket:

All 6 comments

I guess in terms of performance it doesn't really matter much. I slightly prefer passing by reference since it is an opaque type.

I guess in terms of performance it doesn't really matter much.

That is true. I did not mean to imply that it does.

It's a C-style data type, so it must be copyable (all C data types are copyable). I think we should follow the C convention: Pass by value. That's what the MPI functions themselves do.

I think we should follow the C convention

Alright, I am proposing a vote:

  • const & :+1:
  • by value: :-1:
  • I don't care :rocket:

Any more opinions about this very important question? :-)

yay! :+1:

Was this page helpful?
0 / 5 - 0 ratings