What: Merge the opal_free_list_t and ompi_free_list_t implementations
and add explicit interfaces for single and multi-threaded use.

Why: Historically these two lists were different due to ompi_free_list_t
dependencies in ompi (mpool). Those dependencies have since been moved
to opal so it is safe to (finally) combine them. The combined free
list comes in three flavors:

 - Single-threaded. Only to be used when it is guaranteed that no
   concurrent access will be made to the free list. Single-threaded
   functions are suffixed with _st.

 - Mutli-threaded. To be used when the free list may be accessed by
   multiple threads despite the setting of opal_using_threads.
   Multi-threaded functins are suffixed with _mt.

 - Conditionally multi-threaded. Common use case. These functions are
   thread-safe if opal_using_threads is set to true.

Compatibility functions for the ompi_free_list_t and the old accessor
functions (OPAL_FREE_LIST_*) are available while the code base is
transitioned to the new class/functions.

Additional changes to the free list:

 - Added a new argument to opal_free_list_init: mpool_reg_flags. These
   flags will be passed to the mpool allocation function for all free
   list allocations.

 - Free list item initializer functions now return an integer to
   indicate success or failure. This allows initializtion function that
   perform allocation to indicate whether the free list item is
   usable. If an initializer returns an error the item will not be added
   to the free list.

Additionally, I took this opportunity to clean up the initialization
functions. Instead of providing multiple flavors of initialization
(ompi_free_list_init, ompi_free_list_init_new, ompi_free_list_init_ex,
etc) there is only a single free list initializer: opal_free_list_init.

On additional thought: some free list users store the opal_free_list_t
their item belongs to in their opal_free_list_item_t subclass
(ex. btl/sm/btl_sm_frag.h) so that the appropriate opal_free_list_t can
be passed to opal_free_list_return. We could add an opal_free_list_t *
to opal_free_list_item_t and change:

void opal_free_list_return (opal_free_list_t *, opal_free_list_item_t
*);

to

void opal_free_list_return (opal_free_list_item_t *);

It would simplify some code with the cost of 8 bytes per free list
item. If this is acceptable I can add the change to this RFC.



When: Friday Mar 6. This gives me time to talk face-to-face with some of
you at the MPI forum.


PR: https://github.com/open-mpi/ompi/pull/407


-Nathan

Attachment: pgpg8Kcy8nVHU.pgp
Description: PGP signature

Reply via email to