Skip to content

Matrix llvmir - #11

Merged
YWHyuk merged 2 commits into
developfrom
matrix_llvmir
Jan 12, 2024
Merged

YWHyuk merged 2 commits into
developfrom
matrix_llvmir

Conversation

@YunseonShin

Copy link
Copy Markdown
Collaborator

Matrix LLVM IR Code generation is implemented.
TILE SIZE is hard coded and notified with "FIXME"

var = self.cse.generate(self.loads, line)
# stride is input row size
stride = self.ranges[-1] * align
# NOTE. Since clang 16.0 always used this constant, 2 is hard coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is unnecessarily copied

var = self.cse.generate(self.stores, line)
# stride is input row size
stride = self.ranges[-1] * align
# NOTE. Since clang 16.0 always used this constant, 2 is hard coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same one...

raise AssertionError(reduction_type)

def matrix_reduction_combine(reduction_type, start_value, vector_value):
tile_rows = 4 # FIXME. hard coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use global variable to define tile row, tile col and tile size

raise AssertionError(reduction_type)

def matrix_partial_reduction_combine(reduction_type, vector_value):
tile_rows = 4 # FIXME. hard coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated definition.

class MatrixOverrides(ExtensionOverrides):
@staticmethod
def add(operand1, operand2):
tile_size = 16 # FIXME. hard coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated definition.

self.index_cse = common.CSE(self.newvar_prefix, self.suffix, name_prefix="tmp_idx")
self.tile_size = 16 # FIXME. hard coded
self.tile_row = 4 # FIXME. hard coded
self.tile_col = 4 # FIXME. hard coded

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated definition.

for j in range(self.tile_row):
line += f"i32 {i*self.tile_row+j}, "
# replace last comma to ">"
line = line[:-2] + ">"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var = [f"i32 {i*self.tile_row+j}, " for j in self.tile_row]
var2 = ","
line.join(var)
?

else:
line = f"shufflevector <{size} x {type_name}> %{op1}, <{size} x {type_name}> %{op2}, <{size * 2} x i32> <"
for j in range(size * 2):
line += f"i32 {j}, "

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

join

reduction_vars: Dict[str, str] = None
tile_size = 16 # FIXME. hard coded
tile_row = 4
tile_col = 4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME

def codegen_loops(self):
code = common.BracesBuffer()
# Loop body part
loops = [MatrixLoopLevel(var, size, idx) for idx, (var, size) in enumerate(zip(self.itervars, self.ranges))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we use 2D tiling, number of MatrixLoopLevel would be max 2. It seems that this code can lead error

@YWHyuk

YWHyuk commented Jan 12, 2024

Copy link
Copy Markdown
Collaborator

LGTM!

@YWHyuk
YWHyuk merged commit 9df87d5 into develop Jan 12, 2024
@YWHyuk
YWHyuk deleted the matrix_llvmir branch January 13, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants