openshmem-org / specification

OpenSHMEM Application Programming Interface
http://www.openshmem.org
49 stars 32 forks source link

Understanding the meaning of "no action is performed" in memory management routines #440

Open naveen-rn opened 4 years ago

naveen-rn commented 4 years ago

We have the following statement in the memory management subsection:

When no action is performed, these routines return without performing a barrier.

And, the following statement in the changes to document sections:

Clarified that when the size argument is zero, symmetric heap allocation routines perform no action and return a null pointer; that symmetric heap management routines that perform no action do not perform a barrier; and that the alignment argument to shmem_align must be power of two multiple of sizeof(void*).

Just to be clear on the intended semantics - please clarify whether the following options can be considered as "no action" for the memory management operations:

  1. On shmem_malloc, shmem_realloc, shmem_align, and shmem_calloc, if the size is zero
  2. If the returned pointer from shmem_malloc and shmem_calloc is NULL
  3. If the user passed ptr in shmem_free is NULL
  4. If the count in shmem_calloc is zero

AFAIU, (1), (3), and (4) seems correct. Not sure with (2). Please clarify.

jdinan commented 4 years ago

Item 2 may be true as a consequence of item 1, but I don't recall it being specified in this way. It might simplify coding for OpenSHMEM 1.5 to use this fact, but it could become cause a bug if a future specification invalidates this rule. Then again, it might also simplify the specification to adopt this as a rule. 🤷

naveen-rn commented 4 years ago

I'm fine with (2), for now this is not an issue with our implementation. But, in future, I'm not sure whether there would be bugs when one PE gets a NULL and others get a valid ptr.

jdinan commented 4 years ago

It would break symmetry if all PEs don't either successfully allocate memory or return NULL, right?

This may actually be an oversight in the shmem_malloc_with_hints call. It can return NULL, but I'm not seeing a stipulation that the returned value must be NULL at all PEs in this case.