Example #1
0
/**
 * initializes the sieve global variables
 */
void init_sieve_globals() {

  mpz_init(mpz_fixed_hash_multiplier);
  mpz_set(mpz_fixed_hash_multiplier, opts.mpz_fixed_hash_multiplier);

  int64_arithmetic     = opts.int64_arithmetic;
  min_prime_index      = opts.primes_in_primorial; 
  pool_share           = opts.pool_share;
  primes               = opts.primes->ptr;
  two_inverses         = opts.two_inverses;
  chain_length         = opts.chain_length;
  extensions           = opts.sieve_extensions;
  use_first_half       = opts.use_first_half;
  layers               = extensions + chain_length;
  max_prime_index      = opts.max_prime_index;
  cache_bits           = opts.cache_bits;
  sieve_words          = opts.sieve_words;
  sieve_size           = opts.sieve_size;
  candidate_bytes      = sizeof(sieve_t) * sieve_words;
  bit_half             = sieve_size  / 2;
  word_half            = sieve_words / 2;
  cache_words          = word_index(cache_bits);
  cache_bytes          = byte_index(cache_bits); 

  /* calculate the bi-twin cc1 and cc2 layers */
  twn_cc1_layers = (chain_length + 1) / 2 - 1;
  twn_cc2_layers = chain_length       / 2 - 1;


  /* check the primes if DEBUG is enabled */
  check_primes(primes, two_inverses, max_prime_index);
}
Example #2
0
void
testmain (int argc, char *argv[])
{
  check_small ();
  check_composites ();
  check_primes ();
}
Example #3
0
int
main (int argc, char *argv[])
{
  tests_start ();

  check_primes ();

  tests_end ();
  exit (0);
}
Example #4
0
void* do_job(void* _arg) {
  TAU_REGISTER_THREAD();
  {
    prime_arg_t arg = _arg;
    int j = 0;
#if 0
    printf("JOBS = %d\n", arg[0].jobs);
#endif
    while(j < arg[0].jobs) {
      pthread_mutex_lock(&m);
      if (arg[j].stolen == 0) {
        arg[j].stolen = 1;
        pthread_mutex_unlock(&m);
        arg[j].sum = check_primes(arg[j].start, arg[j].end);
      } else {
        pthread_mutex_unlock(&m);
      }
      j++;
    }
  }
  return NULL;
}
Example #5
0
int
main (int argc, char **argv)
{
  int debug = 0;

  if ((argc > 1) && (! strcmp (argv[1], "--verbose")))
    verbose = 1;
  else if ((argc > 1) && (! strcmp (argv[1], "--debug")))
    verbose = debug = 1;

  gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
  if (! gcry_check_version (GCRYPT_VERSION))
    die ("version mismatch\n");

  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
  if (debug)
    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);

  check_primes ();

  return 0;
}
Example #6
0
int main(void)
{
  check_primes(1000);
  conjecture(2, 2000);
  return 0;
}
Example #7
0
void* prime_th(void* _arg) {
  prime_arg_t arg = _arg;
  arg->sum = check_primes(arg->start, arg->end);
  return NULL;
}