Exemplo n.º 1
0
def test_assignment_memory_model(ctx_factory):
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)

    _, discr = get_strong_wave_op_with_discr_direct(actx, dims=2, order=3)

    # Assignment instruction
    bound_op = bind(discr,
                    sym.Variable("input0", sym.DD_VOLUME) +
                    sym.Variable("input1", sym.DD_VOLUME),
                    exec_mapper_factory=ExecutionMapperWithMemOpCounting)

    input0 = discr.zeros(actx)
    input1 = discr.zeros(actx)

    result, profile_data = bound_op(profile_data={},
                                    input0=input0,
                                    input1=input1)

    assert profile_data["bytes_read"] == \
            dof_array_nbytes(input0) + dof_array_nbytes(input1)
    assert profile_data["bytes_written"] == dof_array_nbytes(result)
Exemplo n.º 2
0
def _bound_face_mass(dcoll, dd):
    u = sym.Variable("u", dd=dd)
    return bind(dcoll, sym.FaceMassOperator(dd_in=dd)(u), local_only=True)
Exemplo n.º 3
0
def _bound_inverse_mass(dcoll):
    return bind(dcoll,
                sym.InverseMassOperator()(sym.Variable("u")),
                local_only=True)
Exemplo n.º 4
0
def _bound_mass(dcoll, dd):
    return bind(dcoll,
                sym.MassOperator(dd_in=dd)(sym.Variable("u", dd)),
                local_only=True)
Exemplo n.º 5
0
def _bound_weak_d_dx(dcoll, dd, xyz_axis):
    return bind(dcoll,
                sym.stiffness_t(dcoll.dim, dd_in=dd)[xyz_axis] *
                sym.Variable("u", dd),
                local_only=True)
Exemplo n.º 6
0
def _bound_weak_grad(dcoll, dd):
    return bind(dcoll,
                sym.stiffness_t(dcoll.dim, dd_in=dd) * sym.Variable("u", dd),
                local_only=True)
Exemplo n.º 7
0
def _bound_d_dx(dcoll, xyz_axis):
    return bind(dcoll,
                sym.nabla(dcoll.dim)[xyz_axis] * sym.Variable("u"),
                local_only=True)
Exemplo n.º 8
0
def _bound_grad(dcoll):
    return bind(dcoll,
                sym.nabla(dcoll.dim) * sym.Variable("u"),
                local_only=True)
Exemplo n.º 9
0
 def _bound_grad(self):
     return bind(self, sym.nabla(self.dim) * sym.Variable("u"), local_only=True)
Exemplo n.º 10
0
 def _bound_d_dx(self, xyz_axis):
     return bind(self,
                 sym.nabla(self.dim)[xyz_axis] * sym.Variable("u"),
                 local_only=True)