Skip to content
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

OSHMEM/SHMEM: fix warnings regarding types and unused variables in shmem #12648

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

roiedanino
Copy link
Contributor

When compiling OpenShmem multiple warnings appear regarding a condition inside RUNTIME_CHECK_IMPL_RC macro as described in #12636

The solution would be changing the return types of the following functions from size_t to int:

prefix##type_name##_test_any

prefix##type_name##_test_some

prefix##type_name##_test_any_vector

prefix##type_name##_test_some_vector

prefix##type_name##_wait_until_any

prefix##type_name##_wait_until_some

prefix##type_name##_wait_until_any_vector

prefix##type_name##_wait_until_some_vector

Also removed an unused variable in void prefix##type_name##_wait_until_all_vector which caused multiple warnings as well

@yosefe
Copy link
Contributor

yosefe commented Jul 1, 2024

@roiedanino the fixes should be according to openshmem specification, see http://openshmem.org/site/sites/default/site_files/OpenSHMEM-1.5.pdf
for example:
image

@roiedanino
Copy link
Contributor Author

@roiedanino the fixes should be according to openshmem specification, see http://openshmem.org/site/sites/default/site_files/OpenSHMEM-1.5.pdf for example: image

So as I see it, those functions return an index and not a return code (like implied by the current implementation), what would be the way to indicate that some function is not implemented yet? logging an error message?

@yosefe
Copy link
Contributor

yosefe commented Jul 2, 2024

So as I see it, those functions return an index and not a return code (like implied by the current implementation), what would be the way to indicate that some function is not implemented yet? logging an error message?

@manjugv @janjust @MamziB WDYT?
These unimplemented functions came from #9631

@devreal
Copy link
Contributor

devreal commented Jul 2, 2024

From what I can see, there is no error-checking in any of this API. Simply running through a program printing warnings on each call is a bad idea. Bailing out (with a proper message) is probably the right way to go here. The cast to int is incorrect since it potentially truncates the size_t returned by confirming implementations and breaks the API.

{
return OSHMEM_ERR_NOT_IMPLEMENTED;
Copy link
Contributor

@MamziB MamziB Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roiedanino can you please explain how this line leads to a warning? I understand the warning for size_t but not for int. Same for void.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one does not, but it's incorrect to return a return code as it doesn't match specifications to do so, the caller won't expect a return code and won't interpret it as such

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could internally return ssize_t to be able to encode errors. That would resolve the warning.

Copy link
Contributor Author

@roiedanino roiedanino Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we will need to add int* return_value parameter to all of those functions to be able to return both rc and the actual value needed to be returned to the caller by specifications

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these functions return size_t in the standard? If you replace size_t with ssize_t (signed size_t) you can return a negative error code and the index/size required by the standard. That will silence the compiler warnings I pointed out (which complained about an unsigned value being tested for negative values)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we will need to add int* return_value parameter to all of those functions to be able to return both rc and the actual value needed to be returned to the caller by specifications

I thought these functions return size_t in the standard? If you replace size_t with ssize_t (signed size_t) you can return a negative error code and the index/size required by the standard. That will silence the compiler warnings I pointed out (which complained about an unsigned value being tested for negative values)

@roiedanino I would suggest keeping the changes to a minimum for now, we can think about dealing with error codes for functions that do not return integers once we have the implementation in. I suggest printing an error/warning and breaking or returning SIZE_MAX for now.

@devreal Yes, standard mandates that this function return size_t and I think we'd better not to change the return code.

@MamziB
Copy link
Contributor

MamziB commented Jul 3, 2024

Thanks to @roiedanino for working on fixing the warnings.
As @devreal mentioned, printing a message before returning is a good idea. Are you covering all the functions that are not implemented in this PR?

@roiedanino
Copy link
Contributor Author

Thanks to @roiedanino for working on fixing the warnings. As @devreal mentioned, printing a message before returning is a good idea. Are you covering all the functions that are not implemented in this PR?

I will go through them and fix where the implementation doesn't match the specifications

oshmem/runtime/runtime.h Outdated Show resolved Hide resolved
oshmem/mca/spml/ucx/spml_ucx_component.c Show resolved Hide resolved
oshmem/runtime/runtime.h Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jul 9, 2024

Hello! The Git Commit Checker CI bot found a few problems with this PR:

2f0dd13: OSHMEM/MCA/SPML/UCX: reverted some of the changes,...

  • check_signed_off: does not contain a valid Signed-off-by line

Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks!

@roiedanino roiedanino force-pushed the oshmem/fixing-type-warnings branch from 2f0dd13 to 66947e6 Compare July 9, 2024 09:18
@roiedanino roiedanino requested a review from MamziB July 9, 2024 09:18
@roiedanino roiedanino self-assigned this Jul 9, 2024
@MamziB
Copy link
Contributor

MamziB commented Jul 9, 2024

Thanks to @roiedanino for working on fixing the warnings. As @devreal mentioned, printing a message before returning is a good idea. Are you covering all the functions that are not implemented in this PR?

I will go through them and fix where the implementation doesn't match the specifications

@roiedanino did you check this?

@roiedanino
Copy link
Contributor Author

Thanks to @roiedanino for working on fixing the warnings. As @devreal mentioned, printing a message before returning is a good idea. Are you covering all the functions that are not implemented in this PR?

I will go through them and fix where the implementation doesn't match the specifications

@roiedanino did you check this?

Hi went through the PR, looks like the only issue I see (other than the things mentioned earlier):
OSHMEM_DECLSPEC void pshmem_team_sync(shmem_team_t team);
which is void while in the spec this function return type should be int:
int shmem_team_sync(shmem_team_t team);

Comment on lines 246 to 251
#define RUNTIME_SHMEM_NOT_IMPLEMENTED_API_ABORT_RET_SIZE_T() \
RUNTIME_SHMEM_NOT_IMPLEMENTED_API_ABORT(); \
return SIZE_MAX

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest proper scoping using do-while (like above)

Suggested change
#define RUNTIME_SHMEM_NOT_IMPLEMENTED_API_ABORT_RET_SIZE_T() \
RUNTIME_SHMEM_NOT_IMPLEMENTED_API_ABORT(); \
return SIZE_MAX
#define RUNTIME_SHMEM_NOT_IMPLEMENTED_API_ABORT_RET_SIZE_T() \
do { \
RUNTIME_SHMEM_NOT_IMPLEMENTED_API_ABORT(); \
return SIZE_MAX; \
} while (0)

Copy link

Hello! The Git Commit Checker CI bot found a few problems with this PR:

c4588ca: OSHMEM/RUNTIME: added do while scoping to NOT_IMPL...

  • check_signed_off: does not contain a valid Signed-off-by line

Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks!

@janjust
Copy link
Contributor

janjust commented Jul 11, 2024

@roiedanino thanks for the PR - please add a sign-off line in the commit

@janjust janjust merged commit 1b95379 into open-mpi:main Jul 11, 2024
13 checks passed
@janjust janjust mentioned this pull request Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants