[llvm-dev] Determination of statements that contain only matrix multiplication

Roman Gareev via llvm-dev llvm-dev at lists.llvm.org
Mon May 16 10:52:23 PDT 2016


Hi Tobias,

could we use information about memory accesses of a SCoP statement and
def-use chains to determine statements, which don’t contain matrix
multiplication of the following form?

for (int i = 0; i < Upper Bound1; i++)
  for (int j = 0; j < Upper Bound2; j++)
    for (int k = 0; k < Upper Bound3; j++)
      C[i][j] += A[i][k] * B[k][j]

We could probably check that memory access relations have the following form:

"accesses" : [
  {
    "kind" : "read",
    "relation" : "{ Stmt_14[i0, i1, i2] -> MemRef_1[i0, i2] }"
  },
  {
    "kind" : "read",
    "relation" : "{ Stmt_14[i0, i1, i2] -> MemRef_2[i2, i1] }"
  },
  {
    "kind" : "read",
    "relation" : "{ Stmt_14[i0, i1, i2] -> MemRef_3[i0, i1] }"
  },
  {
    "kind" : "write",
    "relation" : "{ Stmt_14[i0, i1, i2] -> MemRef_4[i0, i1] }"
  }
]

and there are the following relations between access instructions of
the memory accesses:

AccessInst1 --- def-use --- \
AccessInst2 --- def-use --- fmul
                                            |
                                       def-use
                                            |
AccessInst3 --- def-use --- fadd
                                            |
                                       def-use
                                            |
                                 store (AccessInst4)

(fmul is a user of AccessInst1 and AccessInst2. fadd is a user of the
fmul and AccessInst3. store (AccessInst4) is a user of fadd)

Maybe it could be a temporary solution. I think that if the checks are
successfully passed and the basic block of the statement has exactly
14 instructions, the statement contains matrix multiplication and can
be safely optimized with a generation of specific code, which takes
into account information about usage of SIMD registers.

I have one more question. Are memory accesses of MemAccs from the
ScopStmt class ordered by their sequence order?

-- 
                                    Cheers, Roman Gareev.


More information about the llvm-dev mailing list