openshmem-org / specification

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

Need for config_mask in shmem_team_get_config #447

Open naveen-rn opened 3 years ago

naveen-rn commented 3 years ago

What was the rationale behind adding a config_mask in shmem_team_get_config. Why would the user specifically ask for a config parameter that was not initially used during the team creation?

  1. (config == NULL) and (config_mask == empty) - should we return 0?
  2. (config == NULL) and (config_mask != empty) - AFAIU, this is defn an error from the user - so return non-zero.
  3. (config != NULL) and (config_mask != empty) - but the parameters used in the config_mask is not previously set during team split - so I suppose this is still valid return based on the config_mask (NULL/0) but return zero.
jdinan commented 3 years ago

The mask is for ABI compatibility.

naveen-rn commented 3 years ago

1 and 3 are still not clear from the specification.

jdinan commented 3 years ago

Agree that these should be clarified.

minsii commented 3 years ago

I understand that config_mask is used for ABI compatibility at team creation (i.e., only user-explicitly-set parameters will be used by the library). But I don't get why it is useful for shmem_team_get_config. Why can't the library just return all config parameters associated with the team?

jdinan commented 3 years ago

There is also a potential ABI compatibility issue with shmem_team_get_config. For example, consider an application compiled using this type:

typedef struct {
  int a;
} shmem_team_t;

And then run with an updated SHMEM library that uses this type:

typedef struct {
  int a;
  int b;
} shmem_team_t;

The library should not try to fill in b since the binary has not allocated space for it.

nspark commented 3 years ago

How about the following addition...? (new text in bold)

API Description

shmem_team_get_config returns through the config argument the configuration parameters as described by the mask, which were assigned according to input configuration parameters when the team was created. If team compares equal to SHMEM_TEAM_INVALID, then no operation is performed. If team is otherwise invalid, the behavior is undefined. If config_mask is 0, then config is not modified. If config_mask is nonzero and config is a null pointer, the behavior is undefined.

Return Values

If team does not compare equal to SHMEM_TEAM_INVALID, then shmem_team_get_config returns 0; otherwise, it returns nonzero.

That said, I'm not sure I understand the third issue @naveen-rn raised.

davidozog commented 2 years ago

@nspark et al. - Is there a common use-case for not modifying config if config_mask is 0? I'm wondering if it might be more helpful for users if the routine simply returns all the configuration parameters according to how the team was created (i.e., a "copy" of config). This might make it easier to duplicate a team and might better reflect the "team_split" config_mask, "A config_mask value of 0 indicates that the team should be created with the default values for all configuration parameters."

Either way, I agree this should be clarified - I was trying to implement shmem_team_get_config in SOS and was thoroughly confused by the spec, then ran across this issue ;)