|
|
@ -28,14 +28,20 @@ def type_to_C(float_type: numpy.float32 or numpy.float64) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
return types[float_type]
|
|
|
|
return types[float_type]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctype = type_to_C(numpy.complex128)
|
|
|
|
|
|
|
|
ctype_bare = 'cdouble'
|
|
|
|
|
|
|
|
|
|
|
|
preamble = '''
|
|
|
|
preamble = '''
|
|
|
|
#define PYOPENCL_DEFINE_CDOUBLE
|
|
|
|
#define PYOPENCL_DEFINE_CDOUBLE
|
|
|
|
#include <pyopencl-complex.h>
|
|
|
|
#include <pyopencl-complex.h>
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
//Defines to clean up operation and type names
|
|
|
|
|
|
|
|
#define ctype {ctype}_t
|
|
|
|
ctype = type_to_C(numpy.complex128)
|
|
|
|
#define zero {ctype}_new(0.0, 0.0)
|
|
|
|
|
|
|
|
#define add {ctype}_add
|
|
|
|
|
|
|
|
#define sub {ctype}_sub
|
|
|
|
|
|
|
|
#define mul {ctype}_mul
|
|
|
|
|
|
|
|
'''.format(ctype=ctype_bare)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ptrs(*args):
|
|
|
|
def ptrs(*args):
|
|
|
@ -44,16 +50,14 @@ def ptrs(*args):
|
|
|
|
|
|
|
|
|
|
|
|
def create_a(context, shape, mu=False, pec=False, pmc=False):
|
|
|
|
def create_a(context, shape, mu=False, pec=False, pmc=False):
|
|
|
|
|
|
|
|
|
|
|
|
common_source = jinja_env.get_template('common.cl').render(shape=shape,
|
|
|
|
common_source = jinja_env.get_template('common.cl').render(shape=shape)
|
|
|
|
ctype=ctype)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pec_arg = ['char *pec']
|
|
|
|
pec_arg = ['char *pec']
|
|
|
|
pmc_arg = ['char *pmc']
|
|
|
|
pmc_arg = ['char *pmc']
|
|
|
|
des = [ctype + ' *inv_de' + a for a in 'xyz']
|
|
|
|
des = [ctype + ' *inv_de' + a for a in 'xyz']
|
|
|
|
dhs = [ctype + ' *inv_dh' + a for a in 'xyz']
|
|
|
|
dhs = [ctype + ' *inv_dh' + a for a in 'xyz']
|
|
|
|
|
|
|
|
|
|
|
|
p2e_source = jinja_env.get_template('p2e.cl').render(pec=pec,
|
|
|
|
p2e_source = jinja_env.get_template('p2e.cl').render(pec=pec)
|
|
|
|
ctype=ctype)
|
|
|
|
|
|
|
|
P2E_kernel = ElementwiseKernel(context,
|
|
|
|
P2E_kernel = ElementwiseKernel(context,
|
|
|
|
name='P2E',
|
|
|
|
name='P2E',
|
|
|
|
preamble=preamble,
|
|
|
|
preamble=preamble,
|
|
|
|