Default construction of future, promise, global_ptr and persona before init()
The spec requires UPC++ to be initialized before any UPC++ function can be called. This prohibits any UPC++ type from having static storage duration (since initializing it would entail a call to its constructor). This includes global pointers, which should likely be exempt from this restriction, as it prevents an application from keeping track of global pointers in static storage.
I suggest that we slightly loosen this restriction to something like the following: Unless otherwise stated, it is illegal to call a UPC++ function, including a constructor, when UPC++ is in the uninitialized state. We then exempt the following functions from this restriction:
init()
global_ptr<T>::global_ptr(std::nullptr_t)
global_ptr<T>::global_ptr()
(This doesn't exist at the moment, but it would be nice forglobal_ptr
to be DefaultConstructible. This would just construct a null pointer. It would likely necessitate a rank-independent representation of a null global pointer, which our implementation already does.)
Comments (10)
-
-
Would is be accurate to say that, anything requiring progress is off-limits? I'm not sure because of Amir's comment "a rank-independent representation of a null global pointer."
-
reporter I don't think that's a sufficient restriction. My comment was alluding to the fact that global pointers contain a rank as part of their representation, and
rank_me()
would not be available before initialization. Thus, their must be a representation of null that does not depend on knowing the rank of the creator. -
Can you construct such a null without the rank?
-
reporter My implementation uses a rank of 0 to represent a global pointer, regardless of which rank creates the pointer.
-
For the record, we think future<T> should also be made DefaultConstructible and declarable at static scope, for the convenience of a statically-scoped container to hold futures created at runtime. The "null" future created should by the default constructor should probably just be trivially ready (or trivially never ready).
-
At the 8-9-17 Pagoda meeting we resolved that
future
,promise
,global_ptr
and possiblypersona
should all be DefaultConstructible and declarable at static scope. This needs to be added to the spec, along with the semantics for a default constructed object of each type (ie when functions are called on them after init).team
anddist_object
need to still prohibit default construction due to the collective initialization requirement and the lack of ordering guarantees for static initializers in general. -
- changed component to Init and Finalize
- changed title to Default construction of future, promise, global_ptr and persona before init()
-
- changed milestone to 2017.09.30 release
-
- changed status to resolved
Resolved by Amir in f89f055 Thanks!
- Log in to comment
I agree with all of Amir's observations.
For the same usability reasons, we may also want to allow the default constructor for DefaultConstructible types
upcxx::promise<...T>
andupcxx:persona
. However these might entail more significant implementation effort.I'm not even sure what the semantics of a default constructed persona would be, except to serve as an empty variable that will be overwritten by a real persona after init.