Example #1
0
def test_melody_set_values():
    '''check that values are stored correctly if directly set'''
    function = "function"
    method = "method"
    inputs = "inputs"
    melody = Melody()
    melody.function = function
    melody.method = method
    melody.inputs = inputs
    assert melody.function == function
    assert melody.inputs == inputs
    assert melody.method == method
Example #2
0
def test_melody_search(capsys):
    '''check that melody search runs when we provide a valid set of inputs'''
    from melody.inputs import Choice
    from melody.search import BruteForce
    inputs = [Choice(name="c", inputs=["c1", "c2"])]

    def function(input_var):
        '''test function'''
        return 0, input_var

    search_method = BruteForce
    melody = Melody(method=search_method, inputs=inputs, function=function)
    melody.search()
    out, _ = capsys.readouterr()
    assert "[{'c': 'c1'}] 0 [{'c': 'c1'}]" in out
    assert "[{'c': 'c2'}] 0 [{'c': 'c2'}]" in out
Example #3
0
def test_melody_vanilla():
    '''check that initial values are set to None if they are not
    provided'''
    melody = Melody()
    assert melody.function is None
    assert melody.inputs is None
    assert melody.method is None
    assert melody._state is None
Example #4
0
def test_melody_initial_values():
    '''check that values are stored correctly if provided at initialisation'''
    function = "function"
    method = "method"
    state = "state"
    inputs = "inputs"
    melody = Melody(function=function,
                    method=method,
                    state=state,
                    inputs=inputs)
    assert melody.function == function
    assert melody.inputs == inputs
    assert melody.method == method
    assert melody._state == state
Example #5
0
                        siblings = loop.parent.children
                        my_index = siblings.index(loop)
                        option = []
                        self._recurse(siblings, my_index, option, my_options,
                                      invoke)

        return my_options

    @property
    def name(self):
        '''Returns the name of the melody input class'''
        return self._name


FILE = ("shallow/shallow_alg.f90")
_, INVOKE_INFO = parse(FILE, api="gocean1.0")
PSY = PSyFactory("gocean1.0").create(INVOKE_INFO)

# TBD   ArrayBounds(),
INPUTS = [
    GOLoopFuse(),
    ModuleInline(PSY),
    Choice(name="Problem Size", inputs=["64", "128", "256", "512", "1024"])
]

MELODY = Melody(inputs=INPUTS,
                function=test_function,
                state=PSY,
                method=BruteForce)
MELODY.search()
Example #6
0
# *** try different inline-limit values
# -fwhole-program needs to be part of compile and fails as we link timer
# libraries Switch(name="Single program", on="-fwhole-program"),
# flto needs to be on both compile and link as do all optimisation options

# ignore lower levels of optimisation
#    Choice(name="F90FLAGS", inputs=["", "-O", "-O1", "-O2", "-O3", "-Ofast"]),

# start with one problem size to limit the time
#    Choice(name="Problem Size", inputs=["64", "128", "256"])]

# 512 and 1024 take too long to run
#    Choice(name="Problem Size", inputs=["64", "128", "256", "512", "1024"])]

# unsupported in my version of gfortran
#    Choice(name="Vector Cost Model", pre="-fvect-cost-model=",
#           inputs=["unlimited", "dynamic", "cheap"]),

# ignored for the moment
#    Switch(name="Stores Out Of Loops", on="-fgcse-sm"),
#    Switch(name="Remove Redundant Loads", on="-fgcse-las"),
#    Switch(name="Loop Nests", on="-floop-nest-optimize"),
#    Switch(name="Maths Optimisations", on="-funsafe-math-optimizations"),
#    Switch(name="No Nans and infs", on="-ffinite-math-only"),
#    Switch(name="No user traps", on="-fno-trapping-math"),
#    Switch(name="No signed zeros", on="-fno-signed-zeros"),
#    Switch(name="Always unroll", on="-funroll-all-loops"),

MELODY = Melody(inputs=INPUTS, function=execute, method=BruteForce)
MELODY.search()