Skip to content
Snippets Groups Projects
Commit cee2d2ad authored by René Heß's avatar René Heß
Browse files

[skip ci] Simulate cache misses in autotune benchmarks

Run the function call over multiple data sets.
parent 301c91bc
No related branches found
No related tags found
No related merge requests found
...@@ -381,7 +381,6 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations ...@@ -381,7 +381,6 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
codegen_benchmark_function = textwrap.indent(codegen_benchmark_function, ' ') codegen_benchmark_function = textwrap.indent(codegen_benchmark_function, ' ')
# Declare function arguments # Declare function arguments
datasets = 512
codegen_declare_arguments = [] codegen_declare_arguments = []
codegen_declare_input = [] codegen_declare_input = []
function_arguments = [a for a in kernel.args if a.name in arguments] function_arguments = [a for a in kernel.args if a.name in arguments]
...@@ -403,10 +402,10 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations ...@@ -403,10 +402,10 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
size *= min_stride size *= min_stride
alignment = arg.dtype.itemsize alignment = arg.dtype.itemsize
real = type_floatingpoint() real = type_floatingpoint()
codegen_declare_input.append((' {} {}[{}] __attribute__ ((aligned ({})));\n'.format(real, codegen_declare_input.append(('{} {}[datasets][{}] __attribute__ ((aligned ({})));\n'.format(real,
arg.name, arg.name,
size, size,
alignment))) alignment)))
codegen_declare_arguments = ''.join(codegen_declare_arguments) codegen_declare_arguments = ''.join(codegen_declare_arguments)
codegen_declare_arguments = textwrap.indent(codegen_declare_arguments, ' ') codegen_declare_arguments = textwrap.indent(codegen_declare_arguments, ' ')
...@@ -419,6 +418,10 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations ...@@ -419,6 +418,10 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
for arg in function_arguments: for arg in function_arguments:
if 'fastdg' in arg.name: if 'fastdg' in arg.name:
lines = _initialize_arg(arg) lines = _initialize_arg(arg)
lines = [' ' + a for a in lines]
lines = [a.replace(arg.name + ';', arg.name + '[i];') for a in lines]
lines.insert(0, 'for(std::size_t i=0; i<datasets; ++i){')
lines.append('}')
codegen_initialize_input += '\n'.join(lines) + '\n' codegen_initialize_input += '\n'.join(lines) + '\n'
else: else:
lines = _initialize_arg(arg) lines = _initialize_arg(arg)
...@@ -427,8 +430,14 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations ...@@ -427,8 +430,14 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
codegen_initialize_input = textwrap.indent(codegen_initialize_input, ' ') codegen_initialize_input = textwrap.indent(codegen_initialize_input, ' ')
# Call the benchmark function # Call the benchmark function
codegen_call_benchmark_function = kernel.name + '({})'.format(','.join(arguments)) + ';' arguments_with_datasets = arguments.copy()
codegen_call_benchmark_function = textwrap.indent(codegen_call_benchmark_function, ' ') arguments_with_datasets = [a if 'fastdg' not in a else a + '[i]' for a in arguments]
codegen_call_benchmark_function = 'for (std::size_t i=0; i<datasets; ++i){\n'
codegen_call_benchmark_function += ' ' + kernel.name + '({})'.format(','.join(arguments_with_datasets)) + ';\n'
for arg in input_arguments:
codegen_call_benchmark_function += 'benchmark::DoNotOptimize({}[i][0]);\n'.format(arg)
codegen_call_benchmark_function += '}'
codegen_call_benchmark_function = textwrap.indent(codegen_call_benchmark_function, ' ')
# Replace placeholders in benchmark template # Replace placeholders in benchmark template
benchmark = benchmark.replace('CODEGEN_TRANSFORMATIONS', codegen_transformations) benchmark = benchmark.replace('CODEGEN_TRANSFORMATIONS', codegen_transformations)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment