예제 #1
0
def test_illegal_compile():
    from firedrake.slate.slac import compile_expression as compile_slate
    V = FunctionSpace(UnitSquareMesh(1, 1), "CG", 1)
    v = TestFunction(V)
    form = v * dx
    with pytest.raises(ValueError):
        compile_slate(form)
def test_illegal_compile():
    from firedrake.slate.slac import compile_expression as compile_slate
    V = FunctionSpace(UnitSquareMesh(1, 1), "CG", 1)
    v = TestFunction(V)
    form = v * dx
    with pytest.raises(ValueError):
        compile_slate(form)
예제 #3
0
def test_determinism(tensor):
    """Tests that the :meth:'compile_slate_expression' forms
    a numerically deterministic system. That is, produced kernels
    are consistent.
    """
    kernel1 = compile_slate(tensor)
    kernel2 = compile_slate(tensor)

    # Checking equivalence of kernels
    assert kernel1[0].kinfo.kernel._ast == kernel2[0].kinfo.kernel._ast
예제 #4
0
def test_determinism_and_caching(tensor):
    """Tests that the :meth:'compile_slate_expression' forms
    a numerically deterministic system. That is, produced kernels
    are consistent.

    This test also checks that the caching mechanism is functioning
    properly.
    """
    A = tensor
    # Reconstruct an identical tensor, but as a different instance
    # of a Tensor
    B = Tensor(tensor.form)
    kernel1 = compile_slate(A)
    kernel2 = compile_slate(B)

    # Checking equivalence of kernels
    assert kernel1 is kernel2

    # Changing TSFC parameters should change kernel
    kernel3 = compile_slate(B, {"mode": "vanilla"})
    assert kernel3 is not kernel2

    for k1, k2 in zip(kernel1, kernel3):
        assert k1 is not k2
예제 #5
0
def test_determinism_and_caching(tensor):
    """Tests that the :meth:'compile_slate_expression' forms
    a numerically deterministic system. That is, produced kernels
    are consistent.

    This test also checks that the caching mechanism is functioning
    properly.
    """
    A = tensor
    # Reconstruct an identical tensor, but as a different instance
    # of a Tensor
    B = Tensor(tensor.form)
    kernel1 = compile_slate(A)
    kernel2 = compile_slate(B)

    # Checking equivalence of kernels
    assert kernel1[0].kinfo.kernel._ast == kernel2[0].kinfo.kernel._ast

    # Checking cached kernels (they should be identical to previous one)
    kernel_1a = compile_slate(B)  # Should be the same as A
    _kernels = A._metakernel_cache

    assert kernel_1a[0].kinfo.kernel._ast == kernel1[0].kinfo.kernel._ast
    assert _kernels[0].kinfo.kernel._ast == kernel1[0].kinfo.kernel._ast
예제 #6
0
def test_determinism_and_caching(tensor):
    """Tests that the :meth:'compile_slate_expression' forms
    a numerically deterministic system. That is, produced kernels
    are consistent.

    This test also checks that the caching mechanism is functioning
    properly.
    """
    A = tensor
    # Reconstruct an identical tensor, but as a different instance
    # of a Tensor
    B = Tensor(tensor.form)
    kernel1 = compile_slate(A)
    kernel2 = compile_slate(B)

    # Checking equivalence of kernels
    assert kernel1 is kernel2

    # Changing TSFC parameters should change kernel
    kernel3 = compile_slate(B, {"mode": "vanilla"})
    assert kernel3 is not kernel2

    for k1, k2 in zip(kernel1, kernel3):
        assert k1 is not k2