How programming languages ​​store arrays

When I want to evaluate some expression, let's say: 2*5 stores 2 and 5 in registers, and then performs the MUL operation. But what if we want to propagate huge arrays:

 a = [1, ....... , 100000] b = [1, ....... , 100000] a * b 

Is it necessary to generate asm, which will load and multiply elements one by one, or can whole vectors be stored in some registers? I know that there is Advanced Vector Extensions (AVX) , which allows you to store large vectors in registers, but still, it has a very limited size. I am not asking about any particular language or processor, just for a general idea.

+4
source share
1 answer

Except in very, very specific circumstances (i.e. vector processors , which are mainly used in supercomputers such as Cray X1 ), the processor has no registers that will support loading such large arrays.

As already mentioned, many processors can use SIMD, but, again, they are usually performed for specific applications (for example, GPU modules use built-in SIMD systems to process all the necessary data), and manual coding in assembly language is almost always required.

Vectorization may be of interest to you, as far as compilers are concerned (mainly for C / C ++, I believe) who are trying to compile traditional code with loops into optimized assembler code using vectors. Unfortunately, this usually applies to vectors much smaller than the 100,000 items you requested.

Tl; dr : No, such large registers do not exist, and languages ​​/ compilers that easily support them. But there are several smaller solutions that may interest you!

Hope this will be helpful!

+1
source

All Articles