2020-05-25, 05:49   #308
Citrix

Jun 2003

32·52·7 Posts

I tried to write the code my self. I have attached it.

The program mainly writes the factors to factor file which need to be processed by srfile. There is no input or output file.

I only modified the FPU code and not the AVX multiplication code.

I cannot get it to compile. gmp.h is missing. I do not have GMP installed on my computer. Can anyone help compile it?

I do not have experience with GPU apps - how do I modify the code for GPU? Possibly cw_kernel.cl needs to be modified. Not sure what to do with the cw_kernel.h file.

Code:
void  SquareNWorker::TestLargePrimesFPU(uint64_t *ps)
{
uint64_t powinvs[4];
uint64_t tempinvs[4];
for (int i = 0; i < 4; i++)
{
powinvs[i] = ps[i] + 1;
powinvs[i] >> 1;
tempinvs[i] = powinvs[i];
}

fpu_powmod_4b_1n_4p(powinvs, 2 * ii_MaxN, ps);
fpu_powmod_4b_1n_4p(tempinvs, ii_MaxN * ii_MaxN, ps);

for (int32_t x = ii_MaxN; x >= ii_MinN; x--)
{
for (int i = 0; i < 4; i++)
{
if (tempinvs[i] <= x) { ip_SquareNApp->ReportFactor(tempinvs[i], x*x, -1, ps[i]); }
if (tempinvs[i] >= ps[i] - x) { ip_SquareNApp->ReportFactor(tempinvs[i], x*x, +1, ps[i]); }
// do not verify factors
// just write to file as k*2^n+-1
// use srfile then to clean up abc file.
// modified report factor so also print k.
}

fpu_push_1divp(ps[3]);
fpu_push_1divp(ps[2]);
fpu_push_1divp(ps[1]);
fpu_push_1divp(ps[0]);

fpu_mulmod_4a_4b_4p(powinvs, tempinvs, ps);

for (int i = 0; i < 4; i++)
{
if (tempinvs[i] & 1) { tempinvs[i] += ps[i]; }
tempinvs[i] >> 1;
if (powinvs[i] & 1) { powinvs[i] += ps[i]; }
powinvs[i] >> 1;
if (tempinvs[i] & 1) { powinvs[i] += ps[i]; }
powinvs[i] >> 1;

}
}
fpu_pop();
fpu_pop();
fpu_pop();
fpu_pop();
}
Attached Files
 squareNsieve.zip (20.4 KB, 6 views)