def __init__(self, sampling_rate: int, topology_name: str, source: Type['Source']): self.sampling_rate = sampling_rate self.topology_name = topology_name self.electrode_topology = get_topology(topology_name) self.nchannels = len(self.electrode_topology) self.Source = source # type: Type['Source']
def run_tests(): tests = ['Methane Dimer', 'Water Dimer', 'Benzene dimer'] N_tests = len(tests) test_energy_file = test_dir + '/energy_tests.dat' test_energies = fileio.get_file_string_array(test_energy_file) for i in range(N_tests): test_energies[i] = float(test_energies[i][0]) ALL_SUCCESS = 1 for i in range(N_tests): test_prefix = test_dir + '/test%i' % (i + 1) dimer_file = test_prefix + '_dimer.xyzq' monoA_file = test_prefix + '_monoA.xyzq' monoB_file = test_prefix + '_monoB.xyzq' dimer_geom = fileio.get_geom(dimer_file) monoA_geom = fileio.get_geom(monoA_file) monoB_geom = fileio.get_geom(monoB_file) dimer_topology = topology.get_topology(dimer_geom) monoA_topology = topology.get_topology(monoA_geom) monoB_topology = topology.get_topology(monoB_geom) dimer_energy = energy.get_e_nonbond(dimer_geom, dimer_topology) monoA_energy = energy.get_e_nonbond(monoA_geom, monoA_topology) monoB_energy = energy.get_e_nonbond(monoB_geom, monoB_topology) int_energy = dimer_energy - (monoA_energy + monoB_energy) reference_energy = test_energies[i] TEST_PASS = are_equal(int_energy, reference_energy, 10**test_thresh) if (TEST_PASS): print 'Test %i PASS %15.10f (%s)' % (i + 1, int_energy, tests[i]) else: print 'Test %i FAIL %15.10f (%s)' % (i + 1, int_energy, tests[i]) ALL_SUCCESS *= TEST_PASS if (ALL_SUCCESS): print 'All Tests PASS' else: print 'Some Tests FAIL' return ALL_SUCCESS
def do_GET(self): start = time.time() response = {} try: if self.path.startswith('/api/allocation'): allocation = topology.get_allocation() response = copy.deepcopy(allocation) elif self.path.startswith('/api/inspect'): response = topology.inspect() elif self.path.startswith('/api/topology'): response = topology.get_topology() else: self.send_error(404) return except Exception as e: response = {} response['error'] = repr(e) traceback.print_exc(file=sys.stdout) response['time'] = '{0:.2f}'.format(time.time() - start) self.send_response(200) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(json.dumps(response)) return
def main(args): check_setup() print("Setting up control groups...") for cg in all_cgroups: cgroup.cgdelete(cg) if 0 != cgroup.cgcreate(cg): print("Could not create control group %s." % cg) exit(1) topo = topology.get_topology() print("Topology: %u Package x %u Cores x %u Threads" % (len(topo), len(topo[0].core), len(topo[0].core[0].thread))) if (len(topo[-1].core) < 3): print("ERROR: We need 3 cores in a package for optimal thread pinning.") if not "--ignore-warnings" in args: exit(1) any_cpu = "1-64" switch_cpus = any_cpu server_cpus = any_cpu client_cpus = any_cpu else: core_list = topo[-1].core[-4:] switch_cpu = core_list[1].thread[-1] print("Switch CPU is %s." % switch_cpu) print("Let the benchmarking commence!") try: start_time = time.time() tso = [False, True] irqr_v = [10000, 0] configurations = [ x for x in itertools.product(tso, irqr_v)] for conf in configurations: tsov, irqr = conf run_vhost_benchmark(tsov, irqr) poll_v = [0] batch_v = [16] configurations = [ x for x in itertools.product(tso, poll_v, batch_v, irqr_v)] for n in range(len(configurations)): remaining_experiments = len(configurations) - n elapsed = time.time() - start_time # We count the vhost experiment here as well. print("\n=== Remaining time %.2fh. ===\n" % ((remaining_experiments * (elapsed / (n+1))) / (60*60))) tso, poll_us, batch_size, irq_rate = configurations[n] print("TSO %s, poll %d, batch %d, irqr %u" % (tso, poll_us, batch_size, irq_rate)) run_externalpci_benchmark([switch_cpu], tso, poll_us, batch_size, irq_rate) finally: global experiments if len(experiments) > 0: filename = datetime.datetime.today().strftime("results-%Y%m%d-%H%m%S.json.gz") with gzip.open(filename, "wb") as f: f.write(json.dumps(experiments)) print("Written %s." % filename)
def test_get_topology2(self): password = "******" self.assertEquals(password, get_topology("password"))
def test_get_topology1(self): specials = "?s?s?s?s?s" self.assertEquals(specials, get_topology(".^!@%"))
def test_get_topology4(self): self.assertEquals("", get_topology(None))
def test_get_topology3(self): mix = "?u?s?l?l?l?l?n?n" self.assertEquals(mix, get_topology("P@sswo63"))