# Changeset View

# Standalone View

# lib/Transform/ScheduleOptimizer.cpp

Show First 20 Lines • Show All 861 Lines • ▼ Show 20 Lines | createExtensionNode(__isl_take isl_schedule_node *Node, | ||||

auto *NewNode = isl_schedule_node_from_extension(Extension); | auto *NewNode = isl_schedule_node_from_extension(Extension); | ||||

return isl_schedule_node_graft_before(Node, NewNode); | return isl_schedule_node_graft_before(Node, NewNode); | ||||

} | } | ||||

/// Apply the packing transformation. | /// Apply the packing transformation. | ||||

/// | /// | ||||

/// The packing transformation can be described as a data-layout | /// The packing transformation can be described as a data-layout | ||||

/// transformation that requires to introduce a new array, copy data | /// transformation that requires to introduce a new array, copy data | ||||

/// to the array, and change memory access locations of the compute kernel | /// to the array, and change memory access locations to reference the array. | ||||

/// to reference the array. | /// It can be used to ensure that elements of the new array are read in-stride | ||||

/// access, aligned to cache lines boundaries, and preloaded into certain cache | |||||

/// levels. | |||||

/// | |||||

/// As an example let us consider the packing of the array A that would help | |||||

/// to read its elements with in-stride access. An access to the array A | |||||

/// is represented by an access relation that has the form | |||||

/// S[i, j, k] -> A[i, k]. The scheduling function of the SCoP statement S has | |||||

/// the form S[i,j, k] -> [floor((j mod Nc) / Nr), floor((i mod Mc) / Mr), | |||||

/// k mod Kc, j mod Nr, i mod Mr]. | |||||

/// | |||||

/// To ensure that elements of the array A are read in-stride access, we add | |||||

/// a new array Packed_A[Mc/Mr][Kc][Mr] to the SCoP, using | |||||

/// Scop::createScopArrayInfo(), change the access relation | |||||

/// S[i, j, k] -> A[i, k] to | |||||

/// S[i, j, k] -> Packed_A[floor((i mod Mc) / Mr), k mod Kc, i mod Mr], using | |||||

/// MemoryAccess::setNewAccessRelation, and copy the data to the array, using | |||||

/// the copy statement created by Scop::addScopStmt. | |||||

/// | /// | ||||

/// @param Node The schedule node to be optimized. | /// @param Node The schedule node to be optimized. | ||||

/// @param MapOldIndVar The relation, which maps original induction variables | /// @param MapOldIndVar The relation, which maps original induction variables | ||||

grosser: access relation | |||||

/// to the ones, which are produced by schedule | /// to the ones, which are produced by schedule | ||||

/// transformations. | /// transformations. | ||||

/// @param MicroParams, MacroParams Parameters of the BLIS kernel | /// @param MicroParams, MacroParams Parameters of the BLIS kernel | ||||

/// to be taken into account. | /// to be taken into account. | ||||

/// @return The optimized schedule node. | /// @return The optimized schedule node. | ||||

static __isl_give isl_schedule_node *optimizeDataLayoutMatrMulPattern( | static __isl_give isl_schedule_node *optimizeDataLayoutMatrMulPattern( | ||||

__isl_take isl_schedule_node *Node, __isl_take isl_map *MapOldIndVar, | __isl_take isl_schedule_node *Node, __isl_take isl_map *MapOldIndVar, | ||||

MicroKernelParamsTy MicroParams, MacroKernelParamsTy MacroParams) { | MicroKernelParamsTy MicroParams, MacroKernelParamsTy MacroParams) { | ||||

Not Done ReplyInline ActionsThis is a mouthful to read and I cannot take any additional information from it. If show this here to illustrate the space of these isl_maps, I'd suggest to shorten it to something like If it is for showing a numerical example, this is way to complicated. It would be better if you would construct an illustrative example by hand that only contains the relevant parts instead of dumping something from a test case. Meinersbur: This is a mouthful to read and I cannot take any additional information from it. If show this… | |||||

Not Done ReplyInline ActionsHi Roman, AFAIR the access functions in this comment can indeed be further simplified, no? grosser: Hi Roman,
AFAIR the access functions in this comment can indeed be further simplified, no? | |||||

// Check whether memory accesses of the SCoP statement correspond to | // Check whether memory accesses of the SCoP statement correspond to | ||||

// the matrix multiplication pattern and if this is true, obtain them. | // the matrix multiplication pattern and if this is true, obtain them. | ||||

auto InputDimsId = isl_map_get_tuple_id(MapOldIndVar, isl_dim_in); | auto InputDimsId = isl_map_get_tuple_id(MapOldIndVar, isl_dim_in); | ||||

auto *Stmt = static_cast<ScopStmt *>(isl_id_get_user(InputDimsId)); | auto *Stmt = static_cast<ScopStmt *>(isl_id_get_user(InputDimsId)); | ||||

isl_id_free(InputDimsId); | isl_id_free(InputDimsId); | ||||

MemoryAccess *MemAccessA = identifyAccessA(Stmt); | MemoryAccess *MemAccessA = identifyAccessA(Stmt); | ||||

MemoryAccess *MemAccessB = identifyAccessB(Stmt); | MemoryAccess *MemAccessB = identifyAccessB(Stmt); | ||||

Not Done ReplyInline ActionsHow did we get to this?
Meinersbur: How did we get to this?
`{ Stmt_for_body6[i0, i1, i2] -> [o0, o1, o2] ... }` is a scatter… | |||||

Not Done ReplyInline ActionsI mixed up something here. It has the space of a scatter function, but probably only the target array (eg. Meinersbur: I mixed up something here. It has the space of a scatter function, but probably only the target… | |||||

if (!MemAccessA || !MemAccessB) { | if (!MemAccessA || !MemAccessB) { | ||||

Not Done ReplyInline Actions
Meinersbur: `setNewAccessRelation` is only the setter method updating the data, about as interesting as `MA… | |||||

isl_map_free(MapOldIndVar); | isl_map_free(MapOldIndVar); | ||||

return Node; | return Node; | ||||

} | } | ||||

// Create a copy statement that corresponds to the memory access to the | // Create a copy statement that corresponds to the memory access to the | ||||

// matrix B, the second operand of the matrix multiplication. | // matrix B, the second operand of the matrix multiplication. | ||||

Node = isl_schedule_node_parent(isl_schedule_node_parent(Node)); | Node = isl_schedule_node_parent(isl_schedule_node_parent(Node)); | ||||

Node = isl_schedule_node_parent(isl_schedule_node_parent(Node)); | Node = isl_schedule_node_parent(isl_schedule_node_parent(Node)); | ||||

▲ Show 20 Lines • Show All 405 Lines • Show Last 20 Lines |

access relation