diff --git a/sw/apps/atax/scripts/datagen.py b/sw/apps/atax/scripts/datagen.py index c73ae70a2..0008bea26 100755 --- a/sw/apps/atax/scripts/datagen.py +++ b/sw/apps/atax/scripts/datagen.py @@ -9,8 +9,6 @@ import numpy as np import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_scalar_definition, format_array_definition, \ - format_array_declaration, format_ifdef_wrapper, DataGen # AXI splits bursts crossing 4KB address boundaries. To minimize @@ -18,7 +16,7 @@ BURST_ALIGNMENT = 4096 -class AtaxDataGen(DataGen): +class AtaxDataGen(du.DataGen): def golden_model(self, A, x): return np.matmul(A.transpose(), np.matmul(A, x)) @@ -38,13 +36,13 @@ def emit_header(self, **kwargs): x = x.flatten() y = y.flatten() - header += [format_scalar_definition('uint32_t', 'M', M)] - header += [format_scalar_definition('uint32_t', 'N', N)] - header += [format_array_definition('double', 'A', A, alignment=BURST_ALIGNMENT)] - header += [format_array_definition('double', 'x', x, alignment=BURST_ALIGNMENT)] - header += [format_array_declaration('double', 'y', y.shape, alignment=BURST_ALIGNMENT)] - result_def = format_array_definition('double', 'golden', y, alignment=BURST_ALIGNMENT) - header += [format_ifdef_wrapper('BIST', result_def)] + header += [du.format_scalar_definition('uint32_t', 'M', M)] + header += [du.format_scalar_definition('uint32_t', 'N', N)] + header += [du.format_array_definition('double', 'A', A, alignment=BURST_ALIGNMENT)] + header += [du.format_array_definition('double', 'x', x, alignment=BURST_ALIGNMENT)] + header += [du.format_array_declaration('double', 'y', y.shape, alignment=BURST_ALIGNMENT)] + result_def = du.format_array_definition('double', 'golden', y, alignment=BURST_ALIGNMENT) + header += [du.format_ifdef_wrapper('BIST', result_def)] header = '\n\n'.join(header) return header diff --git a/sw/apps/correlation/scripts/datagen.py b/sw/apps/correlation/scripts/datagen.py index 7880c1693..d60f527d1 100755 --- a/sw/apps/correlation/scripts/datagen.py +++ b/sw/apps/correlation/scripts/datagen.py @@ -9,8 +9,6 @@ import numpy as np import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_scalar_definition, format_array_definition, \ - format_array_declaration, format_ifdef_wrapper, DataGen # AXI splits bursts crossing 4KB address boundaries. To minimize @@ -18,7 +16,7 @@ BURST_ALIGNMENT = 4096 -class CorrelationDataGen(DataGen): +class CorrelationDataGen(du.DataGen): def golden_model(self, data): return np.corrcoef(data, rowvar=False) @@ -33,13 +31,14 @@ def emit_header(self, **kwargs): data = data.flatten() corr = corr.flatten() - header += [format_scalar_definition('uint32_t', 'M', M)] - header += [format_scalar_definition('uint32_t', 'N', N)] - header += [format_array_definition('double', 'data', data, alignment=BURST_ALIGNMENT)] - header += [format_array_declaration('double', 'corr', corr.shape, - alignment=BURST_ALIGNMENT)] - result_def = format_array_definition('double', 'golden', corr, alignment=BURST_ALIGNMENT) - header += [format_ifdef_wrapper('BIST', result_def)] + header += [du.format_scalar_definition('uint32_t', 'M', M)] + header += [du.format_scalar_definition('uint32_t', 'N', N)] + header += [du.format_array_definition('double', 'data', data, alignment=BURST_ALIGNMENT)] + header += [du.format_array_declaration('double', 'corr', corr.shape, + alignment=BURST_ALIGNMENT)] + result_def = du.format_array_definition('double', 'golden', corr, + alignment=BURST_ALIGNMENT) + header += [du.format_ifdef_wrapper('BIST', result_def)] header = '\n\n'.join(header) return header diff --git a/sw/apps/covariance/scripts/datagen.py b/sw/apps/covariance/scripts/datagen.py index 07bb92d0a..7beb2c671 100755 --- a/sw/apps/covariance/scripts/datagen.py +++ b/sw/apps/covariance/scripts/datagen.py @@ -9,15 +9,13 @@ import numpy as np import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_array_definition, \ - format_array_declaration, format_struct_definition, DataGen np.random.seed(42) DOUBLE_BUFFER = True -class CovarianceDataGen(DataGen): +class CovarianceDataGen(du.DataGen): # Function pointers to alternative implementations FUNCPTRS = ["covariance_naive", "covariance_baseline", "covariance_opt"] @@ -69,9 +67,9 @@ def emit_header(self, **kwargs): 'funcptr': kwargs['funcptr'] } - header += [format_array_definition('double', data_uid, data)] - header += [format_array_declaration('double', cov_uid, cov.shape)] - header += [format_struct_definition('covariance_args_t', 'args', cfg)] + header += [du.format_array_definition('double', data_uid, data)] + header += [du.format_array_declaration('double', cov_uid, cov.shape)] + header += [du.format_struct_definition('covariance_args_t', 'args', cfg)] header = '\n\n'.join(header) return header diff --git a/sw/apps/doitgen/scripts/datagen.py b/sw/apps/doitgen/scripts/datagen.py index 5f14ec86d..d1a9c3b46 100755 --- a/sw/apps/doitgen/scripts/datagen.py +++ b/sw/apps/doitgen/scripts/datagen.py @@ -8,14 +8,13 @@ import numpy as np import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_array_definition, format_struct_definition, DataGen np.random.seed(42) DOUBLE_BUFFER = True -class DoitgenDataGen(DataGen): +class DoitgenDataGen(du.DataGen): # Function pointers to alternative implementations FUNCPTRS = ["doitgen_naive", "doitgen_baseline", "doitgen_opt"] @@ -78,9 +77,9 @@ def emit_header(self, **kwargs): 'funcptr': kwargs['funcptr'] } - header += [format_array_definition('double', A_uid, A)] - header += [format_array_definition('double', x_uid, x)] - header += [format_struct_definition('doitgen_args_t', 'args', cfg)] + header += [du.format_array_definition('double', A_uid, A)] + header += [du.format_array_definition('double', x_uid, x)] + header += [du.format_struct_definition('doitgen_args_t', 'args', cfg)] header = '\n\n'.join(header) return header diff --git a/sw/blas/axpy/scripts/datagen.py b/sw/blas/axpy/scripts/datagen.py index ec00a4c88..38634dd5e 100755 --- a/sw/blas/axpy/scripts/datagen.py +++ b/sw/blas/axpy/scripts/datagen.py @@ -5,15 +5,12 @@ # # Author: Luca Colagrande -import numpy as np import sys import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_scalar_definition, format_array_definition, \ - format_array_declaration, format_ifdef_wrapper, format_struct_definition, DataGen -class AxpyDataGen(DataGen): +class AxpyDataGen(du.DataGen): # AXI splits bursts crossing 4KB address boundaries. To minimize # the occurrence of these splits the data should be aligned to 4KB @@ -60,16 +57,16 @@ def emit_header(self, **kwargs): 'funcptr': kwargs['funcptr'] } - header += [format_scalar_definition('const double', 'a', a)] - header += [format_array_definition('double', x_uid, x, + header += [du.format_scalar_definition('const double', 'a', a)] + header += [du.format_array_definition('double', x_uid, x, alignment=self.BURST_ALIGNMENT, section=kwargs['section'])] - header += [format_array_definition('double', y_uid, y, + header += [du.format_array_definition('double', y_uid, y, alignment=self.BURST_ALIGNMENT, section=kwargs['section'])] - header += [format_array_declaration('double', z_uid, x.shape, + header += [du.format_array_declaration('double', z_uid, x.shape, alignment=self.BURST_ALIGNMENT, section=kwargs['section'])] - header += [format_struct_definition('axpy_args_t', 'args', cfg)] - result_def = format_array_definition('double', 'g', g) - header += [format_ifdef_wrapper('BIST', result_def)] + header += [du.format_struct_definition('axpy_args_t', 'args', cfg)] + result_def = du.format_array_definition('double', 'g', g) + header += [du.format_ifdef_wrapper('BIST', result_def)] header = '\n\n'.join(header) return header diff --git a/sw/blas/dot/scripts/datagen.py b/sw/blas/dot/scripts/datagen.py index d11b53ff8..8a8631a6a 100755 --- a/sw/blas/dot/scripts/datagen.py +++ b/sw/blas/dot/scripts/datagen.py @@ -7,11 +7,9 @@ import sys import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_scalar_definition, format_array_definition, \ - format_scalar_declaration, format_ifdef_wrapper, DataGen -class DotDataGen(DataGen): +class DotDataGen(du.DataGen): # AXI splits bursts crossing 4KB address boundaries. To minimize # the occurrence of these splits the data should be aligned to 4KB @@ -31,15 +29,15 @@ def emit_header(self, **kwargs): assert (n % (8 * 4)) == 0, "n must be an integer multiple of the number of cores times " \ "the unrolling factor" - header += [format_scalar_definition('const uint32_t', 'n', n)] - header += [format_array_definition('double', 'x', x, alignment=self.BURST_ALIGNMENT, - section=kwargs['section'])] - header += [format_array_definition('double', 'y', y, alignment=self.BURST_ALIGNMENT, - section=kwargs['section'])] - header += [format_scalar_declaration('double', 'result', alignment=self.BURST_ALIGNMENT, - section=kwargs['section'])] - result_def = format_scalar_definition('double', 'g', g) - header += [format_ifdef_wrapper('BIST', result_def)] + header += [du.format_scalar_definition('const uint32_t', 'n', n)] + header += [du.format_array_definition('double', 'x', x, alignment=self.BURST_ALIGNMENT, + section=kwargs['section'])] + header += [du.format_array_definition('double', 'y', y, alignment=self.BURST_ALIGNMENT, + section=kwargs['section'])] + header += [du.format_scalar_declaration('double', 'result', alignment=self.BURST_ALIGNMENT, + section=kwargs['section'])] + result_def = du.format_scalar_definition('double', 'g', g) + header += [du.format_ifdef_wrapper('BIST', result_def)] header = '\n\n'.join(header) return header diff --git a/sw/blas/gemm/scripts/datagen.py b/sw/blas/gemm/scripts/datagen.py index 636175604..2eb6e2f4d 100755 --- a/sw/blas/gemm/scripts/datagen.py +++ b/sw/blas/gemm/scripts/datagen.py @@ -13,14 +13,12 @@ import sys import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import DataGen, format_array_declaration, \ - format_struct_definition, format_array_definition, format_ifdef_wrapper np.random.seed(42) -class GemmDataGen(DataGen): +class GemmDataGen(du.DataGen): # AXI splits bursts crossing 4KB address boundaries. To minimize # the occurrence of these splits the data should be aligned to 4KB @@ -125,18 +123,18 @@ def emit_header(self, **kwargs): b = b.flatten() c = c.flatten() - header += [format_array_declaration(ctype, a_uid, a.shape)] - header += [format_array_declaration(ctype, b_uid, b.shape)] - header += [format_array_declaration(ctype, c_uid, c.shape)] - header += [format_struct_definition('gemm_args_t', 'args', cfg)] - header += [format_array_definition(ctype, a_uid, a, - section=kwargs['section'])] - header += [format_array_definition(ctype, b_uid, b, - section=kwargs['section'])] - header += [format_array_definition(ctype, c_uid, c, - section=kwargs['section'])] - result_def = format_array_definition(ctype, 'result', result.flatten()) - header += [format_ifdef_wrapper('BIST', result_def)] + header += [du.format_array_declaration(ctype, a_uid, a.shape)] + header += [du.format_array_declaration(ctype, b_uid, b.shape)] + header += [du.format_array_declaration(ctype, c_uid, c.shape)] + header += [du.format_struct_definition('gemm_args_t', 'args', cfg)] + header += [du.format_array_definition(ctype, a_uid, a, + section=kwargs['section'])] + header += [du.format_array_definition(ctype, b_uid, b, + section=kwargs['section'])] + header += [du.format_array_definition(ctype, c_uid, c, + section=kwargs['section'])] + result_def = du.format_array_definition(ctype, 'result', result.flatten()) + header += [du.format_ifdef_wrapper('BIST', result_def)] header = '\n\n'.join(header) return header diff --git a/sw/blas/syrk/scripts/datagen.py b/sw/blas/syrk/scripts/datagen.py index ad15222f3..3fb86644f 100755 --- a/sw/blas/syrk/scripts/datagen.py +++ b/sw/blas/syrk/scripts/datagen.py @@ -8,13 +8,12 @@ import numpy as np import snitch.util.sim.data_utils as du -from snitch.util.sim.data_utils import format_array_definition, format_struct_definition, DataGen DOUBLE_BUFFER = True -class SyrkDataGen(DataGen): +class SyrkDataGen(du.DataGen): # Function pointers to alternative implementations FUNCPTRS = ["syrk_naive", "syrk_baseline", "syrk_opt"] @@ -73,9 +72,9 @@ def emit_header(self, **kwargs): 'funcptr': kwargs['funcptr'] } - header += [format_array_definition('double', A_uid, A)] - header += [format_array_definition('double', C_uid, C_in)] - header += [format_struct_definition('syrk_args_t', 'args', cfg)] + header += [du.format_array_definition('double', A_uid, A)] + header += [du.format_array_definition('double', C_uid, C_in)] + header += [du.format_struct_definition('syrk_args_t', 'args', cfg)] header = '\n\n'.join(header) return header