Is it possible to do some calculations in RAM?

In theory, is there a way to do some kind of computation in RAM using memory-related instructions like move

, clflush

or something else like xor

between two adjacent lines?

With my limited knowledge of RAM and assembly, I cannot think of such possibilities.

+3


source to share


2 answers


No, any calculations are done on the CPU (or GPU or other system devices that can be loaded / stored in RAM). Even the Turing-complete mov stuff that @PaulR linked in a comment just uses the hardware to create CPU addresses and the data in the register does the computation.

64-bit packages and 64-bit packages are still visible in memory when the processor misses the cache.

See also What every programmer should know about memory for some background on how the DDR protocol works (send an address, then transfer a data packet to / from RAM)


Related: is num++

atomic in C or x86inc [mem]

?



lock inc [mem]

is actually implemented inside the CPU with load / modify / store, which the CPU makes atomic to all possible other observers in the system (like other CPU cores and PCIe devices). But not including things like connecting a logic analyzer to a memory bus, which is inconsistent with the cache-coherency protocol that the CPU core uses to store exclusive rights to a cache line when it performs an atomic read-modify-write.

Some people thought the addition was done "inside" the memory chips, but they are wrong. There is no adder or even AND / OR / XOR logic hardware in the DRAM chip (or in the interface chips that connect it to the DDR4 bus); all he can do is download or save from a given address. Any chip that can do more than that is not just DRAM.

Well, obviously there is logic in the memory interface chips, but it is not connected to work with data.

If this were the case, it would be a type of Computational RAM . (Thanks for linking this in the comments, BTW. Interesting computer architecture idea. AFAIK, no main processor or GPU uses C-RAM.)

You can't even ask for DDR4 DRAM for page zero. The CPU must do this through the memory controllers.

+5


source


Surprisingly yes, according to Paul R's comment: mov

completed by Turing
.

Such a computer mov

would be (highly) impractical. not to mention that it would be terribly difficult to write a compiler for it.There is an ac compiler that translates general purpose c programs into x86 mov

instructions
. Surprisingly, this allows floating point calculations.
Since it is based on a Turing machine and not a Von Neumann machine, it is terribly slow (but this is a great way to obfuscate your code: -1).



For all practical purposes, you can only perform calculations through registers.
Only AFIAK movs

accepts 2 memory operands, every other instruction that addresses memory additionally uses a constant or register.

Rowhammer is not a solver because it is not deterministic.
It is also an artifact of the implementation of dramas, the cache memory does not suffer from this effect.

+4


source







All Articles