Beispiel #1
0
 def test_pydh_invalid_small_single(fixture_small_invalid):
     n_atoms, n_bins, coords, histo_ref = fixture_small_invalid
     with pytest.raises(ValueError):
         pydh.histograms(coords,
                         r_max,
                         n_bins,
                         precision="single",
                         n_threads=1,
                         check_input=True)
Beispiel #2
0
 def test_pydh_invalid_threads_small_double(fixture_small_invalid):
     n_atoms, n_bins, coords, histo_ref = fixture_small_invalid
     for nt in n_threads:
         with pytest.raises(ValueError):
             pydh.histograms(coords,
                             r_max,
                             n_bins,
                             precision="double",
                             n_threads=nt,
                             check_input=True)
Beispiel #3
0
def minimal_driver():
    DUMP_DATA = bool(int(os.environ.get("DUMP_DATA", "0")))
    n_atoms = [32768]
    n_bins = 16384
    coords = util.generate_random_coordinate_set(n_atoms)

    box = None
    # box = get_triclinic_box()
    # box = get_orthorhombic_box()
    force_triclinic = False

    # box = get_orthorhombic_triclinic_box()
    # force_triclinic = True

    histo = pydh.histograms(coords,
                            r_max,
                            n_bins,
                            box=box,
                            precision="double",
                            force_triclinic=force_triclinic,
                            n_threads=util.get_n_cpu_cores(),
                            verbose=True)

    if DUMP_DATA:
        file_name = sys._getframe().f_code.co_name + ".dat"
        util.dump_histograms(file_name, histo, r_max, n_bins)
Beispiel #4
0
 def test_pydh_large_single(fixture_large):
     n_atoms, n_bins, coords, histo_ref = fixture_large
     histo_pydh = pydh.histograms(coords,
                                  r_max,
                                  n_bins,
                                  precision="single",
                                  n_threads=1)
     util.compare(histo_ref, histo_pydh)
Beispiel #5
0
 def test_n_threads_xlarge_single(fixture_xlarge):
     n_atoms, n_bins, coords, histo_ref = fixture_xlarge
     for nt in n_threads:
         histo_pydh = pydh.histograms(coords,
                                      r_max,
                                      n_bins,
                                      precision="single",
                                      n_threads=nt)
         util.compare(histo_ref, histo_pydh)
Beispiel #6
0
 def test_pydh_medium_manybins_single(fixture_medium_manybins):
     n_atoms, n_bins, coords, histo_ref = fixture_medium_manybins
     for check_input in [True, False]:
         histo_pydh = pydh.histograms(coords,
                                      r_max,
                                      n_bins,
                                      precision="single",
                                      n_threads=1,
                                      check_input=check_input)
         util.compare(histo_ref, histo_pydh)
Beispiel #7
0
 def test_n_threads_medium_double(fixture_medium):
     n_atoms, n_bins, coords, histo_ref = fixture_medium
     for check_input in [True, False]:
         for nt in n_threads:
             histo_pydh = pydh.histograms(coords,
                                          r_max,
                                          n_bins,
                                          precision="double",
                                          n_threads=nt,
                                          check_input=check_input)
             util.compare(histo_ref, histo_pydh)
Beispiel #8
0
 def test_pydh_small_single(fixture_small):
     """Test if pydh gives the same answer as dist()."""
     n_atoms, n_bins, coords, histo_ref = fixture_small
     for check_input in [True, False]:
         histo_pydh = pydh.histograms(coords,
                                      r_max,
                                      n_bins,
                                      precision="single",
                                      n_threads=1,
                                      check_input=check_input)
         util.compare(histo_ref, histo_pydh)
Beispiel #9
0
 def test_pydh_small_double_blocked(fixture_small):
     n_atoms, n_bins, coords, histo_ref = fixture_small
     for check_input in [True, False]:
         for nt in n_threads:
             histo_blocked = pydh.histograms(coords,
                                             r_max,
                                             n_bins,
                                             precision="double",
                                             n_threads=nt,
                                             blocksize=200,
                                             check_input=check_input)
             util.compare(histo_ref, histo_blocked)
Beispiel #10
0
 def test_pydh_small_triclinic_single(fixture_small_triclinic):
     """Test if the triclinic implementation gives the same answer in single precision."""
     n_atoms, n_bins, coords, box, histo_ref = fixture_small_triclinic
     for check_input in [True, False]:
         histo = pydh.histograms(coords,
                                 r_max,
                                 n_bins,
                                 box=box,
                                 precision="single",
                                 n_threads=1,
                                 check_input=check_input)
         util.compare(histo_ref, histo)
Beispiel #11
0
 def fixture_large():
     global testcase_large
     if testcase_large is None:
         n_atoms = [105000, 110000, 133000]
         n_bins = 16000
         coords = util.generate_random_coordinate_set(n_atoms)
         # --- note that we use pydh to generate the test dataset
         histo_ref = pydh.histograms(coords,
                                     r_max,
                                     n_bins,
                                     precision="double",
                                     n_threads=n_threads[-1])
         testcase_large = (n_atoms, n_bins, coords, histo_ref)
     return testcase_large
Beispiel #12
0
 def test_pydh_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]:
         histo_pydh = pydh.histograms(coords,
                                      r_max,
                                      n_bins,
                                      precision="single",
                                      n_threads=1,
                                      scale_factors=scale_factors,
                                      check_input=check_input)
         assert (histo_ref.sum() == 2.0 * histo_pydh.sum())
Beispiel #13
0
 def fixture_xlarge():
     global testcase_xlarge
     if testcase_xlarge is None:
         n_atoms = [250000, 275000, 225000]
         n_bins = 18000
         coords = util.generate_random_coordinate_set(n_atoms)
         # --- note that we use pydh to generate the test dataset, max number of threads and no blocking
         histo_ref = pydh.histograms(coords,
                                     r_max,
                                     n_bins,
                                     precision="double",
                                     n_threads=n_threads[-1],
                                     blocksize=-1)
         testcase_xlarge = (n_atoms, n_bins, coords, histo_ref)
     return testcase_xlarge
Beispiel #14
0
 def test_pydh_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]:
             histo_ort = pydh.histograms(coords,
                                         r_max,
                                         n_bins,
                                         box=box_ort,
                                         force_triclinic=False,
                                         precision=precision,
                                         n_threads=1,
                                         check_input=check_input)
             histo_tri = pydh.histograms(coords,
                                         r_max,
                                         n_bins,
                                         box=box_tri,
                                         force_triclinic=True,
                                         precision=precision,
                                         n_threads=1,
                                         check_input=check_input)
             util.compare(histo_ort, histo_tri)
Beispiel #15
0
 def test_pydh_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]:
         histo_pydh = pydh.histograms(coords,
                                      r_max,
                                      n_bins,
                                      precision="single",
                                      n_threads=1,
                                      mask_array=mask_array,
                                      check_input=check_input)
         col_sum = histo_pydh.sum(axis=0)
         assert (np.sum(col_sum[1::2]) == 0)
Beispiel #16
0
def fixture_small_triclinic():
    """Create a triclinic reference case in double precision using pydh."""
    global testcase_small_triclinic
    if testcase_small_triclinic is None:
        n_atoms = [2847, 3918]
        n_bins = 1000
        coords = util.generate_random_coordinate_set(n_atoms)
        box = get_triclinic_box()
        histo = pydh.histograms(coords,
                                r_max,
                                n_bins,
                                box=box,
                                precision="double",
                                n_threads=1)
        testcase_small_triclinic = (n_atoms, n_bins, coords, box, histo)
    return testcase_small_triclinic
Beispiel #17
0
                           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,
                           verbose=True)
t1 = time.time()
dt = (t1 - t0)

bapps = old_div(bap, dt)

run_values['bap'] = bap
run_values['time'] = dt
run_values['bapps'] = bapps

if not run_values['silent']:
    vals = [x + ":" + str(run_values[x]) for x in output_keys]