Example #1
0
void CSpaceRestrictionShape::build_border	()
{
	m_border.clear					();
	CCF_Shape						*shape = smart_cast<CCF_Shape*>(m_restrictor->collidable.model);
	VERIFY							(shape);
	xr_vector<CCF_Shape::shape_def>::const_iterator	I = shape->Shapes().begin();
	xr_vector<CCF_Shape::shape_def>::const_iterator	E = shape->Shapes().end();
	for ( ; I != E; ++I)
		fill_shape					(*I);
	
	{
		m_border.erase				(
			std::remove_if(
				m_border.begin(),
				m_border.end(),
				CBorderMergePredicate(this)
			),
			m_border.end()
		);
	}

	process_borders					();

	VERIFY3							(!border().empty(),"space restrictor has no border",*m_restrictor->cName());

#ifdef DEBUG
	test_correctness				();
#endif
}
Example #2
0
int main(int, char**) {
  plan_tests(17);
  test_correctness();
  bench_all_ignores();
  bench_no_ignores();

  return exit_status();
}
int main() {
    srand(time(0));

    test_correctness();
    std::cout << "Test succeeded" << std::endl;

    test_speed();
    std::cout << "Test completed" << std::endl;
}
Example #4
0
int parallel_tests()
{
    size_t n = 10000000;
    std::vector<double> v(n);
    int num_failed = 0;
    num_failed += test_speed(v);
    num_failed += test_correctness(v);
    num_failed += test_threadpool();
    return num_failed;
}
Example #5
0
void test_rsa_mp()
{
	device_context dev_ctx;
	dev_ctx.init(10485760, 0);
// srinath commenting out  
#if 0
	printf("------------------------------------------\n");
	printf("RSA512, GPU (MP), random\n");
	printf("------------------------------------------\n");
	rsa_context_mp rsa512_mp(512);
	rsa512_mp.set_device_context(&dev_ctx);
	test_latency(&rsa512_mp);
	test_correctness(&rsa512_mp, 20);
#endif
  
	printf("------------------------------------------\n");
	printf("RSA1024, GPU (MP), random\n");
	printf("------------------------------------------\n");
	rsa_context_mp rsa1024_mp(1024);
	rsa1024_mp.set_device_context(&dev_ctx);
	test_latency(&rsa1024_mp);
	test_correctness(&rsa1024_mp, 20);

// srinath commenting out
#if 0
	printf("------------------------------------------\n");
	printf("RSA2048, GPU (MP), random\n");
	printf("------------------------------------------\n");
	rsa_context_mp rsa2048_mp(2048);
	rsa2048_mp.set_device_context(&dev_ctx);
	test_latency(&rsa2048_mp);
	test_correctness(&rsa2048_mp, 20);

	printf("------------------------------------------\n");
	printf("RSA4096, GPU (MP), random\n");
	printf("------------------------------------------\n");
	rsa_context_mp rsa4096_mp(4096);
	rsa4096_mp.set_device_context(&dev_ctx);
	test_latency(&rsa4096_mp);
	test_correctness(&rsa4096_mp, 20);
#endif
}
Example #6
0
void test_rsa_cpu()
{
	printf("------------------------------------------\n");
	printf("RSA1024, CPU, random\n");
	printf("------------------------------------------\n");
	rsa_context rsa1024_cpu(1024);
	test_latency(&rsa1024_cpu);
	test_correctness(&rsa1024_cpu, 20);

	printf("------------------------------------------\n");
	printf("RSA2048, CPU, random\n");
	printf("------------------------------------------\n");
	rsa_context rsa2048_cpu(2048);
	test_latency(&rsa2048_cpu);
	test_correctness(&rsa2048_cpu, 20);

	printf("------------------------------------------\n");
	printf("RSA4096, CPU, random\n");
	printf("------------------------------------------\n");
	rsa_context rsa4096_cpu(4096);
	test_latency(&rsa4096_cpu);
	test_correctness(&rsa4096_cpu, 20);
}
Example #7
0
int parallel_tests()
{
    size_t n = 10000000;
    std::vector<double> v(n);
    int num_failed = 0;

    // if we only get one thread on this machine, skip the speed test
    if (std::thread::hardware_concurrency() > 1)
        num_failed += test_speed(v);

    num_failed += test_correctness(v);
    num_failed += test_threadpool();
    return num_failed;
}
Example #8
0
void test_rsa_mp_cert(unsigned num_stream)
{
	device_context dev_ctx;
	dev_ctx.init(10485760, num_stream);

	printf("------------------------------------------\n");
	printf("RSA1024, GPU (MP), server.key\n");
	printf("------------------------------------------\n");
	rsa_context_mp rsa("../../server.key", "anlab");
	rsa.set_device_context(&dev_ctx);
	//rsa.dump();
	if (num_stream == 0) {
		test_latency(&rsa);
		test_correctness(&rsa, 20);
	}
	else {
		for (unsigned int i = 1; i <= 16; i++)
			test_latency_stream(&rsa, &dev_ctx, i);
	}
}
Example #9
0
void test_planner(int rank)
{
     /* 
      * create and destroy many plans, at random.  Check the
      * garbage-collecting allocator of twiddle factors 
      */
     int i, dim;
     int r, s;
     fftw_plan p[PLANNER_TEST_SIZE];
     fftwnd_plan pnd[PLANNER_TEST_SIZE];
     int *narr, maxdim;

     chk_mem_leak = 0;
     verbose--;

     please_wait();
     if (rank < 1)
	  rank = 1;

     narr = (int *) fftw_malloc(rank * sizeof(int));

     maxdim = (int) pow(8192.0, 1.0/rank);

     for (i = 0; i < PLANNER_TEST_SIZE; ++i) {
	  p[i] = (fftw_plan) 0;
	  pnd[i] = (fftwnd_plan) 0;
     }

     for (i = 0; i < PLANNER_TEST_SIZE * PLANNER_TEST_SIZE; ++i) {
	  r = rand();
	  if (r < 0)
	       r = -r;
	  r = r % PLANNER_TEST_SIZE;

	  for (dim = 0; dim < rank; ++dim) {
	       do {
		    s = rand();
		    if (s < 0)
			 s = -s;
		    s = s % maxdim + 1;
	       } while (s == 0);
	       narr[dim] = s;
	  }

	  if (rank == 1) {
	       if (p[r])
		    fftw_destroy_plan(p[r]);

	       p[r] = fftw_create_plan(narr[0], random_dir(), measure_flag |
				       wisdom_flag);
	       if (paranoid && narr[0] < 200)
		    test_correctness(narr[0]);
	  }

	  if (pnd[r])
	       fftwnd_destroy_plan(pnd[r]);

	  pnd[r] = fftwnd_create_plan(rank, narr,
				      random_dir(), measure_flag |
				      wisdom_flag);

	  if (i % (PLANNER_TEST_SIZE * PLANNER_TEST_SIZE / 20) == 0) {
	       WHEN_VERBOSE(0, printf("test planner: so far so good\n"));
	       WHEN_VERBOSE(0, printf("test planner: iteration %d out of %d\n",
			      i, PLANNER_TEST_SIZE * PLANNER_TEST_SIZE));
	  }
     }

     for (i = 0; i < PLANNER_TEST_SIZE; ++i) {
	  if (p[i])
	       fftw_destroy_plan(p[i]);
	  if (pnd[i])
	       fftwnd_destroy_plan(pnd[i]);
     }

     fftw_free(narr);
     verbose++;
     chk_mem_leak = 1;
}
void CSpaceRestrictionComposition::initialize	()
{
	u32							n = _GetItemCount(*m_space_restrictors);
	VERIFY						(n);
	if (n == 1) {
#ifdef DEBUG		
		m_correct				= true;
		check_restrictor_type	();
#endif
		return;
	}

	string256					element;

	for (u32 i=0; i<n ;++i)
		if (!m_space_restriction_holder->restriction(_GetItem(*m_space_restrictors,i,element))->initialized())
			return;

	Fsphere						*spheres = (Fsphere*)_alloca(n*sizeof(Fsphere));
	for (u32 i=0; i<n ;++i) {
		SpaceRestrictionHolder::CBaseRestrictionPtr	restriction = 
			m_space_restriction_holder->restriction(
				_GetItem(
					*m_space_restrictors,
					i,
					element
				)
			);

		merge					(restriction);

		spheres[i]				= restriction->sphere();
	}

	// computing almost minimum sphere which covers all the almost minimum spheres
	Fbox3						temp;
	temp.min.x					= spheres[0].P.x - spheres[0].R;
	temp.min.y					= spheres[0].P.y - spheres[0].R;
	temp.min.z					= spheres[0].P.z - spheres[0].R;
	temp.max.x					= spheres[0].P.x + spheres[0].R;
	temp.max.y					= spheres[0].P.y + spheres[0].R;
	temp.max.z					= spheres[0].P.z + spheres[0].R;

	for (u32 i=1; i<n; ++i) {
		temp.min.x				= _min(temp.min.x,spheres[i].P.x - spheres[i].R);
		temp.min.y				= _min(temp.min.y,spheres[i].P.y - spheres[i].R);
		temp.min.z				= _min(temp.min.z,spheres[i].P.z - spheres[i].R);
		temp.max.x				= _max(temp.max.x,spheres[i].P.x + spheres[i].R);
		temp.max.y				= _max(temp.max.y,spheres[i].P.y + spheres[i].R);
		temp.max.z				= _max(temp.max.z,spheres[i].P.z + spheres[i].R);
	}

	m_sphere.P.mad				(temp.min,temp.max,.5f);
	m_sphere.R					= m_sphere.P.distance_to(spheres[0].P) + spheres[0].R;

	for (u32 i=1; i<n ;++i)
		m_sphere.R				= _max(m_sphere.R,m_sphere.P.distance_to(spheres[i].P) + spheres[i].R);

	m_sphere.R					+= EPS_L;

	m_initialized				= true;

	m_border.erase				(
		std::remove_if(
			m_border.begin(),
			m_border.end(),
			CMergePredicate(this)
		),
		m_border.end()
	);

	process_borders				();

#ifdef DEBUG
	test_correctness			();
#endif
}
Example #11
0
int main()
{
  std::cout << "*" << std::endl;
  std::cout << "* ViennaCL test: FFT" << std::endl;
  std::cout << "*" << std::endl;

  //1D FFT tests
  if (test_correctness("fft::direct", "../non-release/testdata/cufft.data", read_vectors_pair, &opencl_direct) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::fft", "../non-release/testdata/cufft.data", read_vectors_pair, &opencl_fft) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::batch::direct", "../non-release/testdata/batch_radix.data", read_vectors_pair, &opencl_direct) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::radix2", "../non-release/testdata/radix2.data", read_vectors_pair, &opencl_radix2) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::batch::radix2", "../non-release/testdata/batch_radix.data", read_vectors_pair, &opencl_radix2) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::batch::fft", "../non-release/testdata/batch_radix.data", read_vectors_pair, &opencl_fft) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::convolve::1", "../non-release/testdata/cufft.data", read_vectors_pair, &opencl_convolve) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::convolve::2", "../non-release/testdata/radix2.data", read_vectors_pair, &opencl_convolve) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::bluestein::1", "../non-release/testdata/cufft.data", read_vectors_pair, &opencl_bluestein) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft::bluestein::2", "../non-release/testdata/radix2.data", read_vectors_pair, &opencl_bluestein) == EXIT_FAILURE)
    return EXIT_FAILURE;

  //2D FFT tests
  if (test_correctness("fft:2d::radix2::sml::1_arg",
                        "../non-release/testdata/fft2d_radix2.data", read_matrices_pair, &opencl_2d_fft_1arg) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft:2d::direct::sml::1_arg",
                        "../non-release/testdata/fft2d_direct.data", read_matrices_pair, &opencl_2d_fft_1arg) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft:2d::direct::big::1_arg",
                        "../non-release/testdata/fft2d_direct_big.data", read_matrices_pair, &opencl_2d_fft_1arg) == EXIT_FAILURE)
    return EXIT_FAILURE;

  if (test_correctness("fft:2d::radix2::sml::2_arg",
                        "../non-release/testdata/fft2d_radix2.data", read_matrices_pair, &opencl_2d_fft_2arg) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft:2d::direct::sml::2_arg",
                        "../non-release/testdata/fft2d_direct.data", read_matrices_pair, &opencl_2d_fft_2arg) == EXIT_FAILURE)
    return EXIT_FAILURE;
  if (test_correctness("fft:2d::direct::bscalarig::2_arg",
                        "../non-release/testdata/fft2d_direct_big.data", read_matrices_pair, &opencl_2d_fft_2arg) == EXIT_FAILURE)
    return EXIT_FAILURE;

  std::cout << std::endl;
  std::cout << "------- Test completed --------" << std::endl;
  std::cout << std::endl;


  return EXIT_SUCCESS;
}