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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/c-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,29 @@ RISC-V intrinsics examples:
vint8m1_t __riscv_vadd_vv_i8m1(vint8m1_t vs2, vint8m1_t vs1, size_t vl); // vadd.vv vd, vs2, vs1
----

=== CMO Intrinsics

The RISC-V CMO extension provides instruction for perform operations on copies
of data in the memory hierarchy.

In order to access the RISC-V CMO intrinsics, it is necessary to
include the header file `riscv_cmo.h`.

The functions are only available if the compiler's `-march` string enables the
required ISA extension.

.CMO Extension Intrinsics
[%autowidth]
|===
|*Prototype* |*Instruction* |*Extension*
|`+void __riscv_cbo_clean(void *addr);+` |`cbo.clean` |Zicbom
|`+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.

|`+int __riscv_cbo_prefetchi(const int locality);+` |`prefetch.i` |Zicbop
|===

=== NTLH Intrinsics


Expand Down