Skip to content

Support for the ICVs tool-var and display-affinity-var in ompd_enumerate_icvs() and ompd_get_icv_from_scope() #75

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

Merged

Conversation

jinisusan
Copy link

Changes to provide support for the ICVs tool-var and display-affinity-var in ompd_enumerate_icvs() and ompd_get_icv_from_scope()

return ompd_rc_stale_handle;
ompd_rc_t ret;

assert(callbacks && "Callback table not initialized!");

Choose a reason for hiding this comment

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

As a general rule, putting asserts into library code is not good, because it will crash the tool. I think a better approach would be to return an error code to the tool. Calling assert() should be the last resort, not for recoverable error handling. I know that there are other places in the LLVM OMPD library that use assert(), but I think those should be fixed too.

return ompd_rc_stale_handle;
ompd_rc_t ret;

assert(callbacks && "Callback table not initialized!");

Choose a reason for hiding this comment

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

assert() should be removed.

Copy link

@jdelsign jdelsign left a comment

Choose a reason for hiding this comment

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

I think the changes look OK, but have they been tested by a tool yet?

Also, see my comments regarding the use of assert(), which I think should be avoided if at all possible.

@ilagunap
Copy link

ilagunap commented Jan 21, 2020

The changes look good to me also. Just a comment on the asserts; the reason for the asserts is that we follow the LLVM philosophy: assert liberally. From the LLVM doc: "Use the “assert” macro to its fullest. Check all of your preconditions and assumptions, you never know when a bug (not necessarily even yours) might be caught early by an assertion, which reduces debugging time dramatically."

A better approach would be to allow the user to turn off asserts - LLVM provides that option: "-DLLVM_ENABLE_ASSERTIONS=On".

@jdelsign
Copy link

The changes look good to me also. Just a comment on the asserts; the reason for the asserts is that we follow the LLVM philosophy: assert liberally. From the LLVM doc: "Use the “assert” macro to its fullest. Check all of your preconditions and assumptions, you never know when a bug (not necessarily even yours) might be caught early by an assertion, which reduces debugging time dramatically."

A better approach would be to allow the user to turn off asserts - LLVM provides that option: "-DLLVM_ENABLE_ASSERTIONS=On".

IMHO, that's an OK philosophy in the compiler itself, but it's a terrible philosophy in a library intended to be used by third party tools, especially when there's a simple way to recover from the error condition.

@jinisusan
Copy link
Author

Thank you very much, John and Ignacio, for the reviews. I understand the philosophy behind removing the asserts, and I am OK with replacing the asserts with returning error codes. Ignacio, are you ok with that ? But looking at the standard, the closest I could think of is ompd_rc_error -- the others do not seem to match. This is kind of a generic error though -- Ideally, I think, there should have been a special error code for the lack of a callback table implementation in the standard. We might have to add some debug statement or so alongwith returning the error code to throw more light on why this error occurs -- but that might not be ok in a library either.

I could go ahead and modify this to replace the asserts with ompd_rc_error. Replacing the asserts in the rest of the code can be taken up as a separate task.

John, I have been modifying gdb to use OMPD, and I have been testing these changes using that.

@jinisusan jinisusan closed this Jan 21, 2020
@jinisusan jinisusan reopened this Jan 21, 2020
@ilagunap
Copy link

I'm ok with that. Yes, ompd_rc_error is the closest. I was only trying to explain why there are several places with assertions. I don't think that crashing the library because a bug occurred is bad as long as the assertion message is insightful, but if the debugger implementers prefer return error codes, I'm okay with that also.

@jdelsign
Copy link

@jinisusan You are right that it would be nice if there were a more specific error code, but I think simply returning ompd_rc_error is the best option. Someone (not me) should someday find the other asserts in the LLVM OMPD library and change them to return error codes if possible.

…ate_icvs() and ompd_get_icv_from_scope() -- changed asserts to error code returns
@jinisusan
Copy link
Author

Thanks! Have made the assert related changes and made the new commit. If it looks ok, it would be great if someone can do the merge on my behalf too.

@jprotze
Copy link

jprotze commented Jan 23, 2020

LGTM, merged

@jinisusan
Copy link
Author

Thank you, Joachim !

@jinisusan jinisusan deleted the ompd-display-affinity branch July 30, 2020 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants