Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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())
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
# --- import the pydh module
from cadishi.kernel import pydh

# --- import the cudh module
if TEST_CUDH:
    try:
        from cadishi.kernel import cudh
    except Exception as e:
        print("Error importing >> cudh <<.  Disabling CUDA tests.")
        print("Exception message : " + e.message)
        TEST_CUDH = False

if TEST_CUDH:
    # test if we are able to run the tests at all
    if (cudh.get_num_devices() == 0):
        print("No usable CUDA device detected.  Disabling CUDA tests.")
        TEST_CUDH = False
    else:
        print("CUDA tests: " + str(cudh.get_num_devices()) + " GPUs detected.")


def get_triclinic_box():
    """Return an (arbitrarily defined) triclinic box."""
    return np.asarray([0.66, 0.75, 0.88, 33., 45., 66.])


def get_orthorhombic_triclinic_box():
    """Return an (arbitrarily defined) orthorhombic box (using a triclinic specifier)."""
    return np.asarray([0.66, 0.75, 0.88, 90., 90., 90.])