View Single Post
Old 2016-02-09, 16:47   #2464
msft
 
msft's Avatar
 
Jul 2009
Tokyo

2×5×61 Posts
Default

Hi,
Add residue check code.
Please review.

Ex.
Code:
Using threads: square 256, splice 128.
Starting M216091 fft length = 14K
|   Date     Time    |   Test Num     Iter        Residue        |    FFT   Error     ms/It     Time  |       ETA      Done   |
|  Feb 10  01:39:42  |    M216091     10000  0x0000000000000002  |    14K  0.00011   0.3752    3.75s  |         1:17   4.62%  |
Illegal residue: 0x0000000000000002. See mersenneforum.org for help.
Code:
unsigned long long check_illegal_residue(int *x_int, int q, int n, int offset)
{
  int j, k = 0;
  int digit, bit;
  unsigned long long residue = 0;
  int qn = q / n, carry = 0;
  int lo = 1 << qn;
  int hi = lo << 1;
  int tx, temp;

  digit = floor(offset * (n / (double) q));
  bit = offset - ceil(digit * (q / (double) n));
  j = (n + digit - 1) % n;
  while(x_int[j] == 0 && j != digit)
  {
     j--;
     if(j < 0) j += n;
  }
  if(j == digit && x_int[digit] == 0) return(0);
  else if (x_int[j] < 0) carry = -1;
  for(j = 0; j < n; j++)
  {
    tx = x_int[digit] + carry;
    if (size(digit)) temp = hi;
    else temp = lo;
    if(tx < 0)
    {
      tx += temp;
      carry = -1;
    }
    else carry = 0;
    residue += (unsigned long long) tx << k;
    k += q / n + size(digit);
    if(j == 0)
    {
       k -= bit;
       residue >>= bit;
    }
    if(k >= 64) break;
    digit++;
    if(digit == n) digit = 0;
  }
  return residue;
}
Code:
              if(residue == 0)
              {
                printf("Illegal residue: 0x0000000000000000. See mersenneforum.org for help.\n\n");
                exit (2);
              }
              else
                if(residue == 2 && check_illegal_residue(x_int, q, n, offset) == 2)
                {
                  printf("Illegal residue: 0x0000000000000002. See mersenneforum.org for help.\n\n");
                  exit (2);
                }
Attached Files
File Type: bz2 CUDALucas.cu.bz2 (27.8 KB, 59 views)
msft is offline   Reply With Quote