示例#1
0
    def test_iteration_index_order_matters_with_mat(self, backend, skip_opencl,
                                                    iterset, x, iter2ind1,
                                                    mat):
        self.cache.clear()
        assert len(self.cache) == 0
        self.cache_hit.clear()
        assert len(self.cache_hit) == 0
        plan1 = plan.Plan(iterset.all_part,
                          mat(op2.INC,
                              (iter2ind1[op2.i[0]], iter2ind1[op2.i[1]])),
                          x(op2.READ, iter2ind1[0]),
                          partition_size=10,
                          matrix_coloring=True)

        op2.base._trace.evaluate(set([mat]), set())
        assert len(self.cache) == 1
        assert self.cache_hit[plan1] == 1
        plan2 = plan.Plan(iterset.all_part,
                          mat(op2.INC,
                              (iter2ind1[op2.i[1]], iter2ind1[op2.i[0]])),
                          x(op2.READ, iter2ind1[0]),
                          partition_size=10,
                          matrix_coloring=True)

        op2.base._trace.evaluate(set([mat]), set())
        assert len(self.cache) == 2
        assert plan1 is not plan2
        assert self.cache_hit[plan1] == 1
        assert self.cache_hit[plan2] == 1
示例#2
0
    def test_thread_coloring(self, backend, skip_opencl, elements,
                             elem_node_map, elem_node, mat, x):
        assert NUM_ELE % 2 == 0, "NUM_ELE must be even."

        plan = _plan.Plan(elements.all_part,
                          mat(op2.INC,
                              (elem_node[op2.i[0]], elem_node[op2.i[1]])),
                          x(op2.WRITE, elem_node[0]),
                          partition_size=NUM_ELE / 2,
                          matrix_coloring=True)

        assert plan.nblocks == 2
        eidx = 0
        for p in range(plan.nblocks):
            for thrcol in range(plan.nthrcol[p]):
                counter = numpy.zeros(NUM_NODES, dtype=numpy.uint32)
                for e in range(eidx, eidx + plan.nelems[p]):
                    if plan.thrcol[e] == thrcol:
                        counter[elem_node.values[e][0]] += 1
                assert (counter < 2).all()

            eidx += plan.nelems[p]