The major benefit of the second method is that it has the obvious potential to 
save us some memory. Not much I guess, but somewhere in the order of few Kb.

But in order to save this memory, the originator must keep a pointer to the 
data in order to be able to free it after the mca_params framework is closed. 
This means for each string saved (due to the lack of the strdup in the 
mca_params framework), there will be sizeof(char*) bytes spend in bookkeeping. 
Thus the memory savings will be drastically lowered, and the benefit of the 
second approach is strongly compromised.


  George.

On Feb 5, 2013, at 12:46 , Nathan Hjelm <hje...@lanl.gov> wrote:

> Notes:
> 
> Variable system currently takes ownership of string values. This is done so 
> strings can be freed when overwritten (by mca_base_var_set_value) or when the 
> variable is deregistered. This requires that initial string values be 
> allocated on the heap (not .DATA, heap, etc). Brian raised a good point that 
> projects/frameworks/components should be responsible for freeing anything 
> they allocate and that it shouldn't be the responsibility of the MCA variable 
> system to free these strings (though we have to handle the 
> mca_base_var_set_value case).
> 
> Some options:
> 1) Always duplicate the string passed in by the caller. The caller will have 
> to free the original value if it was allocated. Ex:
> 
> tmp = strdup ("some_string_value");
> backing_store = tmp;
> mca_base_var_register (..., MCA_BASE_VAR_TYPE_STRING, ..., &backing_store);
> free (tmp);
> 
> 2) Add a flag indicating whether the variable system should call free on the 
> initial value. Ex:
> 
> backing_store = "some_string_value";
> mca_base_var_register (..., MCA_BASE_VAR_TYPE_STRING, ..., 
> MCA_BASE_VAR_FLAG_STATIC, ..., &backing_store);
> 
> If the STATIC flag is not set the variable system takes ownership of the 
> string and frees it later. If the STATIC flag is set the variable system can 
> either 1) use the initial value, or 2) strdup the initial value. There are 
> issues with using the initial value without duplication since the registree 
> would need to ensure the initial value lives as long as the registered 
> variable (not a problem if the value is in .DATA or .BSS).
> 
> Thoughts on these options? Other options?
> 
> 
> List of initial supported types is adequate: char *, int, and bool. We can 
> re-evaluate later if there is a need for more types.
> 
> 
> We need to figure out how Open MPI could read all file values and build an 
> environment that could be passed to the backend to prevent the need to read 
> from files on the backend. This may necessitate modifying the mca_base_var 
> API.
> 
> 
> -Nathan
> <openmpi_mpit.pdf>_______________________________________________
> devel mailing list
> de...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/devel


Reply via email to