Skip to content
Snippets Groups Projects
Commit 8518fe80 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Merge branch 'fhennig/include-cleanup' into 'v2.0-dev'

Some cleanup to the pystencils runtime headers

See merge request !456
parents 1998bc1e fcd5bfb6
Branches
No related tags found
1 merge request!456Some cleanup to the pystencils runtime headers
Pipeline #75337 passed
...@@ -188,7 +188,7 @@ class CudaPlatform(GenericGpu): ...@@ -188,7 +188,7 @@ class CudaPlatform(GenericGpu):
@property @property
def required_headers(self) -> set[str]: 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( def materialize_iteration_space(
self, body: PsBlock, ispace: IterationSpace self, body: PsBlock, ispace: IterationSpace
......
#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
}
#pragma once #pragma once
#define POS_INFINITY __int_as_float(0x7f800000)
#define INFINITY POS_INFINITY
#define NEG_INFINITY __int_as_float(0xff800000)
#ifdef __HIPCC_RTC__ #ifdef __HIPCC_RTC__
typedef __hip_uint8_t uint8_t; typedef __hip_uint8_t uint8_t;
typedef __hip_int8_t int8_t; typedef __hip_int8_t int8_t;
......
...@@ -250,8 +250,8 @@ class CupyJit(JitBase): ...@@ -250,8 +250,8 @@ class CupyJit(JitBase):
headers = self._runtime_headers headers = self._runtime_headers
headers |= kfunc.required_headers headers |= kfunc.required_headers
if '"half_precision.h"' in headers: if '"pystencils_runtime/half.h"' in headers:
headers.remove('"half_precision.h"') headers.remove('"pystencils_runtime/half.h"')
if cp.cuda.runtime.is_hip: if cp.cuda.runtime.is_hip:
headers.add("<hip/hip_fp16.h>") headers.add("<hip/hip_fp16.h>")
else: else:
......
...@@ -661,7 +661,7 @@ class PsIeeeFloatType(PsScalarType): ...@@ -661,7 +661,7 @@ class PsIeeeFloatType(PsScalarType):
@property @property
def required_headers(self) -> set[str]: def required_headers(self) -> set[str]:
if self._width == 16: if self._width == 16:
return {'"half_precision.h"'} return {'"pystencils_runtime/half.h"'}
else: else:
return set() return set()
...@@ -672,7 +672,7 @@ class PsIeeeFloatType(PsScalarType): ...@@ -672,7 +672,7 @@ class PsIeeeFloatType(PsScalarType):
match self.width: match self.width:
case 16: case 16:
return f"((half) {value})" # see include/half_precision.h return f"((half) {value})" # see include/pystencils_runtime/half.h
case 32: case 32:
return f"{value}f" return f"{value}f"
case 64: case 64:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment