Cleaned up the include directory: removed all unnecessary stuff and moved common definitions to a separate file
This commit is contained in:
@@ -16,183 +16,28 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Astaroth. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* \brief Brief info.
|
||||
*
|
||||
* Provides an interface to Astaroth. Contains all the necessary configuration
|
||||
* structs and functions for running the code on multiple GPUs.
|
||||
*
|
||||
* All interface functions declared here (such as acInit()) operate all GPUs
|
||||
* available in the node under the hood, and the user does not need any
|
||||
* information about the decomposition, synchronization or such to use these
|
||||
* functions.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/* Prevent name mangling */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <float.h> // FLT_EPSILON, etc
|
||||
#include <stdlib.h> // size_t
|
||||
#include <vector_types.h> // CUDA vector types (float4, etc)
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Flags for auto-optimization
|
||||
* =============================================================================
|
||||
*/
|
||||
#define AUTO_OPTIMIZE (0) // DEPRECATED TODO remove
|
||||
#define BOUNDCONDS_OPTIMIZE (0)
|
||||
#define GENERATE_BENCHMARK_DATA (0)
|
||||
#define VERBOSE_PRINTING (1)
|
||||
|
||||
// Device info
|
||||
#define REGISTERS_PER_THREAD (255)
|
||||
#define MAX_REGISTERS_PER_BLOCK (65536)
|
||||
#define MAX_THREADS_PER_BLOCK (1024)
|
||||
#define WARP_SIZE (32)
|
||||
/*
|
||||
* =============================================================================
|
||||
* Compile-time constants used during simulation (user definable)
|
||||
* =============================================================================
|
||||
*/
|
||||
// USER_PROVIDED_DEFINES must be defined in user.h if the user wants to override the following
|
||||
// logical switches
|
||||
#include "user.h"
|
||||
|
||||
// clang-format off
|
||||
#ifndef USER_PROVIDED_DEFINES
|
||||
#include "stencil_defines.h"
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Built-in parameters
|
||||
* =============================================================================
|
||||
*/
|
||||
// clang-format off
|
||||
#define AC_FOR_BUILTIN_INT_PARAM_TYPES(FUNC)\
|
||||
/* cparams */\
|
||||
FUNC(AC_nx), \
|
||||
FUNC(AC_ny), \
|
||||
FUNC(AC_nz), \
|
||||
FUNC(AC_mx), \
|
||||
FUNC(AC_my), \
|
||||
FUNC(AC_mz), \
|
||||
FUNC(AC_nx_min), \
|
||||
FUNC(AC_ny_min), \
|
||||
FUNC(AC_nz_min), \
|
||||
FUNC(AC_nx_max), \
|
||||
FUNC(AC_ny_max), \
|
||||
FUNC(AC_nz_max), \
|
||||
/* Additional */\
|
||||
FUNC(AC_mxy),\
|
||||
FUNC(AC_nxy),\
|
||||
FUNC(AC_nxyz),
|
||||
// clang-format on
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Single/double precision switch
|
||||
* =============================================================================
|
||||
*/
|
||||
// clang-format off
|
||||
#if AC_DOUBLE_PRECISION == 1
|
||||
typedef double AcReal;
|
||||
typedef double3 AcReal3;
|
||||
#define AC_REAL_MAX (DBL_MAX)
|
||||
#define AC_REAL_MIN (DBL_MIN)
|
||||
#define AC_REAL_EPSILON (DBL_EPSILON)
|
||||
#else
|
||||
typedef float AcReal;
|
||||
typedef float3 AcReal3;
|
||||
#define AC_REAL_MAX (FLT_MAX)
|
||||
#define AC_REAL_MIN (FLT_MIN)
|
||||
#define AC_REAL_EPSILON (FLT_EPSILON)
|
||||
#endif
|
||||
// clang-format on
|
||||
#include "astaroth_defines.h"
|
||||
|
||||
typedef struct {
|
||||
AcReal3 row[3];
|
||||
} AcMatrix;
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Helper macros
|
||||
* =============================================================================
|
||||
*/
|
||||
#define AC_GEN_ID(X) X
|
||||
#define AC_GEN_STR(X) #X
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Error codes
|
||||
* =============================================================================
|
||||
*/
|
||||
typedef enum { AC_SUCCESS = 0, AC_FAILURE = 1 } AcResult;
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Reduction types
|
||||
* =============================================================================
|
||||
*/
|
||||
typedef enum { RTYPE_MAX, RTYPE_MIN, RTYPE_RMS, RTYPE_RMS_EXP, NUM_REDUCTION_TYPES } ReductionType;
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Definitions for the enums and structs for AcMeshInfo (DO NOT TOUCH)
|
||||
* =============================================================================
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
AC_FOR_BUILTIN_INT_PARAM_TYPES(AC_GEN_ID) //
|
||||
AC_FOR_USER_INT_PARAM_TYPES(AC_GEN_ID), //
|
||||
NUM_INT_PARAM_TYPES
|
||||
} AcIntParam;
|
||||
|
||||
typedef enum { AC_FOR_REAL_PARAM_TYPES(AC_GEN_ID), NUM_REAL_PARAM_TYPES } AcRealParam;
|
||||
// typedef enum { AC_FOR_VEC_PARAM_TYPES(AC_GEN_ID), NUM_VEC_PARAM_TYPES } AcVecParam;
|
||||
|
||||
extern const char* intparam_names[]; // Defined in astaroth.cu
|
||||
extern const char* realparam_names[]; // Defined in astaroth.cu
|
||||
|
||||
typedef struct {
|
||||
int int_params[NUM_INT_PARAM_TYPES];
|
||||
AcReal real_params[NUM_REAL_PARAM_TYPES];
|
||||
// AcReal* vec_params[NUM_VEC_PARAM_TYPES];
|
||||
int int_params[NUM_INT_PARAMS];
|
||||
int3 int3_params[NUM_INT3_PARAMS];
|
||||
AcReal real_params[NUM_REAL_PARAMS];
|
||||
AcReal3 vec_params[NUM_REAL3_PARAMS];
|
||||
} AcMeshInfo;
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Definitions for the enums and structs for AcMesh (DO NOT TOUCH)
|
||||
* =============================================================================
|
||||
*/
|
||||
typedef enum { AC_FOR_VTXBUF_HANDLES(AC_GEN_ID) NUM_VTXBUF_HANDLES } VertexBufferHandle;
|
||||
|
||||
extern const char* vtxbuf_names[]; // Defined in astaroth.cu
|
||||
|
||||
/*
|
||||
typedef struct {
|
||||
AcReal* data;
|
||||
} VertexBuffer;
|
||||
*/
|
||||
|
||||
// NOTE: there's no particular benefit declaring AcMesh a class, since
|
||||
// a library user may already have allocated memory for the vertex_buffers.
|
||||
// But then we would allocate memory again when the user wants to start
|
||||
// filling the class with data. => Its better to consider AcMesh as a
|
||||
// payload-only struct
|
||||
typedef struct {
|
||||
AcReal* vertex_buffer[NUM_VTXBUF_HANDLES];
|
||||
AcMeshInfo info;
|
||||
} AcMesh;
|
||||
|
||||
typedef enum {
|
||||
STREAM_DEFAULT,
|
||||
NUM_STREAM_TYPES, //
|
||||
STREAM_ALL
|
||||
} StreamType;
|
||||
|
||||
#define AC_VTXBUF_SIZE(mesh_info) \
|
||||
((size_t)(mesh_info.int_params[AC_mx] * mesh_info.int_params[AC_my] * \
|
||||
mesh_info.int_params[AC_mz]))
|
||||
@@ -209,17 +54,6 @@ typedef struct {
|
||||
((i) + (j)*mesh_info.int_params[AC_mx] + \
|
||||
(k)*mesh_info.int_params[AC_mx] * mesh_info.int_params[AC_my])
|
||||
|
||||
/*
|
||||
* =============================================================================
|
||||
* Astaroth interface: Basic functions. Synchronous.
|
||||
* =============================================================================
|
||||
*/
|
||||
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);
|
||||
@@ -303,8 +137,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);
|
||||
|
||||
/* End extern "C" */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user