aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2020-01-17 21:05:23 +0100
committerAdrian Kummerlaender2020-01-17 21:05:40 +0100
commit25c210daa7c45d937bcc336ca887bfba71000a23 (patch)
tree137bf71404050770501774cb16eee2e2b0004cc4
parentb5a24f31871d900342a3c47398cc75e22bad0b6f (diff)
downloadboltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.tar
boltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.tar.gz
boltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.tar.bz2
boltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.tar.lz
boltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.tar.xz
boltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.tar.zst
boltzgen-25c210daa7c45d937bcc336ca887bfba71000a23.zip
Implement AA for CUDA target
-rw-r--r--boltzgen/kernel/template/pattern/AA.cuda.mako215
1 files changed, 215 insertions, 0 deletions
diff --git a/boltzgen/kernel/template/pattern/AA.cuda.mako b/boltzgen/kernel/template/pattern/AA.cuda.mako
new file mode 100644
index 0000000..b3dd2a6
--- /dev/null
+++ b/boltzgen/kernel/template/pattern/AA.cuda.mako
@@ -0,0 +1,215 @@
+<%def name="operator(name, params = None)">
+__global__ void ${name}_tick(
+ ${float_type}* f
+% if 'cell_list_dispatch' in extras:
+ , std::size_t* cells
+ , std::size_t cell_count
+% else:
+ , std::size_t gid
+% endif
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+% if 'cell_list_dispatch' in extras:
+ const std::size_t index = blockIdx.x * blockDim.x + threadIdx.x;
+ if (!(index < cell_count)) {
+ return;
+ }
+ const std::size_t gid = cells[index];
+% endif
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(i)}];
+% endfor
+
+ ${caller.body()}
+
+% for i, c_i in enumerate(descriptor.c):
+ preshifted_f[${layout.pop_offset(i)}] = f_next_${descriptor.c.index(-c_i)};
+% endfor
+}
+
+__global__ void ${name}_tock(
+ ${float_type}* f
+% if 'cell_list_dispatch' in extras:
+ , std::size_t* cells
+ , std::size_t cell_count
+% else:
+ , std::size_t gid
+% endif
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+% if 'cell_list_dispatch' in extras:
+ const std::size_t index = blockIdx.x * blockDim.x + threadIdx.x;
+ if (!(index < cell_count)) {
+ return;
+ }
+ const std::size_t gid = cells[index];
+% endif
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${descriptor.c.index(-c_i)} = preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}];
+% endfor
+
+ ${caller.body()}
+
+% for i, c_i in enumerate(descriptor.c):
+ preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}] = f_next_${i};
+% endfor
+}
+</%def>
+
+<%def name="operator_with_domain_dispatch(name, params = None)">
+__global__ void ${name}_tick(
+ ${float_type}* f
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ const std::size_t gid = ${index.gid('get_global_id(0)', 'get_global_id(1)', 'get_global_id(2)')};
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(i)}];
+% endfor
+
+ ${caller.body()}
+
+% for i, c_i in enumerate(descriptor.c):
+ preshifted_f[${layout.pop_offset(i)}] = f_next_${descriptor.c.index(-c_i)};
+% endfor
+}
+
+__global__ void ${name}_tock(
+ ${float_type}* f
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ const std::size_t gid = ${index.gid('get_global_id(0)', 'get_global_id(1)', 'get_global_id(2)')};
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${descriptor.c.index(-c_i)} = preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}];
+% endfor
+
+ ${caller.body()}
+
+% for i, c_i in enumerate(descriptor.c):
+ preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}] = f_next_${i};
+% endfor
+}
+</%def>
+
+<%def name="functor(name, params = None)">
+__global__ void ${name}_tick(
+ ${float_type}* f
+% if 'cell_list_dispatch' in extras:
+ , std::size_t* cells
+ , std::size_t cell_count
+% else:
+ , std::size_t gid
+% endif
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+% if 'cell_list_dispatch' in extras:
+ const std::size_t index = blockIdx.x * blockDim.x + threadIdx.x;
+ if (!(index < cell_count)) {
+ return;
+ }
+ const std::size_t gid = cells[index];
+% endif
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(descriptor.c.index(-c_i))}];
+% endfor
+
+ ${caller.body()}
+}
+
+__global__ void ${name}_tock(
+ ${float_type}* f
+% if 'cell_list_dispatch' in extras:
+ , std::size_t* cells
+ , std::size_t cell_count
+% else:
+ , std::size_t gid
+% endif
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+% if 'cell_list_dispatch' in extras:
+ const std::size_t index = blockIdx.x * blockDim.x + threadIdx.x;
+ if (!(index < cell_count)) {
+ return;
+ }
+ const std::size_t gid = cells[index];
+% endif
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}];
+% endfor
+
+ ${caller.body()}
+}
+</%def>
+
+<%def name="functor_with_domain_dispatch(name, params = None)">
+__global__ void ${name}_tick(
+ ${float_type}* f
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ const std::size_t gid = ${index.gid('get_global_id(0)', 'get_global_id(1)', 'get_global_id(2)')};
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(descriptor.c.index(-c_i))}];
+% endfor
+
+ ${caller.body()}
+}
+
+__global__ void ${name}_tock(
+ ${float_type}* f
+% if params is not None:
+% for param_type, param_name in params:
+ , ${param_type} ${param_name}
+% endfor
+% endif
+) {
+ const std::size_t gid = ${index.gid('get_global_id(0)', 'get_global_id(1)', 'get_global_id(2)')};
+ ${float_type}* preshifted_f = f + ${layout.cell_preshift('gid')};
+
+% for i, c_i in enumerate(descriptor.c):
+ const ${float_type} f_curr_${i} = preshifted_f[${layout.pop_offset(i) + layout.neighbor_offset(c_i)}];
+% endfor
+
+ ${caller.body()}
+}
+</%def>