Sandia-OpenSHMEM / SOS

Sandia OpenSHMEM is an implementation of the OpenSHMEM specification over multiple Networking APIs, including Portals 4, the Open Fabric Interface (OFI), and UCX. Please click on the Wiki tab for help with building and using SOS.
Other
61 stars 53 forks source link

Single PE allocation API #1088

Open wrrobin opened 1 year ago

wrrobin commented 1 year ago

This PR introduces the single PE allocation API and related changes. New APIs being added are as below.

void * shmemx_malloc_onepe(size_t size);
void * shmemx_calloc_onepe(size_t count, size_t size);
ptrdiff_t shmemx_ptrdiff_of_ptr(void *ptr);
void *shmemx_ptr_of_ptrdiff(ptrdiff_t ptrdiff);
void shmemx_free_onepe(void *ptr);

A simple unit test is used to test the APIs.

wrrobin commented 1 year ago

@stewartl318 - I was trying to add you as a reviewer on this, but not able to. I am trying this way to send a notification.

stewartl318 commented 1 year ago

As a general comment, I am personally in favor of alloc_single and in favor of the address translation idea, but opposed to varsize.

I think that varsize clutters up the API without providing any benefits.

The alternative is just to allocate the full requested size on every PE, but not put real memory behind it. This could result in runtime failures if the user tries to put and get to memory that is not there, but in the varsize case, there are no checks to verify that addresses are actually inside the varsize region anyway, so it is no different.

So, what is the precise benefit of varsize that justifies an API change?

There is also an argument that alloc_single can equally well be dealt with by using sbrk to expand the globals and statics region, and fcollect _end.