def test_cudh_small_orthorhombic_triclinic(fixture_small_triclinic): """Test if the triclinic and orthorhombic implementations give the same answer for an orthorhombic box.""" n_atoms, n_bins, coords, box, histo_ref = fixture_small_triclinic box_ort = get_orthorhombic_box() box_tri = get_orthorhombic_triclinic_box() for precision in ['single', 'double']: for check_input in [True, False]: for algo in [1, 2, 3]: histo_ort = cudh.histograms(coords, r_max, n_bins, box=box_ort, force_triclinic=False, precision=precision, check_input=check_input, algorithm=algo) histo_tri = cudh.histograms(coords, r_max, n_bins, box=box_tri, force_triclinic=True, precision=precision, check_input=check_input, algorithm=algo) util.compare(histo_ort, histo_tri)
def test_cudh_invalid_small_single(fixture_small_invalid): n_atoms, n_bins, coords, histo_ref = fixture_small_invalid for gpu_id in range(cudh.get_num_devices()): with pytest.raises(ValueError): cudh.histograms(coords, r_max, n_bins, precision="single", gpu_id=gpu_id, check_input=True)
def test_cudh_xlarge_single(fixture_xlarge): n_atoms, n_bins, coords, histo_ref = fixture_xlarge for gpu_id in range(cudh.get_num_devices()): for algo in [1, 2, 3]: histo_cudh = cudh.histograms(coords, r_max, n_bins, precision="single", gpu_id=gpu_id, algorithm=algo) util.compare(histo_ref, histo_cudh)
def test_cudh_medium_manybins_single(fixture_medium_manybins): n_atoms, n_bins, coords, histo_ref = fixture_medium_manybins for check_input in [True, False]: for gpu_id in range(cudh.get_num_devices()): for algo in [1, 2, 3]: histo_cudh = cudh.histograms(coords, r_max, n_bins, precision="single", gpu_id=gpu_id, check_input=check_input, algorithm=algo) util.compare(histo_ref, histo_cudh)
def test_cudh_small_triclinic(fixture_small_triclinic): """Check if pydh and cudh give the same answer with triclinic boxes.""" n_atoms, n_bins, coords, box, histo_ref = fixture_small_triclinic for precision in ['single', 'double']: for check_input in [True, False]: for algo in [1, 2, 3]: histo = cudh.histograms(coords, r_max, n_bins, box=box, precision=precision, check_input=check_input, algorithm=algo) util.compare(histo_ref, histo)
def test_cudh_medium_scaled_single(fixture_medium): n_atoms, n_bins, coords, histo_ref = fixture_medium n_el = len(n_atoms) scale_factors = np.ones(n_el * (n_el + 1) / 2) scale_factors *= 0.5 for check_input in [True, False]: for gpu_id in range(cudh.get_num_devices()): for algo in [1, 2, 3]: histo_cudh = cudh.histograms(coords, r_max, n_bins, precision="single", gpu_id=gpu_id, scale_factors=scale_factors, check_input=check_input, algorithm=algo) assert (histo_ref.sum() == 2.0 * histo_cudh.sum())
def test_cudh_medium_masked_single(fixture_medium): n_atoms, n_bins, coords, histo_ref = fixture_medium n_el = len(n_atoms) mask_array = np.ones(n_el * (n_el + 1) / 2) mask_array[::2] = 0 for check_input in [True, False]: for gpu_id in range(cudh.get_num_devices()): for algo in [1, 2, 3]: histo_cudh = cudh.histograms(coords, r_max, n_bins, precision="single", gpu_id=gpu_id, mask_array=mask_array, check_input=check_input, algorithm=algo) col_sum = histo_cudh.sum(axis=0) assert (np.sum(col_sum[1::2]) == 0)
# no box box = [] # --- r_max, valid when coordinates are in a unit box r_max = math.sqrt(3.0) bap = get_bap() t0 = time.time() if run_values['kernel'] == "cudh": xxxx = cudh.histograms(coords, r_max, run_values['bins'], run_values['precision'], gpu_id=gpu_id, do_histo2_only=run_values['histo2'], thread_block_x=run_values['thread_block_x'], check_input=run_values['check_input'], box=box, algorithm=run_values['gpu_algorithm'], verbose=True) else: xxxx = pydh.histograms(coords, r_max, run_values['bins'], run_values['precision'], check_input=run_values['check_input'], do_histo2_only=run_values['histo2'], n_threads=run_values['threads'], blocksize=run_values['blocksize'], box=box,