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.

This commit is contained in:
jpekkila
2019-07-23 16:06:54 +03:00
parent c98e730397
commit e5172e2a9a
2 changed files with 105 additions and 113 deletions

View File

@@ -18,30 +18,8 @@
*/ */
#pragma once #pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "astaroth_defines.h" #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, /** Checks whether there are any CUDA devices available. Returns AC_SUCCESS if there is 1 or more,
* AC_FAILURE otherwise. */ * AC_FAILURE otherwise. */
AcResult acCheckDeviceAvailability(void); 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. */ /** Performs the boundary condition step on the GPUs in the node. Asynchronous. */
AcResult acBoundcondStep(void); AcResult acBoundcondStep(void);
AcResult acBoundcondStepAsync(const StreamType stream); 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

View File

@@ -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 { 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 #define AC_GEN_ID(X) X
typedef enum { typedef enum {
AC_FOR_BUILTIN_INT_PARAM_TYPES(AC_GEN_ID) // 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* real3param_names[];
extern const char* vtxbuf_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 #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif