|
@@ -1,5 +1,6 @@
|
|
|
"""Generate burst laminographic backprojection OpenCL kernels."""
|
|
|
import argparse
|
|
|
+import os
|
|
|
|
|
|
|
|
|
IDX_TO_VEC_ELEM = dict(zip(range(10), range(10)))
|
|
@@ -18,14 +19,15 @@ def fill_compute_template(tmpl, num_items, index):
|
|
|
return tmpl.format(index, access, operation)
|
|
|
|
|
|
|
|
|
-def fill_kernel_template(input_tmpl, compute_tmpl, kernel_tmpl, num_items):
|
|
|
+def fill_kernel_template(input_tmpl, compute_tmpl, kernel_outer, kernel_inner, num_items):
|
|
|
"""Construct the whole kernel."""
|
|
|
vector_length = num_items if num_items > 1 else ''
|
|
|
computes = '\n'.join([fill_compute_template(compute_tmpl, num_items, i)
|
|
|
for i in range(num_items)])
|
|
|
inputs = '\n'.join([input_tmpl.format(i) for i in range(num_items)])
|
|
|
+ kernel_inner = kernel_inner.format(computes)
|
|
|
|
|
|
- return kernel_tmpl.format(num_items, inputs, vector_length, computes)
|
|
|
+ return kernel_outer.format(num_items, inputs, vector_length, kernel_inner)
|
|
|
|
|
|
|
|
|
def parse_args():
|
|
@@ -46,8 +48,10 @@ def main():
|
|
|
raise ValueError('Specified burst mode `{}` must be one of `{}`'.format(args.burst,
|
|
|
allowed_bursts))
|
|
|
in_tmpl = "read_only image2d_t projection_{},"
|
|
|
- comp_tmpl, ker_tmpl = open(args.filename, 'r').read().split('\n%nl\n')
|
|
|
- print fill_kernel_template(in_tmpl, comp_tmpl, ker_tmpl, args.burst)
|
|
|
+ common_filename = os.path.join(os.path.dirname(args.filename), 'common.in')
|
|
|
+ kernel_outer = open(common_filename, 'r').read()
|
|
|
+ comp_tmpl, kernel_inner = open(args.filename, 'r').read().split('\n%nl\n')
|
|
|
+ print fill_kernel_template(in_tmpl, comp_tmpl, kernel_outer, kernel_inner, args.burst)
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|