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

Add CMO extension intrinsics #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Liaoshihua
Copy link
Contributor

Add CMO extension intrinsics description.

src/c-api.adoc Outdated
|`+void __riscv_cbo_flush(void *addr);+` |`cbo.flush` |Zicbom
|`+void __riscv_cbo_inval(void *addr);+` |`cbo.inval` |Zicbom
|`+void __riscv_cbo_zero(void *addr);+` |`cbo.zero` |Zicboz
|`+void __riscv_cbo_prefetch(void *addr, const int rw, const int locality);+` |`prefetch.[r][w]` |Zicbop
Copy link
Contributor

Choose a reason for hiding this comment

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

Is __riscv_cbo_prefetch a wrapper around __builtin_prefetch where there are 4 possible localities? RISC-V supports 5 localities, 4 NTL hint prefixes and 1 without any prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is __builtin_prefetch's wrapper. The 4 NTL hint maping had been included in Prefetch Intrinsics part on this doc. So, this commit only support a wrapper for __builtin_prefetch on zicbop extension.

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 document how the different rw/locality map to different instruction sequences?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you document how the different rw/locality map to different instruction sequences?

Do you mean to expand to describe these mappings?
Ok, I will send a new version tomorrow.

@yulong18 yulong18 mentioned this pull request Oct 26, 2024
@yulong18
Copy link

I follow the documentation to set the __riscv_cbo_prefetchi parameter type, but I get such an error that is invalid argument to built-in function. So, I think the authour need to redefine the parameter type.

@topperc
Copy link
Contributor

topperc commented Oct 26, 2024

I follow the documentation to set the __riscv_cbo_prefetchi parameter type, but I get such an error that is invalid argument to built-in function. So, I think the authour need to redefine the parameter type.

The rw and locality argument to __builtin_prefetch must be compile time constants. You'll need to use a macro instead of a function.

src/c-api.adoc Outdated
----
void __riscv_cbo_prefetch(void *addr, const int rw, const int locality)
{
__builtin_prefetch(addr, rw, locality);
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to explain that locality==0, adds nt.all hint. locality==1, adds ntl.pall hint. locality==2, adds ntl.p1 hint.

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.

3 participants