Skip to content
Snippets Groups Projects

Add experimental half precison support

Merged Markus Holzer requested to merge holzer/pystencils:halfP into master
Files
5
+ 7
1
@@ -60,7 +60,7 @@ from appdirs import user_cache_dir, user_config_dir
from pystencils import FieldType
from pystencils.astnodes import LoopOverCoordinate
from pystencils.backends.cbackend import generate_c, get_headers, CFunction
from pystencils.typing import CastFunc, VectorType, VectorMemoryAccess
from pystencils.typing import BasicType, CastFunc, VectorType, VectorMemoryAccess
from pystencils.include import get_pystencils_include_path
from pystencils.kernel_wrapper import KernelWrapper
from pystencils.utils import atomic_file_write, recursive_dict_update
@@ -519,8 +519,14 @@ class ExtensionModuleCode:
self._code_string = str()
headers = {'<math.h>', '<stdint.h>'}
half = False
for ast in self._ast_nodes:
for field in ast.fields_accessed:
if isinstance(field.dtype, BasicType) and field.dtype.is_half():
half = True
headers.update(get_headers(ast))
if half:
headers.update({'"half_precision.h"', })
header_list = list(headers)
header_list.sort()
header_list.insert(0, '"Python.h"')
Loading