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

Improve compatibility with Hexagon hardware #1785

Merged
merged 7 commits into from
May 23, 2024
Merged

Conversation

steven-johnson
Copy link
Contributor

The customization done via BENCHMARK_OS_QURT works just fine with the Hexagon simulator, but on at least some Hexagon hardware, both qurt_timer_get_ticks() and std::chrono::now() are broken and always return 0. This fixes the former by using the better-supported (and essentially identical qurt_sysclock_get_hw_ticks() call, and the latter by reading a 19.2MHz hardware counter (per suggestion from Qualcomm). Local testing seems to indicate these changes are just as robust under the simulator as before.

The customization done via BENCHMARK_OS_QURT works just fine with the Hexagon simulator, but on at least some Hexagon hardware, both `qurt_timer_get_ticks()` and `std::chrono::now()` are broken and always return 0. This fixes the former by using the better-supported (and essentially identical `qurt_sysclock_get_hw_ticks()` call, and the latter by reading a 19.2MHz hardware counter (per suggestion from Qualcomm). Local testing seems to indicate these changes are just as robust under the simulator as before.
@LebedevRI
Copy link
Collaborator

Can you please explain (in the commit message too)
why this ChronoClockNow workaround is being introduced
instead of fixing the underlying bug?

src/timers.h Outdated Show resolved Hide resolved
@steven-johnson
Copy link
Contributor Author

Can you please explain (in the commit message too) why this ChronoClockNow workaround is being introduced instead of fixing the underlying bug?

It is not in my power to fix the underlying bug, which (presumably) lies inside the Qualcomm SDK. I'd much prefer it if the implementation of std::chrono that Qualcomm provided actually works.

src/timers.h Outdated Show resolved Hide resolved
@LebedevRI
Copy link
Collaborator

Can you please explain (in the commit message too) why this ChronoClockNow workaround is being introduced instead of fixing the underlying bug?

It is not in my power to fix the underlying bug, which (presumably) lies inside the Qualcomm SDK. I'd much prefer it if the implementation of std::chrono that Qualcomm provided actually works.

Makes sense. Please link the upstream bugreport in commit message.

@steven-johnson
Copy link
Contributor Author

steven-johnson commented May 14, 2024

Can you please explain (in the commit message too) why this ChronoClockNow workaround is being introduced instead of fixing the underlying bug?

It is not in my power to fix the underlying bug, which (presumably) lies inside the Qualcomm SDK. I'd much prefer it if the implementation of std::chrono that Qualcomm provided actually works.

Makes sense. Please link the upstream bugreport in commit message.

There is no upstream bug report, because I haven't yet gotten Qualcomm to admit that this is in fact a bug -- I'm trying to find the correct contacts at Qualcomm.

EDIT: I have asked the contacts I do have to take look at the PR and comment as appropriate.

@steven-johnson
Copy link
Contributor Author

PTAL

src/timers.h Outdated Show resolved Hide resolved
src/timers.h Outdated
static const bool is_steady = false;

static time_point now() {
unsigned long long count;
Copy link
Collaborator

@LebedevRI LebedevRI May 15, 2024

Choose a reason for hiding this comment

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

(You are sure this shouldn't just be rep?)

@LebedevRI
Copy link
Collaborator

Cool, looks good to me. It would be good to get some kind of
an acknowledgement from Qualcomm re the bug,
i'm not sure if we should wait for that or not?

@LebedevRI
Copy link
Collaborator

And one more thought: in the cases where the normal clocks work, what's their frequency, is it better than of this clock?
I.e., should we be always using this clock, or should we detect the bug, and only then use this "fallback" clock?

@steven-johnson
Copy link
Contributor Author

Cool, looks good to me. It would be good to get some kind of an acknowledgement from Qualcomm re the bug, i'm not sure if we should wait for that or not?

IMHO we should wait for comment

And one more thought: in the cases where the normal clocks work, what's their frequency, is it better than of this clock? I.e., should we be always using this clock, or should we detect the bug, and only then use this "fallback" clock?

The normal clock frequencies are implementation-defined. As to whether we should detect and fallback, that would add a bit of extra overhead where we probably want to minimize overhead, but I'll defer to QC folk on that.

@LebedevRI
Copy link
Collaborator

Cool, looks good to me. It would be good to get some kind of an acknowledgement from Qualcomm re the bug, i'm not sure if we should wait for that or not?

IMHO we should wait for comment

Let's wait.

And one more thought: in the cases where the normal clocks work, what's their frequency, is it better than of this clock? I.e., should we be always using this clock, or should we detect the bug, and only then use this "fallback" clock?

The normal clock frequencies are implementation-defined. As to whether we should detect and fallback, that would add a bit of extra overhead where we probably want to minimize overhead, but I'll defer to QC folk on that.

That would need to happen at CMake time, true, but then i'm not sure if it can truly be detected then,
because i suspect it might not happen when the compiled code is run not on the actual hardware,
but emulated on the machine on which it is being compiled.

LebedevRI
LebedevRI previously approved these changes May 15, 2024
Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

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

LGTM, but let's wait.

@steven-johnson
Copy link
Contributor Author

Update: It's taking much longer than I expected to get any kind of feedback from Qualcomm on this, and my team is getting blocked by this. Can we go ahead and land this, with the understanding that it may be rolled back and/or fixed forward when we eventually do get feedback from QC?

@aankit-quic
Copy link

@steven-johnson @LebedevRI I'm really sorry. I still haven't gotten any response from the team who could answer these concerns.

The PR looks good to me. The qurt APIs essentially do the same thing as what Steven is doing here. I feel the std::chrono should have worked in the first place and is probably a bug, but the responsible team still have not confirmed anything.

@LebedevRI
Copy link
Collaborator

Update: It's taking much longer than I expected to get any kind of feedback from Qualcomm on this, and my team is getting blocked by this.

FWIW, i've very much expected that it would take a month+ before anything happens here.
Sure, let's merge this.

@LebedevRI LebedevRI merged commit 7f992a5 into google:main May 23, 2024
79 of 80 checks passed
@LebedevRI
Copy link
Collaborator

@steven-johnson @aankit-quic thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants