diff --git a/pystencils/backends/opencl1.1_known_functions.txt b/pystencils/backends/opencl1.1_known_functions.txt new file mode 100644 index 0000000000000000000000000000000000000000..abeab29043e2c76b2b2df8e9024c00e7ac34de0f --- /dev/null +++ b/pystencils/backends/opencl1.1_known_functions.txt @@ -0,0 +1,100 @@ +acos +acosh +acospi +asin +asinh +asinpi +atan +atan2 +atanh +atanpi +atan2pi +cbrt +ceil +copysign +cos +cosh +cospi +erfc +erf +exp +exp2 +exp10 +expm1 +fabs +fdim +floor +fma +fmax +fmax +fmin45 +fmin +fmod +fract +frexp +hypot +ilogb +ldexp +lgamma +lgamma_r +log +log2 +log10 +log1p +logb +mad +maxmag +minmag +modf +nextafter +pow +pown +powr +remquo +intn +remquo +rint +rootn +rootn +round +rsqrt +sin +sincos +sinh +sinpi +sqrt +tan +tanh +tanpi +tgamma +trunc + + +half_cos +half_divide +half_exp +half_exp2 +half_exp10 +half_log +half_log2 +half_log10 +half_powr +half_recip +half_rsqrt +half_sin +half_sqrt +half_tan +native_cos +native_divide +native_exp +native_exp2 +native_exp10 +native_log +native_log2 +native_log10 +native_powr +native_recip +native_rsqrt +native_sin +native_sqrt +native_tan diff --git a/pystencils/backends/opencl_backend.py b/pystencils/backends/opencl_backend.py index b70b3ce72fbc494261bb059c6948879669d3ec9f..01c2c410c07d376f54a40d24e61fcd8c809ffb98 100644 --- a/pystencils/backends/opencl_backend.py +++ b/pystencils/backends/opencl_backend.py @@ -1,9 +1,15 @@ +from os.path import dirname, join + import pystencils.data_types from pystencils.astnodes import Node from pystencils.backends.cbackend import CustomSympyPrinter, generate_c from pystencils.backends.cuda_backend import CudaBackend, CudaSympyPrinter from pystencils.fast_approximation import fast_division, fast_inv_sqrt, fast_sqrt +with open(join(dirname(__file__), 'opencl1.1_known_functions.txt')) as f: + lines = f.readlines() + OPENCL_KNOWN_FUNCTIONS = {l.strip(): l.strip() for l in lines if l} + def generate_opencl(astnode: Node, signature_only: bool = False) -> str: """Prints an abstract syntax tree node as CUDA code. @@ -58,6 +64,10 @@ class OpenClSympyPrinter(CudaSympyPrinter): 'gridDim': 'get_global_size' } + def __init__(self): + CustomSympyPrinter.__init__(self) + self.known_functions = OPENCL_KNOWN_FUNCTIONS + def _print_ThreadIndexingSymbol(self, node): symbol_name: str = node.name function_name, dimension = tuple(symbol_name.split(".")) diff --git a/setup.py b/setup.py index 3da19ffedeffdc88c2c4b5424a7a1e26983621b8..da6b82856b17e5252941154d43310ec1888eaa39 100644 --- a/setup.py +++ b/setup.py @@ -88,7 +88,10 @@ setup(name='pystencils', url='https://i10git.cs.fau.de/pycodegen/pystencils/', packages=['pystencils'] + ['pystencils.' + s for s in find_packages('pystencils')], install_requires=['sympy>=1.1', 'numpy', 'appdirs', 'joblib'], - package_data={'pystencils': ['include/*.h', 'backends/cuda_known_functions.txt']}, + package_data={'pystencils': ['include/*.h', + 'backends/cuda_known_functions.txt', + 'backends/opencl1.1_known_functions.txt']}, + ext_modules=cython_extensions("pystencils.boundaries.createindexlistcython"), classifiers=[ 'Development Status :: 4 - Beta',