[Trilinos-Users] int, Thyra::Ordinal: Thyra::create_Comm, Teuchos::Comm incompatibility?

Baker, Christopher G. bakercg at ornl.gov
Tue Dec 8 09:26:56 MST 2009

Hello all.

The ordinal type of a Teuchos::Comm specifies the length of messages that can be passed; specifically, the local size of a receive, send,  We didn't want to specify Comm ordinals as a template parameter to Tpetra, so all Tpetra objects were hardcoded to take a Comm<int>. It may be that it should have been set to size_t or some configure-time type instead; this issue should be revisited. In the meantime, I'm not concerned, as the underlying MPI interface for most (all?) of our Comm implementations defines this as an int.

In the short term, the easiest thing for you may be to steal the body of the Thyra::create_Comm() and rewrite it to encapsulate the communicator in a Teuchos::Comm<int>, like the create_CommInt() method that I have included below. (Note, if you know you are in an MPI environment, you can ignore the SerialComm section. The set_extra_data bit references the Epetra_Comm object to that it isn't deleted until after the newly-created Teuchos::Comm is deleted; that bit may not be necessary either).

Teuchos::RCP<const Teuchos::Comm<int> >
create_CommInt( const RCP<const Epetra_Comm> &epetraComm )
  using Teuchos::RCP;
  using Teuchos::rcp;
  using Teuchos::rcp_dynamic_cast;
  using Teuchos::set_extra_data;

  RCP<const Epetra_SerialComm>
    serialEpetraComm = rcp_dynamic_cast<const Epetra_SerialComm>(epetraComm);
  if( serialEpetraComm.get() ) {
    RCP<const Teuchos::SerialComm<int> >
      serialComm = rcp(new Teuchos::SerialComm<int>());
    set_extra_data( serialEpetraComm, "serialEpetraComm", Teuchos::inOutArg(serialComm) );
    return serialComm;

#ifdef HAVE_MPI

  RCP<const Epetra_MpiComm>
    mpiEpetraComm = rcp_dynamic_cast<const Epetra_MpiComm>(epetraComm);
  if( mpiEpetraComm.get() ) {
    RCP<const Teuchos::OpaqueWrapper<MPI_Comm> >
      rawMpiComm = Teuchos::opaqueWrapper(mpiEpetraComm->Comm());
    set_extra_data( mpiEpetraComm, "mpiEpetraComm", Teuchos::inOutArg(rawMpiComm) );
    RCP<const Teuchos::MpiComm<int> >
      mpiComm = rcp(new Teuchos::MpiComm<int>(rawMpiComm));
    return mpiComm;

#endif // HAVE_MPI

  // If you get here then the failed!
  return Teuchos::null;

Another possibity would be to add functionality to Teuchos to allow a Comm to return an equivalent Comm bound to a different Ordinal type.


On 12/8/09 10:49 AM, "Nico Schlömer" <nico.schloemer at ua.ac.be> wrote:


I'm bumping into problems here on a machine where Thyra::Ordinal is "long int" instead of the (regular?) "int".

I'm specifically creating a Teuchos::Comm via Thyra::create_Comm, and get a Teuchos::Comm<long int>. I'm unsuccessful in instantiating a Tpetra::Map<long int> with this communicator, which is because the none of the Tpetra::Map is templated in it's Teuchos::Comm argument, but instead demand a Teuchos::Comm<int>.

Would it possibly make sense to change this for GlobalOrdinal, or is there another way for creating a Tpetra::Map out of a Thyra::create_Comm?


More information about the Trilinos-Users mailing list