From e5172e2a9aa12108a05f33b2095990ee633be165 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Tue, 23 Jul 2019 16:06:54 +0300 Subject: [PATCH] Moved more stuff out of astaroth.h to astaroth_defines.h. I'm not particularly sure what's the best way to arrange the include files. These changes are just for readability so it's very safe to move things around though. --- include/astaroth.h | 113 ------------------------------------- include/astaroth_defines.h | 105 ++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 113 deletions(-) diff --git a/include/astaroth.h b/include/astaroth.h index b45db11..a5b84cd 100644 --- a/include/astaroth.h +++ b/include/astaroth.h @@ -18,30 +18,8 @@ */ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "astaroth_defines.h" -typedef struct { - int int_params[NUM_INT_PARAMS]; - int3 int3_params[NUM_INT3_PARAMS]; - AcReal real_params[NUM_REAL_PARAMS]; - AcReal3 real3_params[NUM_REAL3_PARAMS]; -} AcMeshInfo; - -typedef struct { - AcReal* vertex_buffer[NUM_VTXBUF_HANDLES]; - AcMeshInfo info; -} AcMesh; - -typedef enum { - STREAM_DEFAULT, - NUM_STREAM_TYPES, // - STREAM_ALL -} StreamType; - /** Checks whether there are any CUDA devices available. Returns AC_SUCCESS if there is 1 or more, * AC_FAILURE otherwise. */ AcResult acCheckDeviceAvailability(void); @@ -125,94 +103,3 @@ AcResult acIntegrateStepWithOffsetAsync(const int& isubstep, const AcReal& dt, c /** Performs the boundary condition step on the GPUs in the node. Asynchronous. */ AcResult acBoundcondStep(void); AcResult acBoundcondStepAsync(const StreamType stream); - -/* - * ============================================================================= - * Helper functions - * ============================================================================= - */ -static inline size_t -acVertexBufferSize(const AcMeshInfo& info) -{ - return info.int_params[AC_mx] * info.int_params[AC_my] * info.int_params[AC_mz]; -} - -static inline size_t -acVertexBufferSizeBytes(const AcMeshInfo& info) -{ - return sizeof(AcReal) * acVertexBufferSize(info); -} - -static inline size_t -acVertexBufferCompdomainSize(const AcMeshInfo& info) -{ - return info.int_params[AC_nx] * info.int_params[AC_ny] * info.int_params[AC_nz]; -} - -static inline size_t -acVertexBufferCompdomainSizeBytes(const AcMeshInfo& info) -{ - return sizeof(AcReal) * acVertexBufferCompdomainSize(info); -} - -static inline size_t -acVertexBufferIdx(const int i, const int j, const int k, const AcMeshInfo& info) -{ - return i + // - j * info.int_params[AC_mx] + // - k * info.int_params[AC_mx] * info.int_params[AC_my]; -} - -/* -static inline int -acGetParam(const AcMeshInfo& info, const AcIntParam param) -{ - return info.int_params[param]; -} - -static inline int3 -acGetParam(const AcMeshInfo& info, const AcInt3Param param) -{ - return info.int3_params[param]; -} - -static inline AcReal -acGetParam(const AcMeshInfo& info, const AcRealParam param) -{ - return info.real_params[param]; -} - -static inline AcReal3 -acGetParam(const AcMeshInfo& info, const AcReal3Param param) -{ - return info.real3_params[param]; -} - -static inline void -acSetParam(const AcIntParam param, const int value, AcMeshInfo* info) -{ - info->int_params[param] = value; -} - -static inline void -acSetParam(const AcInt3Param param, const int3 value, AcMeshInfo* info) -{ - info->int3_params[param] = value; -} - -static inline void -acSetParam(const AcRealParam param, const AcReal value, AcMeshInfo* info) -{ - info->real_params[param] = value; -} - -static inline void -acSetParam(const AcReal3Param param, const AcReal3 value, AcMeshInfo* info) -{ - info->real3_params[param] = value; -} -*/ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/include/astaroth_defines.h b/include/astaroth_defines.h index 222dc9e..ac9804b 100644 --- a/include/astaroth_defines.h +++ b/include/astaroth_defines.h @@ -79,6 +79,12 @@ typedef enum { AC_SUCCESS = 0, AC_FAILURE = 1 } AcResult; typedef enum { RTYPE_MAX, RTYPE_MIN, RTYPE_RMS, RTYPE_RMS_EXP, NUM_REDUCTION_TYPES } ReductionType; +typedef enum { + STREAM_DEFAULT, + NUM_STREAM_TYPES, // + STREAM_ALL +} StreamType; + #define AC_GEN_ID(X) X typedef enum { AC_FOR_BUILTIN_INT_PARAM_TYPES(AC_GEN_ID) // @@ -116,6 +122,105 @@ extern const char* realparam_names[]; extern const char* real3param_names[]; extern const char* vtxbuf_names[]; +typedef struct { + int int_params[NUM_INT_PARAMS]; + int3 int3_params[NUM_INT3_PARAMS]; + AcReal real_params[NUM_REAL_PARAMS]; + AcReal3 real3_params[NUM_REAL3_PARAMS]; +} AcMeshInfo; + +typedef struct { + AcReal* vertex_buffer[NUM_VTXBUF_HANDLES]; + AcMeshInfo info; +} AcMesh; + +/* + * ============================================================================= + * Helper functions + * ============================================================================= + */ +static inline size_t +acVertexBufferSize(const AcMeshInfo& info) +{ + return info.int_params[AC_mx] * info.int_params[AC_my] * info.int_params[AC_mz]; +} + +static inline size_t +acVertexBufferSizeBytes(const AcMeshInfo& info) +{ + return sizeof(AcReal) * acVertexBufferSize(info); +} + +static inline size_t +acVertexBufferCompdomainSize(const AcMeshInfo& info) +{ + return info.int_params[AC_nx] * info.int_params[AC_ny] * info.int_params[AC_nz]; +} + +static inline size_t +acVertexBufferCompdomainSizeBytes(const AcMeshInfo& info) +{ + return sizeof(AcReal) * acVertexBufferCompdomainSize(info); +} + +static inline size_t +acVertexBufferIdx(const int i, const int j, const int k, const AcMeshInfo& info) +{ + return i + // + j * info.int_params[AC_mx] + // + k * info.int_params[AC_mx] * info.int_params[AC_my]; +} + +/* +static inline int +acGetParam(const AcMeshInfo& info, const AcIntParam param) +{ + return info.int_params[param]; +} + +static inline int3 +acGetParam(const AcMeshInfo& info, const AcInt3Param param) +{ + return info.int3_params[param]; +} + +static inline AcReal +acGetParam(const AcMeshInfo& info, const AcRealParam param) +{ + return info.real_params[param]; +} + +static inline AcReal3 +acGetParam(const AcMeshInfo& info, const AcReal3Param param) +{ + return info.real3_params[param]; +} + +static inline void +acSetParam(const AcIntParam param, const int value, AcMeshInfo* info) +{ + info->int_params[param] = value; +} + +static inline void +acSetParam(const AcInt3Param param, const int3 value, AcMeshInfo* info) +{ + info->int3_params[param] = value; +} + +static inline void +acSetParam(const AcRealParam param, const AcReal value, AcMeshInfo* info) +{ + info->real_params[param] = value; +} + +static inline void +acSetParam(const AcReal3Param param, const AcReal3 value, AcMeshInfo* info) +{ + info->real3_params[param] = value; +} +*/ + #ifdef __cplusplus } // extern "C" #endif