You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: riscv-c-api.md
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -400,6 +400,25 @@ enum {
400
400
| `__RISCV_NTLH_INNERMOST_SHARED` | `ntl.s1` |
401
401
| `__RISCV_NTLH_ALL` | `ntl.all` |
402
402
403
+
### Prefetch Intrinsics
404
+
405
+
The Zicbop extension provides the prefetch instruction to allow users to optimize data access patterns by providing hints to the hardware regarding future data accesses. It is supported through a compiler-defined built-in function with three arguments that specify its behavior.
406
+
407
+
```
408
+
void __builtin_prefetch(const void *addr, int rw, int locality)
409
+
```
410
+
411
+
The locality for the built-in `__builtin_prefetch` function in RISC-V can be achieved using the Non-Temporal Locality Hints (Zihintntl) extension. When a Non-Temporal Locality (NTL) Hints instruction is applied to prefetch instruction, a cache line should be prefetched into a cache level that is higher than the level specified by the NTL.
412
+
413
+
The following table presents the mapping from the `__builtin_prefetch` function to the corresponding assembly instructions assuming the presence of the Zihintntl and Zicbop extensions.
0 commit comments