In C, is there any way to copy data in cache larger than one cache line size e.g. 128 or 256 bytes in a single memory read?
1 Answers
The answer is that this depends on what you mean by "a single memory read". At the CPU level, we are working with caches and data lines. At the kernel level, we are working with memory pages. At the application level, we are working with streams and language-specific datatypes.
With C, you can have access to the latter, and even the kernel-level memory in an OS-specific way, but you will generally not be able to access the CPU level. (unless you are writing a kernel/microkernel or doing embedded controller programming) In fact, it's much more complicated than just cache, there are all kinds of memory interfaces and buses in a modern CPU, so it depends on /what/ and /where/, etc...
The kernel-level memory interface for Linux is very accessible in C and well documented, start with the mmap() man page.

- 4,083
- 2
- 25
- 48
-
I will explain what I mean by "single memory read". There is some data in the RAM which is not present in cache.When I access that data – Nauman Ahmed Jan 07 '15 at 18:21