diff --git a/src/pystencils/backend/platforms/cuda.py b/src/pystencils/backend/platforms/cuda.py index e896fc2bba9a484e33480b34b3e390d8c44eb4df..d630594ba8a633e04e2b058e74f77d604f6d95a9 100644 --- a/src/pystencils/backend/platforms/cuda.py +++ b/src/pystencils/backend/platforms/cuda.py @@ -188,7 +188,7 @@ class CudaPlatform(GenericGpu): @property def required_headers(self) -> set[str]: - return {'"gpu_defines.h"'} + return {'"pystencils_runtime/hip.h"'} # TODO: move to HipPlatform once it is introduced def materialize_iteration_space( self, body: PsBlock, ispace: IterationSpace diff --git a/src/pystencils/include/PyStencilsField.h b/src/pystencils/include/PyStencilsField.h deleted file mode 100644 index 3055cae2365279e28fdcaab4353779b97ca27d35..0000000000000000000000000000000000000000 --- a/src/pystencils/include/PyStencilsField.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -extern "C++" { -#ifdef __CUDA_ARCH__ -template <typename DTYPE_T, std::size_t DIMENSION> struct PyStencilsField { - DTYPE_T *data; - DTYPE_T shape[DIMENSION]; - DTYPE_T stride[DIMENSION]; -}; -#else -#include <array> - -template <typename DTYPE_T, std::size_t DIMENSION> struct PyStencilsField { - DTYPE_T *data; - std::array<DTYPE_T, DIMENSION> shape; - std::array<DTYPE_T, DIMENSION> stride; -}; -#endif -} diff --git a/src/pystencils/include/half_precision.h b/src/pystencils/include/pystencils_runtime/half.h similarity index 100% rename from src/pystencils/include/half_precision.h rename to src/pystencils/include/pystencils_runtime/half.h diff --git a/src/pystencils/include/gpu_defines.h b/src/pystencils/include/pystencils_runtime/hip.h similarity index 56% rename from src/pystencils/include/gpu_defines.h rename to src/pystencils/include/pystencils_runtime/hip.h index 67e7722e9a01b217584dce14f0dcec16d2025c80..4bf4917f8aef1054813eb62a5596a908defeb30c 100644 --- a/src/pystencils/include/gpu_defines.h +++ b/src/pystencils/include/pystencils_runtime/hip.h @@ -1,9 +1,5 @@ #pragma once -#define POS_INFINITY __int_as_float(0x7f800000) -#define INFINITY POS_INFINITY -#define NEG_INFINITY __int_as_float(0xff800000) - #ifdef __HIPCC_RTC__ typedef __hip_uint8_t uint8_t; typedef __hip_int8_t int8_t; diff --git a/src/pystencils/jit/gpu_cupy.py b/src/pystencils/jit/gpu_cupy.py index 1c771a427ab5025c0f041d88f1acbec7da9f0920..d45abf8786e8fc1789f8eae551a07b6aa556db67 100644 --- a/src/pystencils/jit/gpu_cupy.py +++ b/src/pystencils/jit/gpu_cupy.py @@ -250,8 +250,8 @@ class CupyJit(JitBase): headers = self._runtime_headers headers |= kfunc.required_headers - if '"half_precision.h"' in headers: - headers.remove('"half_precision.h"') + if '"pystencils_runtime/half.h"' in headers: + headers.remove('"pystencils_runtime/half.h"') if cp.cuda.runtime.is_hip: headers.add("<hip/hip_fp16.h>") else: diff --git a/src/pystencils/types/types.py b/src/pystencils/types/types.py index 825ac1d5d35fde0f26c5a9ebadb55ec43004c9ae..8dea97ca43539b966e260ac7a206b0e26b3b2110 100644 --- a/src/pystencils/types/types.py +++ b/src/pystencils/types/types.py @@ -661,7 +661,7 @@ class PsIeeeFloatType(PsScalarType): @property def required_headers(self) -> set[str]: if self._width == 16: - return {'"half_precision.h"'} + return {'"pystencils_runtime/half.h"'} else: return set() @@ -672,7 +672,7 @@ class PsIeeeFloatType(PsScalarType): match self.width: case 16: - return f"((half) {value})" # see include/half_precision.h + return f"((half) {value})" # see include/pystencils_runtime/half.h case 32: return f"{value}f" case 64: