-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplifying the SET
API and its variants
#65
Comments
As we just discussed in person, the decision is to define The |
Great! I like this proposal. I think @housengw had found a way to use C's What do you think? |
I think that since the third argument is a function pointer, we should use difference names for the macros to be safe.. |
As you are working on this, can I suggest to take the opportunity to switch to lowercase names as brought up in #40? |
That's a good point. I am open to the change. @edwardalee @Soroosh129 What do you think? |
That is OK with me. Do we want to leave the upper case names there for backward compatibility? I don't see any harm in that... |
It's OK with me too. We can keep SET in a deprecated state and eventually remove it. |
I couldn't get the solution outlined in @Soroosh129's link to work with macros. So I used |
a lower case
|
This error is limited to the CCpp target it looks like. |
I'm not sure I like this solution... Is this really necessary? |
I think so. Even if we can circumvent name conflicts with |
After a discussion with @edwardalee, a conclusion was reached that a copy constructor is needed for mutable inputs. It makes sense add a |
It might not be enough to add a Also, it might be strange to assign the |
For federated execution in general, I think it's better to disallow (or strongly deprecate) token types altogether and only allow the default serializer to be used for plain old data (POD). It seems to me that allowing users to potentially send pointers over the network is error-prone. If we improve our Protobufs integration, this shouldn't be too much of a pain for programmers. This strategy will also make it more straightforward to enable Python and C federates to talk to each other (even if they were not necessarily designed to do so). CPython provides built-in functions to convert PODs between C and Python. For more complicated types, Protobuf can take care of the serialization. |
After meeting with @Soroosh129 and @edwardalee, we have come to the following design: Implementation:
|
closed by #68 |
For how long will we need to keep the deprecated API functions around? For context,
|
I think now is as good a time as any to remove them. |
Yes, now is a good time :-) |
While working on issue 44, I realized it might help with ease of use if we provide an alternate set of
SET
APIs that are defined based on the memory properties of the set data.Design
Instead of adding
destructor
variants to existingSET
APIs, I propose a design that will only have twoSET
variants, one for static data and one for dynamic data:SET(out, val)
(implies static data)SET_DYNAMIC(out, val, destructor)
(implies dynamic data)Implementation:
SET(out, val)
is the same as the currentSET
.SET_DYNAMIC(out, val, destructor)
is the same asSET_ARRAY
except without theelem_size
argument (whichSET_ARRAY
doesn't use in its macro body, anyway) and have an extra field for the destructor.Example use case:
Suppose is a struct called
data
:data
is static (none of its members is malloc'd), just useSET(out, data)
data
has dynamic members, the user would malloc the whole struct, then malloc the members. Then, useSET_DYNAMIC(out, data, &destructor)
, wherevoid destructor(void* data)
is a function provided by the user that takesdata
and frees every dynamic member of it as well asdata
itself. Ifdestructor
isNULL
,free
is used instead.The point of this API is to simplify memory management and reduce the number of assumptions the user has to make to use the dynamic memory
SET
s.EDIT:
Action Items:
elem_size
argument fromSET_ARRAY
sinceelem_size
is already set in the default token generated bydeferredCreateDefaultTokens
inCTriggerObjectsGenerator.java
elem_size
from_LF_SET_ARRAY
andSET_ARRAY
elem_size
argument from API call inSetArray.lf
SET_DYNAMIC
API.The text was updated successfully, but these errors were encountered: