Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:SeisSol/TensorForge into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
davschneller committed May 14, 2024
2 parents 9ce5632 + 3f68a6c commit 0114898
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 271 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Ravil Dorozhinskii <[email protected]>
Yakup Budanaz <[email protected]>
David Schneller <[email protected]>

Elias Reutelsterz <[email protected]>
36 changes: 14 additions & 22 deletions example/a_atrans_bc.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
from kernelforge.common import DenseMatrix
from kernelforge.common.context import Context
from kernelforge.common.aux import generate_tmp_matrix
from kernelforge.generators.descriptions import GemmDescr, FloatingPointType, Addressing
from kernelforge.generators.generator import Generator
from kernelforge.common.matrix.boundingbox import BoundingBox
from kernelforge.common.matrix.tensor import Tensor


# Q += A x ((A^T x B) x C)

variants = {'v0': Addressing.STRIDED,
'v1': Addressing.NONE}

mat_q = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.STRIDED,
bbox=[0, 0, 20, 9])
mat_q = Tensor([56, 56], Addressing.STRIDED, BoundingBox([0,0], [20,9]))

mat_a = DenseMatrix(num_rows=56,
num_cols=56,
addressing=variants['v0'],
bbox=[0, 0, 20, 9])
mat_a = Tensor([56, 56], addressing=variants['v0'], bbox=BoundingBox([0,0], [20,9]))

mat_b = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.STRIDED,
bbox=[0, 0, 20, 9])
mat_b = Tensor([56, 56], Addressing.STRIDED, BoundingBox([0,0], [20,9]))

mat_c = DenseMatrix(num_rows=56,
num_cols=9,
bbox=[0, 0, 9, 9],
addressing=Addressing.STRIDED)
mat_c = Tensor([56, 9], Addressing.STRIDED, BoundingBox([0,0], [9,9]))


tmp1 = generate_tmp_matrix(mat_a, mat_b, True, False)
Expand All @@ -53,8 +42,11 @@
generator = Generator(gemm_list, context)
generator.generate()

print(generator.get_launcher())
print()
print(generator.get_header())
print()
print(generator.get_kernel())
with_output = True
if with_output:
print(generator.get_header())
print(generator.default_generate_call_site())
print()
print(generator.get_launcher())
print()
print(generator.get_kernel())
37 changes: 17 additions & 20 deletions example/ab_transb.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
from kernelforge.common import DenseMatrix
from kernelforge.common.context import Context
from kernelforge.common.aux import generate_tmp_matrix
from kernelforge.generators.descriptions import GemmDescr, FloatingPointType, Addressing
from kernelforge.generators.generator import Generator
from kernelforge.common.matrix.boundingbox import BoundingBox
from kernelforge.common.matrix.tensor import Tensor


# Q += (A x B^T) x B

mat_q = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.PTR_BASED,
bbox=[0, 0, 20, 9])
mat_q = Tensor([56, 56], Addressing.PTR_BASED, BoundingBox([0,0], [20,9]))

mat_a = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.NONE,
bbox=[0, 0, 20, 9])
mat_a = Tensor([56, 56], Addressing.NONE, BoundingBox([0,0], [20,9]))

mat_b = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.STRIDED,
bbox=[0, 0, 20, 9])
mat_b = Tensor([56, 56], Addressing.STRIDED, BoundingBox([0,0], [20,9]))

tmp1 = generate_tmp_matrix(mat_a, mat_b, trans_op1=False, trans_op2=True)
tmp1 = generate_tmp_matrix(mat_a, mat_b, trans_a=False, trans_b=True)

gemm_list = [GemmDescr(trans_a=False,
trans_b=True,
a=mat_a, b=mat_b, c=tmp1),
GemmDescr(trans_a=False,
trans_b=False,
a=tmp1, b=mat_b, c=mat_q)]
a=tmp1, b=mat_b, c=mat_q,
alpha=1.0,
beta=1.0)]

context = Context(arch='sm_60',
backend='cuda',
Expand All @@ -38,8 +32,11 @@
generator = Generator(gemm_list, context)
generator.generate()

print(generator.get_launcher())
print()
print(generator.get_header())
print()
print(generator.get_kernel())
with_output = True
if with_output:
print(generator.get_header())
print(generator.default_generate_call_site())
print()
print(generator.get_launcher())
print()
print(generator.get_kernel())
36 changes: 18 additions & 18 deletions example/abb_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
from kernelforge.common.aux import generate_tmp_matrix
from kernelforge.generators.descriptions import GemmDescr, FloatingPointType, Addressing
from kernelforge.generators.generator import Generator
from kernelforge.common.matrix.boundingbox import BoundingBox
from kernelforge.common.matrix.tensor import Tensor


# Q += (A x B) x B^T
mat_q = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.PTR_BASED,
bbox=[0, 0, 20, 9])

mat_a = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.NONE,
bbox=[0, 0, 20, 9])
mat_q = Tensor([56, 56], Addressing.PTR_BASED, BoundingBox([0,0], [20,9]))

mat_a = Tensor([56, 56], Addressing.NONE, BoundingBox([0,0], [20,9]))

mat_b = Tensor([56, 56], Addressing.STRIDED, BoundingBox([0,0], [9,20]))

mat_b = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.STRIDED,
bbox=[0, 0, 9, 20])

tmp1 = generate_tmp_matrix(mat_a, mat_b)

Expand All @@ -28,7 +23,9 @@
a=mat_a, b=mat_b, c=tmp1),
GemmDescr(trans_a=False,
trans_b=True,
a=tmp1, b=mat_b, c=mat_q)]
a=tmp1, b=mat_b, c=mat_q,
alpha=1.0,
beta=1.0)]

context = Context(arch='sm_60',
backend='cuda',
Expand All @@ -37,8 +34,11 @@
generator = Generator(gemm_list, context)
generator.generate()

print(generator.get_launcher())
print()
print(generator.get_header())
print()
print(generator.get_kernel())
with_output = True
if with_output:
print(generator.get_header())
print(generator.default_generate_call_site())
print()
print(generator.get_launcher())
print()
print(generator.get_kernel())
1 change: 1 addition & 0 deletions example/csa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from kernelforge import DenseMatrix, GenerationError, CsaGenerator
from kernelforge.common.vm.vm import vm_factory
import argparse
from kernelforge.backend.instructions.csa import CSA


parser = argparse.ArgumentParser(description='Specify Backend and Arch of the GPU')
Expand Down
34 changes: 11 additions & 23 deletions example/five_multiplies.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,37 @@
from kernelforge.common.matrix.dense import DenseMatrix
from kernelforge.common.context import Context
from kernelforge.common.aux import generate_tmp_matrix
from kernelforge.generators.descriptions import GemmDescr
from kernelforge.common.basic_types import FloatingPointType, Addressing
from kernelforge.generators.generator import Generator
from kernelforge.common.matrix.boundingbox import BoundingBox
from kernelforge.common.matrix.tensor import Tensor


# Q = (((A x B) x (C x B)) x D)
mat_q = DenseMatrix(num_rows=56,
num_cols=9,
addressing=Addressing.STRIDED,
bbox=[0, 0, 56, 9],)

mat_a = DenseMatrix(num_rows=56,
num_cols=56,
addressing=Addressing.STRIDED,
bbox=[0, 0, 56, 56])
mat_q = Tensor([9, 9], Addressing.STRIDED, BoundingBox([0,0], [9,9]))

mat_b = DenseMatrix(num_rows=56,
num_cols=9,
addressing=Addressing.STRIDED,
bbox=[0, 0, 56, 9])
mat_a = Tensor([56, 56], Addressing.STRIDED, BoundingBox([0,0], [56,56]))

mat_c = DenseMatrix(num_rows=56,
num_cols=56,
bbox=[0, 0, 56, 56],
addressing=Addressing.STRIDED)
mat_b = Tensor([56, 9], Addressing.STRIDED, BoundingBox([0,0], [56,9]))

mat_c = Tensor([56, 56], Addressing.STRIDED, BoundingBox([0,0], [56,56]))

mat_d = Tensor([9, 9], Addressing.STRIDED, BoundingBox([0,0], [9,9]))

mat_d = DenseMatrix(num_rows=9,
num_cols=9,
bbox=[0, 0, 9, 9],
addressing=Addressing.STRIDED)


tmp0 = generate_tmp_matrix(mat_a, mat_b)
tmp1 = generate_tmp_matrix(mat_c, mat_b)
tmp2 = generate_tmp_matrix(tmp0, tmp1)
tmp2 = generate_tmp_matrix(tmp0, tmp1, trans_a=True)

gemm_list = [GemmDescr(trans_a=False,
trans_b=False,
a=mat_a, b=mat_b, c=tmp0),
GemmDescr(trans_a=False,
trans_b=False,
a=mat_c, b=mat_b, c=tmp1),
GemmDescr(trans_a=False, trans_b=False,
GemmDescr(trans_a=True, trans_b=False,
a=tmp0, b=tmp1, c=tmp2),
GemmDescr(trans_a=False, trans_b=False,
a=tmp2, b=mat_d, c=mat_q,
Expand Down
41 changes: 0 additions & 41 deletions example/four_matrices_test.py

This file was deleted.

19 changes: 6 additions & 13 deletions example/gemm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from kernelforge.common.matrix.dense import DenseMatrix
from kernelforge.common.context import Context
from kernelforge.common.aux import generate_tmp_matrix
from kernelforge.generators.descriptions import GemmDescr
from kernelforge.common.basic_types import FloatingPointType, Addressing
from kernelforge.generators.generator import Generator
from kernelforge.common.exceptions import GenerationError
import argparse
from kernelforge.common.matrix.boundingbox import BoundingBox
from kernelforge.common.matrix.tensor import Tensor


parser = argparse.ArgumentParser(description="Specify Backend and Arch of the GPU")
Expand All @@ -23,20 +24,12 @@

args = parser.parse_args()

mat_a = DenseMatrix(num_rows=56,
num_cols=18,
addressing=Addressing.STRIDED,
bbox=[0, 0, 56, 18])
mat_a = Tensor([56, 18], Addressing.STRIDED, BoundingBox([0,0], [56,18]))

mat_b = DenseMatrix(num_rows=18,
num_cols=18,
addressing=Addressing.STRIDED,
bbox=[0, 0, 18, 18])
mat_b = Tensor([18, 18], Addressing.STRIDED, BoundingBox([0,0], [18,18]))

mat_c = Tensor([56, 18], Addressing.STRIDED, BoundingBox([0,0], [56,18]))

mat_c = DenseMatrix(num_rows=56,
num_cols=18,
bbox=[0, 0, 56, 18],
addressing=Addressing.STRIDED)

try:
vm = Context(arch=args.arch, backend=args.backend, fp_type=FloatingPointType.FLOAT)
Expand Down
50 changes: 0 additions & 50 deletions example/mat-vec.py

This file was deleted.

Loading

0 comments on commit 0114898

Please sign in to comment.