Пример #1
0
    def __init__(self, ha, hylaa_settings):

        assert isinstance(hylaa_settings, HylaaSettings)
        assert isinstance(ha, LinearHybridAutomaton)

        if not openblas.has_openblas():
            print "Performance warning: OpenBLAS not detected. Matrix operations may be slower than necessary."
            print "Is numpy linked with OpenBLAS? (hylaa.operblas.has_openblas() returned False)"

        if hylaa_settings.simulation.threads is not None:
            openblas.set_num_threads(hylaa_settings.simulation.threads)

        self.hybrid_automaton = ha
        self.settings = hylaa_settings
        self.num_vars = len(ha.variables)

        if self.settings.plot.plot_mode != PlotSettings.PLOT_NONE:
            Star.init_plot_vecs(self.num_vars, self.settings.plot)

        self.plotman = PlotManager(self, self.settings.plot)

        # computation
        self.waiting_list = WaitingList()

        self.cur_state = None  # a Star object
        self.cur_step_in_mode = None  # how much dwell time in current continuous post
        self.max_steps_remaining = None  # bound on num steps left in current mode ; assigned on pop
        self.cur_sim_bundle = None  # set on pop

        self.reached_error = False
        self.result = None  # a HylaaResult... assigned on run()

        if self.settings.plot.plot_mode == PlotSettings.PLOT_NONE:
            self.settings.simulation.use_presimulation = True
Пример #2
0
size 2000, time = 5.54
size 4000, time = 45.93

With OpenBLAS:
size 1000, time = 0.04
size 2000, time = 0.14
size 4000, time = 0.60
'''

import numpy as np
import time
from hylaa.openblas import has_openblas

def mult(size):
    a = np.random.rand(size, size)
    b = np.random.rand(size, size)

    start = time.time()

    np.dot(a, b)

    diff = time.time() - start
    print("size {}, time = {:.2f}".format(size, diff))

print("OpenBLAS detected: {}".format(has_openblas()))
mult(1000)
mult(2000)
mult(4000)