[Trilinos-Users] Tpetra Preference for "long long" GlobalOrdinal type

Hoemmen, Mark mhoemme at sandia.gov
Mon Dec 5 01:07:01 EST 2016

> On Dec 2, 2016, at 4:46 PM, "trilinos-users-request at trilinos.org" <trilinos-users-request at trilinos.org> wrote:
> Date: Thu, 10 Nov 2016 17:14:36 -0600
> From: "Corey A. Henderson" <cahenderson at wisc.edu>
> To: trilinos-users at trilinos.org
> Subject: [Trilinos-Users] TPetra Preference for "long long" Global
>    Ordinal    Type
> I was looking into why I had trouble linking with TPetra when I chose
> unsigned Global Ordinal types
> and explicit template instantiation, and found this:
> https://github.com/trilinos/Trilinos/blob/master/packages/tpetra/doc/FAQ.txt
> It indicates that unsigned ordinals are not preferred. Can someone
> explain why that is? Is there some use case I don't see that leads to
> negative global ordinals?

1. Signed integers generally perform better in for loops.

2. It takes care to write a "count-down" loop that is correct for unsigned integers.  Signed integers let you write the obvious "i >= 0" test.

3. I don't like promising support for types that don't get regularly tested.  

To clarify the last point: Enabling every possible GlobalOrdinal type increases build time.  This is true whether or not explicit template instantiation is enabled.  Thus, we limit the default set of enabled GlobalOrdinal types to the most commonly wanted types.  Most users want GlobalOrdinal = int, long, or long long.  I prefer long long (guaranteed >= 64 bits; long is not!).

If I had my choice, GlobalOrdinal wouldn't even be a template parameter.  You would get int64_t (or long long, not necessarily the same thing!) and that's it.  However, I inherited Tpetra with all those template parameters and I needed to maintain them for backwards compatibility, so there they are.

GlobalOrdinal is not a trivial template parameter, like T in std::vector<T>.  I can't just allow any old type there.  If I allow a type, I need to test it regularly in order to make sure it works.  If I happen to allow some unsigned GlobalOrdinal types, it's only because some key user insisted upon it.  They are responsible for maintaining and testing those types.  Unsigned GlobalOrdinal types are NOT enabled by default.

If you want to enable unsigned GlobalOrdinal types, read the FAQ that you referenced for instructions.  This is true whether or not explicit template instantiation is enabled.  For example, if you want your GlobalOrdinal type to get tested in Tpetra's tests, you'll need to enable it explicitly with the appropriate CMake option.

> I'm relatively new to this so if this is a dumb question, that's my excuse.

Would you mind submitting a Github issue to get this added to the FAQ?  Please include both of our e-mails in the issue.  Thanks!


More information about the Trilinos-Users mailing list