Astaroth  3.1
Scalable Multi-GPU Stencil Computations
Loading...
Searching...
No Matches
astaroth_base.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2014-2026, Johannes Pekkila, Touko Puro, Miikka Vaisala.
3
4 This file is part of Astaroth.
5
6 Astaroth is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Astaroth is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Astaroth. If not, see <http://www.gnu.org/licenses/>.
18*/
19#pragma once
20
21#include <stdbool.h>
22
23#include "acc_runtime.h"
24#include "func_define.h"
25
26#include "user_built-in_constants.h"
27#include "user_builtin_non_scalar_constants.h"
28
29#if AC_RUNTIME_COMPILATION
30#include <dlfcn.h>
31#endif
32
33#include "ac_mpi.h"
34
35#ifdef __cplusplus
36#include <functional>
37#endif
38
39#define UNUSED __attribute__((unused)) // Does not give a warning if unused
40
41typedef struct {
42 AcReal* vertex_buffer[NUM_ALL_FIELDS];
43 AcReal* profile[NUM_PROFILES];
45} AcMesh;
46
83
84#define NUM_STREAMS (32)
85
86// For plate buffers.
87enum AcPlateDirection {AC_H2D, AC_D2H}; // pack/unpack direction
88typedef enum {AC_XZ=0, AC_YZ=1, AC_BOT=0, AC_TOP=2, NUM_PLATE_BUFFERS=4} PlateType;
89
90
91#define RTYPE_ISNAN (RTYPE_SUM)
92
93#define AC_FOR_INIT_TYPES(FUNC) \
94 FUNC(INIT_TYPE_RANDOM) \
95 FUNC(INIT_TYPE_AA_RANDOM) \
96 FUNC(INIT_TYPE_XWAVE) \
97 FUNC(INIT_TYPE_GAUSSIAN_RADIAL_EXPL) \
98 FUNC(INIT_TYPE_ABC_FLOW) \
99 FUNC(INIT_TYPE_SIMPLE_CORE) \
100 FUNC(INIT_TYPE_KICKBALL) \
101 FUNC(INIT_TYPE_VEDGE) \
102 FUNC(INIT_TYPE_VEDGEX) \
103 FUNC(INIT_TYPE_RAYLEIGH_TAYLOR) \
104 FUNC(INIT_TYPE_RAYLEIGH_BENARD)
105
106#define AC_GEN_ID(X) X,
107
112
113
114#define AcProcMappingStrategy_MORTON (-1)
115#define AcProcMappingStrategy_LINEAR (1)
116
117#define AcDecompStrategy_DEFAULT (-1)
118#define AcDecompStrategy_EXTERNAL (1)
119
120#define AcMPICommStrategy_DUPLICATE_MPI_COMM_WORLD (-1)
121#define AcMPICommStrategy_DUPLICATE_USER_COMM (1)
122
123#undef AC_GEN_ID
124
125#define AC_GEN_STR(X) #X,
126static const char* initcondtype_names[] UNUSED = {AC_FOR_INIT_TYPES(AC_GEN_STR) "-end-"};
127
128
129#undef AC_GEN_STR
130
131typedef struct node_s* Node;
132typedef struct device_s* Device;
133
134
135typedef struct {
136 Volume m;
137 Volume n;
138} GridDims;
139
147
148#ifdef __cplusplus
149
150template <typename T1, typename T2, typename T3>
151static inline AcReal3
152acConstructReal3Param(const T1 a, const T2 b, const T3 c, const AcMeshInfo info)
153{
154 return (AcReal3)
155 {
156 info[a],
157 info[b],
158 info[c]
159 };
160}
161template <typename T1, typename T2, typename T3>
162static inline int3
163acConstructInt3Param(const T1 a, const T2 b, const T3 c,
164 const AcMeshInfo info)
165{
166 return (int3){
167 info[a],
168 info[b],
169 info[c],
170 };
171}
172#endif
float AcReal
Definition acreal.h:11
Stream
Definition astaroth_base.h:47
@ STREAM_20
Definition astaroth_base.h:68
@ STREAM_29
Definition astaroth_base.h:77
@ STREAM_25
Definition astaroth_base.h:73
@ STREAM_30
Definition astaroth_base.h:78
@ STREAM_5
Definition astaroth_base.h:53
@ STREAM_28
Definition astaroth_base.h:76
@ STREAM_DEFAULT
Definition astaroth_base.h:81
@ STREAM_23
Definition astaroth_base.h:71
@ STREAM_2
Definition astaroth_base.h:50
@ STREAM_27
Definition astaroth_base.h:75
@ STREAM_17
Definition astaroth_base.h:65
@ STREAM_14
Definition astaroth_base.h:62
@ STREAM_3
Definition astaroth_base.h:51
@ STREAM_13
Definition astaroth_base.h:61
@ STREAM_12
Definition astaroth_base.h:60
@ STREAM_9
Definition astaroth_base.h:57
@ STREAM_21
Definition astaroth_base.h:69
@ STREAM_22
Definition astaroth_base.h:70
@ STREAM_7
Definition astaroth_base.h:55
@ STREAM_16
Definition astaroth_base.h:64
@ STREAM_24
Definition astaroth_base.h:72
@ STREAM_26
Definition astaroth_base.h:74
@ STREAM_1
Definition astaroth_base.h:49
@ STREAM_6
Definition astaroth_base.h:54
@ STREAM_19
Definition astaroth_base.h:67
@ STREAM_4
Definition astaroth_base.h:52
@ STREAM_0
Definition astaroth_base.h:48
@ STREAM_31
Definition astaroth_base.h:79
@ STREAM_8
Definition astaroth_base.h:56
@ STREAM_18
Definition astaroth_base.h:66
@ STREAM_15
Definition astaroth_base.h:63
@ STREAM_ALL
Definition astaroth_base.h:80
@ STREAM_11
Definition astaroth_base.h:59
@ STREAM_10
Definition astaroth_base.h:58
struct device_s * Device
Definition astaroth_base.h:132
struct node_s * Node
Definition astaroth_base.h:131
#define AC_FOR_INIT_TYPES(FUNC)
Definition astaroth_base.h:93
PlateType
Definition astaroth_base.h:88
@ AC_XZ
Definition astaroth_base.h:88
@ AC_TOP
Definition astaroth_base.h:88
@ AC_BOT
Definition astaroth_base.h:88
@ NUM_PLATE_BUFFERS
Definition astaroth_base.h:88
@ AC_YZ
Definition astaroth_base.h:88
#define AC_GEN_ID(X)
Definition astaroth_base.h:106
InitType
Definition astaroth_base.h:108
@ NUM_INIT_TYPES
Definition astaroth_base.h:110
#define AC_GEN_STR(X)
Definition astaroth_base.h:125
AcPlateDirection
Definition astaroth_base.h:87
@ AC_H2D
Definition astaroth_base.h:87
@ AC_D2H
Definition astaroth_base.h:87
int3 acConstructInt3Param(const AcIntParam a, const AcIntParam b, const AcIntParam c, const AcMeshInfo info)
#define UNUSED
Definition func_attributes.h:4
Definition acc_runtime.h:156
Definition astaroth_base.h:41
AcReal * vertex_buffer[NUM_ALL_FIELDS]
Definition astaroth_base.h:42
AcReal * profile[NUM_PROFILES]
Definition astaroth_base.h:43
AcMeshInfo info
Definition astaroth_base.h:44
Definition astaroth_base.h:140
Device * devices
Definition astaroth_base.h:142
int num_devices
Definition astaroth_base.h:141
GridDims subgrid
Definition astaroth_base.h:145
GridDims grid
Definition astaroth_base.h:144
Definition astaroth_base.h:135
Volume m
Definition astaroth_base.h:136
Volume n
Definition astaroth_base.h:137