Software Archive
Read-only legacy content
17061 Discussions

The most fastest method to square arbitrary integer number

richter__dan
Beginner
466 Views

I would like to square integer numbers with more than 10 million decimal digits. What is the fastest method to do it in C++/assembly language using the latest Intel processor instructions (e.g. AVX2, BMI2, MMX, SSE4.2 - Kaby Lake I7 processor)

For example Intel mentioned (by using Carry-Less Multiplication Instruction PCLMULQDQ):

Quick Squaring (256-bit)2 = 512-bit

// c3c2c1c0 = a1a0 * a1a0
{
c0 = _mm_clmulepi64_si128(a0, a0, 0x00);
c1 = _mm_clmulepi64_si128(a0, a0, 0x11);
c2 = _mm_clmulepi64_si128(a1, a1, 0x00);
c3 = _mm_clmulepi64_si128(a1, a1, 0x11);
}

Any suggestion for fast algorithm ideally with source code in C++/x64 assembly ?

0 Kudos
1 Reply
ArthurRatz
Novice
466 Views

richter, dan, I would use the AVX2 instructions since it's more performance efficient.

Thanks.

0 Kudos
Reply