Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can memset be parallelized on 4 cores?

I am not sure to that. Can I write a large memset (for example 10 MB), on four cores to gain speedup with this?

Is such ram-chip parallelization possible at all, and also how big are time costs of firing other threads - is it more than a millisecond or less?

like image 864
grunge fightr Avatar asked Oct 12 '12 05:10

grunge fightr


1 Answers

You are pointing out a right question, at the same time it is difficult to give a simple answer to it. There are several aspects involved.

  1. Overhead of starting new threads (or picking them from some cache);
  2. Contension on the memory bus.
  3. The aspects above differ and have very different cost for different platforms.

Bigger PCs have several memory buses. Smaller ones have only one. On a one memory bus system this does not make any sense. If your system has several memory buses (channels) your array of data may have arbitrary split between memory banks. If it will happen that the whole array sits in the same memory bank, the parralelisation will be useless. Figuring out the layout of your array is an overhead again. In other words before splitting the operation between cores it is necessary to figure out if this is worth doing or not.

Simple answer is that these difficult to predict overheads will most likely will consume the benefit and make the overall result worse.

At the same time for a really huge memory area on some architectures it makes sense.

like image 105
Kirill Kobelev Avatar answered Sep 30 '22 03:09

Kirill Kobelev