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

[Fix][microTVM] QEMU RPC issue #8021

Merged
merged 13 commits into from
Jun 8, 2021
Merged

[Fix][microTVM] QEMU RPC issue #8021

merged 13 commits into from
Jun 8, 2021

Conversation

mehrdadh
Copy link
Member

This issue happens when we send a large tensor over RPC to the zephyr qemu target specially when it runs on a fast machine. We fixed the RPC large transfer size for microTVM at #7838, however, #7838 doesn't include RPC test with qemu and didn't catch this problem.
In this PR:

  • we add qemu RPC test
  • increase the size of ring buffer used for UART in zephyr to be more than TVM_CRT_MAX_PACKET_SIZE_BYTES to fix the UART ring buffer issue

Copy link
Contributor

@leandron leandron left a comment

Choose a reason for hiding this comment

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

cc @areusch @gromero for reviews if possible

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

thanks @mehrdadh, mostly minor things

tests/micro/zephyr/conftest.py Outdated Show resolved Hide resolved
tests/micro/zephyr/test_zephyr.py Outdated Show resolved Hide resolved
apps/microtvm/zephyr/demo_runtime/crt/crt_config.h Outdated Show resolved Hide resolved
@@ -214,7 +214,8 @@ tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
}

// Ring buffer used to store data read from the UART on rx interrupt.
#define RING_BUF_SIZE_BYTES 4 * 1024
// Should be larger than TVM_CRT_MAX_PACKET_SIZE_BYTES
Copy link
Contributor

Choose a reason for hiding this comment

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

can you comment how much larger, and why?

Copy link
Member Author

Choose a reason for hiding this comment

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

the minimum value is 25 bytes and I don't know why.
Also I tested with different baudrates (default is 115200) to see if that solve the issue, but it didn't help.

@mehrdadh mehrdadh force-pushed the qemu_large_rpc branch 3 times, most recently from f21013c to 669f71c Compare May 24, 2021 05:55
@mehrdadh mehrdadh marked this pull request as draft May 24, 2021 06:27
@mehrdadh mehrdadh marked this pull request as ready for review May 25, 2021 03:59
@mehrdadh
Copy link
Member Author

@areusch this is ready to review. PTAL.
thanks!

apps/microtvm/zephyr/host_driven/src/main.c Show resolved Hide resolved

// Small buffer used to read data from the UART into the ring buffer.
static uint8_t uart_data[8];
// TODO(mehrdadh): Explore why offset is required.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain why TVM_CRT_MAX_PACKET_SIZE_BYTES is required, though? I believe it's not needed on most physical hardware

Copy link
Member Author

Choose a reason for hiding this comment

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

This could be because of qemu only. Let me confirm that and add comment on the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

just wanted to follow-up on this one

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked this on physical hardware and as you mentioned this large value for ring buffer size is only required for testing on QEMU. I added a comment about this. Please let me know if you have any other concern.

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

thanks @mehrdadh !

@areusch areusch merged commit d1e2e0d into apache:main Jun 8, 2021
@mehrdadh mehrdadh deleted the qemu_large_rpc branch June 11, 2021 15:49
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 17, 2021
* add test

* fix test

* add parameter to test

* cleanup

* format

* address comments

* address comments

* direct read/write from/to ring buffer

* merge fix

* add comment
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jun 17, 2021
* add test

* fix test

* add parameter to test

* cleanup

* format

* address comments

* address comments

* direct read/write from/to ring buffer

* merge fix

* add comment
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