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

Support early print buffer flushing in debug mode #61

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

zibaiwan
Copy link
Contributor

@zibaiwan zibaiwan commented Jan 18, 2022

Added a flow to flush printf() buffer before the Kernel ends. This will be helpful for debugging a hang Kernel. The Runtime periodically polls from the device and process the printf buffer from the last processed point.

If ACL_HAL_DEBUG = 1 and the Kernel is Hang, Kernel status (existing feature) and printf buffer will be flushed to stdout every 10 seconds (approximately). The thread will run if there are spare cycles.

If ACL_HAL_DEBUG = 3, Kernel status and printf buffer will flushed every 10 seconds, even the Kernel isn't hung.

The behavior of printf() is not altered in non-debug mode.

Sample output

  Kernel  0 Status: 0x00048000 running:: Accelerator 0 printf buffer size is 160.
:: Calling acl_process_printf_buffer_fn with activation_id=1 and printf_size=160.


Previously processed buffer size is 0 
Another test string 14
This is a test
Another test string 11
Another test string 12
Another test string 13
  Kernel  0 Status: 0x00048000 running:: Accelerator 0 printf buffer size is 160.
:: Calling acl_process_printf_buffer_fn with activation_id=1 and printf_size=160.


Previously processed buffer size is 160 
All Printf() buffer has already been dumped

ToDo

  • Fix Klocwork if applicable
  • Run Clang format
  • manual testing
  • Clear commit messages and Rebase
  • Run existing regtest to ensure existing feature still passes
  • Create a new regtest to test this specific feature

@zibaiwan zibaiwan added the enhancement New feature or request label Jan 18, 2022
@zibaiwan zibaiwan added this to the 2022.3 milestone Jan 18, 2022
@zibaiwan zibaiwan self-assigned this Jan 18, 2022
@zibaiwan zibaiwan marked this pull request as ready for review January 25, 2022 20:13
@zibaiwan zibaiwan requested a review from pcolberg January 27, 2022 18:12
Copy link
Contributor

@pcolberg pcolberg left a comment

Choose a reason for hiding this comment

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

Thanks @zibaiwan! Could you include a commit message that summarizes the change and also motivates why it was made?

Have you taken a look at the unit tests to see if anything could be inserted to test this new functionality, as far as is feasible in a unit test? For instance, checking that the new state variables added here correspond to the expected state.

@zibaiwan
Copy link
Contributor Author

zibaiwan commented Feb 1, 2022

@pcolberg , thank you very much for your review. I have updated the PR based on your suggestions.

@zibaiwan zibaiwan requested a review from pcolberg February 1, 2022 14:12
Copy link
Contributor

@pcolberg pcolberg left a comment

Choose a reason for hiding this comment

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

Thanks @zibaiwan for the additional tests, much appreciated 🙂

@sherry-yuan
Copy link
Contributor

A small question about a (maybe) corner case: What happens if the kernel stalls before the next 10 sec printf buffer dumps?

@zibaiwan
Copy link
Contributor Author

zibaiwan commented Feb 2, 2022

A small question about a (maybe) corner case: What happens if the kernel stalls before the next 10 sec printf buffer dumps?

@sherry-yuan Good question. If a kernel is stalled because the printf buffer is full (runtime doesn't seem to stall for other reason, even it does, it wouldn't matter here), it will print the rest of the printf buffer which hasn't been dumped by the debug dumps and clear the buffer.

@zibaiwan zibaiwan force-pushed the printf branch 2 times, most recently from c62dfe7 to 3c3e8e6 Compare February 2, 2022 21:24
Added a flow to flush printf() buffer before the Kernel ends. This will be helpful for debugging a hang Kernel. The Runtime periodically polls from the device and process the printf buffer from the last processed point. If ACL_HAL_DEBUG = 1 and the Kernel is Hang, Kernel status (existing feature) and printf buffer will be flushed to stdout every 10 seconds (approximately). The thread will run if there are spare cycles. If ACL_HAL_DEBUG = 3, Kernel status and printf buffer will flushed every 10 seconds, even the Kernel isn't hung. The behavior of printf() is not altered in non-debug mode.
@zibaiwan zibaiwan merged commit 3f7a228 into intel:main Feb 2, 2022
@zibaiwan zibaiwan deleted the printf branch February 2, 2022 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants