From a8a43181555ba94666fe814d2b346fd5e3a83274 Mon Sep 17 00:00:00 2001
From: Markus Holzer <markus.holzer@fau.de>
Date: Tue, 21 Dec 2021 15:39:03 +0100
Subject: [PATCH] Remove Cuda known functions

---
 pystencils/backends/cuda_backend.py           |   7 -
 pystencils/backends/cuda_known_functions.txt  | 294 ------------------
 pystencils_tests/test_cuda_known_functions.py |  50 ---
 3 files changed, 351 deletions(-)
 delete mode 100644 pystencils/backends/cuda_known_functions.txt
 delete mode 100644 pystencils_tests/test_cuda_known_functions.py

diff --git a/pystencils/backends/cuda_backend.py b/pystencils/backends/cuda_backend.py
index 0c453f889..ebcda56af 100644
--- a/pystencils/backends/cuda_backend.py
+++ b/pystencils/backends/cuda_backend.py
@@ -1,14 +1,8 @@
-from os.path import dirname, join
-
 from pystencils.astnodes import Node
 from pystencils.backends.cbackend import CBackend, CustomSympyPrinter, generate_c
 from pystencils.enums import Backend
 from pystencils.fast_approximation import fast_division, fast_inv_sqrt, fast_sqrt
 
-with open(join(dirname(__file__), 'cuda_known_functions.txt')) as f:
-    lines = f.readlines()
-    CUDA_KNOWN_FUNCTIONS = {l.strip(): l.strip() for l in lines if l}
-
 
 def generate_cuda(ast_node: Node, signature_only: bool = False, custom_backend=None, with_globals=True) -> str:
     """Prints an abstract syntax tree node as CUDA code.
@@ -73,7 +67,6 @@ class CudaSympyPrinter(CustomSympyPrinter):
 
     def __init__(self):
         super(CudaSympyPrinter, self).__init__()
-        self.known_functions.update(CUDA_KNOWN_FUNCTIONS)
 
     def _print_Function(self, expr):
         if isinstance(expr, fast_division):
diff --git a/pystencils/backends/cuda_known_functions.txt b/pystencils/backends/cuda_known_functions.txt
deleted file mode 100644
index 224f4a49d..000000000
--- a/pystencils/backends/cuda_known_functions.txt
+++ /dev/null
@@ -1,294 +0,0 @@
-__prof_trigger
-printf
-
-__syncthreads
-__syncthreads_count
-__syncthreads_and
-__syncthreads_or
-__syncwarp
-__threadfence
-__threadfence_block
-__threadfence_system
-
-atomicAdd
-atomicSub
-atomicExch
-atomicMin
-atomicMax
-atomicInc
-atomicDec
-atomicAnd
-atomicOr
-atomicXor
-atomicCAS
-
-__all_sync
-__any_sync
-__ballot_sync
-__active_mask
-
-__shfl_sync
-__shfl_up_sync
-__shfl_down_sync
-__shfl_xor_sync
-
-__match_any_sync
-__match_all_sync
-
-__isGlobal
-__isShared
-__isConstant
-__isLocal
-
-tex1Dfetch
-tex1D
-tex2D
-tex3D
-
-sqrtf
-rsqrtf
-cbrtf
-rcbrtf
-hypotf
-rhypotf
-norm3df
-rnorm3df
-norm4df
-rnorm4df
-normf
-rnormf
-expf
-exp2f
-exp10f
-expm1f
-logf
-log2f
-log10f
-log1pf
-sinf
-cosf
-tanf
-sincosf
-sinpif
-cospif
-sincospif
-asinf
-acosf
-atanf
-atan2f
-sinhf
-coshf
-tanhf
-asinhf
-acoshf
-atanhf
-powf
-erff
-erfcf
-erfinvf
-erfcinvf
-erfcxf
-normcdff
-normcdfinvf
-lgammaf
-tgammaf
-fmaf
-frexpf
-ldexpf
-scalbnf
-scalblnf
-logbf
-ilogbf
-j0f
-j1f
-jnf
-y0f
-y1f
-ynf
-cyl_bessel_i0f
-cyl_bessel_i1f
-fmodf
-remainderf
-remquof
-modff
-fdimf
-truncf
-roundf
-rintf
-nearbyintf
-ceilf
-floorf
-lrintf
-lroundf
-llrintf
-llroundf
-
-sqrt
-rsqrt
-cbrt
-rcbrt
-hypot
-rhypot
-norm3d
-rnorm3d
-norm4d
-rnorm4d
-norm
-rnorm
-exp
-exp2
-exp10
-expm1
-log
-log2
-log10
-log1p
-sin
-cos
-tan
-sincos
-sinpi
-cospi
-sincospi
-asin
-acos
-atan
-atan2
-sinh
-cosh
-tanh
-asinh
-acosh
-atanh
-pow
-erf
-erfc
-erfinv
-erfcinv
-erfcx
-normcdf
-normcdfinv
-lgamma
-tgamma
-fma
-frexp
-ldexp
-scalbn
-scalbln
-logb
-ilogb
-j0
-j1
-jn
-y0
-y1
-yn
-cyl_bessel_i0
-cyl_bessel_i1
-fmod
-remainder
-remquo
-mod
-fdim
-trunc
-round
-rint
-nearbyint
-ceil
-floor
-lrint
-lround
-llrint
-llround
-
-__fdividef
-__sinf
-__cosf
-__tanf
-__sincosf
-__logf
-__log2f
-__log10f
-__expf
-__exp10f
-__powf
-
-__fadd_rn
-__fsub_rn
-__fmul_rn
-__fmaf_rn
-__frcp_rn
-__fsqrt_rn
-__frsqrt_rn
-__fdiv_rn
-
-__fadd_rz
-__fsub_rz
-__fmul_rz
-__fmaf_rz
-__frcp_rz
-__fsqrt_rz
-__frsqrt_rz
-__fdiv_rz
-
-__fadd_ru
-__fsub_ru
-__fmul_ru
-__fmaf_ru
-__frcp_ru
-__fsqrt_ru
-__frsqrt_ru
-__fdiv_ru
-
-__fadd_rd
-__fsub_rd
-__fmul_rd
-__fmaf_rd
-__frcp_rd
-__fsqrt_rd
-__frsqrt_rd
-__fdiv_rd
-
-__fdividef
-__expf
-__exp10f
-__logf
-__log2f
-__log10f
-__sinf
-__cosf
-__sincosf
-__tanf
-__powf
-
-__dadd_rn
-__dsub_rn
-__dmul_rn
-__fma_rn
-__ddiv_rn
-__drcp_rn
-__dsqrt_rn
-
-__dadd_rz
-__dsub_rz
-__dmul_rz
-__fma_rz
-__ddiv_rz
-__drcp_rz
-__dsqrt_rz
-
-__dadd_ru
-__dsub_ru
-__dmul_ru
-__fma_ru
-__ddiv_ru
-__drcp_ru
-__dsqrt_ru
-
-__dadd_rd
-__dsub_rd
-__dmul_rd
-__fma_rd
-__ddiv_rd
-__drcp_rd
-__dsqrt_rd
diff --git a/pystencils_tests/test_cuda_known_functions.py b/pystencils_tests/test_cuda_known_functions.py
deleted file mode 100644
index b9e17ebdd..000000000
--- a/pystencils_tests/test_cuda_known_functions.py
+++ /dev/null
@@ -1,50 +0,0 @@
-import sympy
-
-import pytest
-
-import pystencils
-from pystencils.astnodes import get_dummy_symbol
-from pystencils.backends.cuda_backend import CudaSympyPrinter
-from pystencils.functions import AddressOf
-from pystencils.enums import Target
-
-
-def test_cuda_known_functions():
-    printer = CudaSympyPrinter()
-    print(printer.known_functions)
-
-    x, y = pystencils.fields('x,y: float32 [2d]')
-
-    assignments = pystencils.AssignmentCollection({
-        get_dummy_symbol(): sympy.Function('atomicAdd')(AddressOf(y.center()), 2),
-        y.center():  sympy.Function('rsqrtf')(x[0, 0])
-    })
-
-    ast = pystencils.create_kernel(assignments, target=Target.GPU)
-    pytest.importorskip('pycuda')
-    pystencils.show_code(ast)
-    kernel = ast.compile()
-    assert(kernel is not None)
-
-
-def test_cuda_but_not_c():
-    x, y = pystencils.fields('x,y: float32 [2d]')
-
-    assignments = pystencils.AssignmentCollection({
-        get_dummy_symbol(): sympy.Function('atomicAdd')(AddressOf(y.center()), 2),
-        y.center():  sympy.Function('rsqrtf')(x[0, 0])
-    })
-
-    ast = pystencils.create_kernel(assignments, target=Target.CPU)
-    pystencils.show_code(ast)
-
-
-def test_cuda_unknown():
-    x, y = pystencils.fields('x,y: float32 [2d]')
-
-    assignments = pystencils.AssignmentCollection({
-        get_dummy_symbol(): sympy.Function('wtf')(AddressOf(y.center()), 2),
-    })
-
-    ast = pystencils.create_kernel(assignments, target=Target.GPU)
-    pystencils.show_code(ast)
-- 
GitLab