-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tpetra: Simplify initialization paths #194
Comments
I hope we are still on track to provide an embedded option for this feature. As was thoroughly discussed in the mentioned Bugzilla bug 6361, global initializers are bad for embedded libraries. Can't we have an initializer object (instead of a global function) that behaves the same way, and then pass it in as an argument to Tpetra classes? That way we can have more than one kind of initializer in a code and can support Tpetra objects that, for example, exist on the host, while others exist on the device, or any other meaningful combination. Mike
|
Tpetra does not actually need initialization if Kokkos and MPI are initialized already. This is the embedded option. Tpetra::initialize() is a no-op in that case, and doesn't even need to exist (so let's get rid of it?). |
That's what Map is :-) It takes an MPI communicator. In the future, we may extend it to take a Kokkos execution space instance as well. |
To clarify further: the main point of this is to avoid unpleasant user surprise at Kokkos getting initialized with the wrong defaults. Tpetra already supports use as an embedded library. There are occasions when it initializes a global MPI_Op, for example, but it is careful to tie finalization of the MPI_Op to an MPI_Finalize hook. The only issue here is whether we even want Tpetra to expose to users an option to support Kokkos and MPI initialization. We're going to need that option for unit tests regardless. |
Revised discussion: @trilinos/tpetra That bug discussion centered around whether Tpetra should initialize Kokkos and MPI (if enabled) for users automatically. In particular, the constructors of the "Node" objects that Tpetra uses (a legacy of Kokkos 1.0, retained only for backwards compatibility) initialize Kokkos if it hasn't already been initialized. (Tpetra::Map's constructor creates the Node automatically for them. Users aren't supposed to handle Node instances anymore, because we plan to phase them out.) This is a problem because correct initialization of both Kokkos and MPI requires command-line arguments (argc, argv). There is currently no way for users to pass command-line arguments into Node's constructor or Map's constructor. This was never a problem for MPI, because Tpetra always required that MPI be initialized; Tpetra never tried to initialize MPI for users. The issue with Kokkos is that users never had to initialize Kokkos 1.0, and we didn't want to have to change their code. It's easy to set up Kokkos and MPI initialization in Teuchos' unit test framework. If a Trilinos unit test executable buys into Teuchos' predefined main() function by linking with packages/teuchos/comm/test/UnitTesting/Teuchos_StandardParallelUnitTestMain.cpp, that main() function initializes MPI before any tests in the executable run, and finalizes MPI after all tests in the executable run. It does so using Teuchos::GlobalMPISession (RAII wrapper around MPI_Init / MPI_Finalize). The weird thing is that Teuchos::GlobalMPISession's destructor finalizes Kokkos as well as MPI! Thus, wouldn't it be rational for Teuchos::GlobalMPISession's constructor (which conveniently takes (argc, argv)) to call Kokkos::initialize? In summary: We could eliminate Tpetra::initialize (all overloads). For unit tests, Teuchos::GlobalMPISession can start Kokkos. For users' code, we expect users either to initialize Kokkos as boilerplate, or to use Teuchos::GlobalMPISession (or some "Tpetra::" equivalent). How about this? |
See also #291 (fixed). Tpetra Node initialization reads and parses the command-line arguments saved by Teuchos::GlobalMPISession, so it gets the command-line arguments correctly for all unit tests that use Teuchos' unit test "main" .cpp file. |
THIS COMMENT SUPERSEDED BY MY LONG COMMENT BELOW (01:23 09 Mar 2016).
@trilinos/tpetra
Moved from Bugzilla Bug 6361: https://software.sandia.gov/bugzilla/show_bug.cgi?id=6361
That bug discussion centered around whether Tpetra should initialize Kokkos and MPI (if enabled) for users automatically. The motivating problem is that users encountered unexpected, undesired Kokkos behavior, because Tpetra initialized Kokkos with defaults, when it should instead have used Kokkos' input command-line arguments. The main benefit of automatic initialization is that Tpetra users who don't otherwise use Kokkos or MPI, don't have to know about either. The risks of automatic initialization are:
We didn't all come to full agreement, but I think we can agree that the following two options make sense:
It is unnecessary to provide an initialize() function that takes an
MPI_Comm
, because Tpetra does not have a "default MPI communicator."Tpetra::Map
takes and wraps the user's communicator. Similarly, initialize() need not take a Kokkos execution space instance; the proper place for that would be the constructor ofTpetra::Map
.Note that the zero-argument version of initialize() above changes current behavior with respect to Kokkos initialization. Current behavior is that initialize() initializes Kokkos with default arguments.
The text was updated successfully, but these errors were encountered: