Astaroth  3.1
Scalable Multi-GPU Stencil Computations
Loading...
Searching...
No Matches
astaroth_utils.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
25#pragma once
26
27#include <stdarg.h>
28
29#include "astaroth.h"
30
31#ifdef __ASTAROTH_UTILS_MAIN_STORAGE__
32#define __FUNC_DEFINE_MAIN_STORAGE__
33#endif
34
35#include "func_define.h"
36
38
39typedef struct {
42 long double abs_error;
43 long double ulp_error;
44 long double rel_error;
47 int x;
48 int y;
49 int z;
50} Error;
51
52FUNC_DEFINE(AcResult, acHostVertexBufferSet,(const VertexBufferHandle handle, const AcReal value, AcMesh* mesh));
53
55
57
59
61
66
67FUNC_DEFINE(AcReal, acHostReduceScal,(const AcMesh mesh, const AcReduction reduction, const VertexBufferHandle a));
68
69FUNC_DEFINE(AcReal, acHostReduceVec,(const AcMesh mesh, const AcReduction reduction, const VertexBufferHandle a, const VertexBufferHandle b, const VertexBufferHandle c));
70FUNC_DEFINE(AcReal, acHostReduceVecScal,(const AcMesh mesh, const AcReduction reduction, const VertexBufferHandle a, const VertexBufferHandle b, const VertexBufferHandle c, const VertexBufferHandle d));
71
72FUNC_DEFINE(bool, acEvalError,(const char* label, const Error error));
73FUNC_DEFINE(bool, acEvalErrorWithMaximumError,(const char* label, const Error error, const long double max_ulp_error));
74
75FUNC_DEFINE(AcResult, acVerifyMesh,(const char* label, const AcMesh model, const AcMesh candidate));
76FUNC_DEFINE(AcResult, acVerifyMeshWithMaximumError,(const char* label, const AcMesh model, const AcMesh candidate, const long double max_ulp_error));
77//AcResult (*acVerifyMesh)(const char*, const AcMesh, const AcMesh);
78
79FUNC_DEFINE(AcResult, acMeshDiffWriteSliceZ,(const char* path, const AcMesh model, const AcMesh candidate, const size_t z));
80
81FUNC_DEFINE(AcResult, acMeshDiffWrite,(const char* path, const AcMesh model, const AcMesh candidate));
82FUNC_DEFINE(AcResult, acVerifyMeshCompDomain,(const char* label, const AcMesh model, const AcMesh candidate));
83
84FUNC_DEFINE(AcResult, acHostMeshWriteToFile,(const AcMesh mesh, const size_t id));
85
87
88FUNC_DEFINE(Error, acGetError,(const AcReal model, const AcReal candidate));
89// Profiles
90FUNC_DEFINE(AcResult, acHostProfileDerz,(const AcReal* in, const size_t count, const AcReal grid_spacing,
91 AcReal* out));
92
93FUNC_DEFINE(AcResult, acHostProfileDerzz,(const AcReal* in, const size_t count, const AcReal grid_spacing,
94 AcReal* out));
95
97
99FUNC_DEFINE(AcResult, acHostWriteProfileToFile, (const char* filepath, const AcReal* profile, const size_t profile_count));
100
102FUNC_DEFINE(AcResult, acHostInitProfileToCosineWave, (const AcReal spacing, const AcReal initial_pos, const AcReal amplitude, const AcReal wavenumber, const size_t mz, AcReal* profile));
103
105FUNC_DEFINE(AcResult, acHostInitProfileToSineWave, (const AcReal spacing, const AcReal initial_pos, const AcReal amplitude, const AcReal wavenumber, const size_t mz, AcReal* profile));
106
108FUNC_DEFINE(AcResult, acHostInitProfileToValue, (const long double value, const size_t profile_count, AcReal* profile));
109
111
113acLoadConfig(const char* config_path, AcMeshInfo* config);
114
116
117#define AC_RED "\x1B[31m"
118#define AC_GRN "\x1B[32m"
119#define AC_YEL "\x1B[33m"
120#define AC_BLU "\x1B[34m"
121#define AC_MAG "\x1B[35m"
122#define AC_CYN "\x1B[36m"
123#define AC_WHT "\x1B[37m"
124#define AC_COL_RESET "\x1B[0m"
float AcReal
Definition acreal.h:11
bool acEvalError(const char *label, const Error error)
AcResult acMeshDiffWriteSliceZ(const char *path, const AcMesh model, const AcMesh candidate, const size_t z)
AcResult acHostMeshWriteToFile(const AcMesh mesh, const size_t id)
AcResult acLoadUtils(const AcMeshInfo info)
Error acGetError(const AcReal model, const AcReal candidate)
AcReal acHostReduceVec(const AcMesh mesh, const AcReduction reduction, const VertexBufferHandle a, const VertexBufferHandle b, const VertexBufferHandle c)
AcResult acHostMeshApplyPeriodicBounds(AcMesh *mesh)
AcResult acHostInitProfileToCosineWave(const AcReal spacing, const AcReal initial_pos, const AcReal amplitude, const AcReal wavenumber, const size_t mz, AcReal *profile)
AcReal acHostReduceScal(const AcMesh mesh, const AcReduction reduction, const VertexBufferHandle a)
AcReal acHostReduceVecScal(const AcMesh mesh, const AcReduction reduction, const VertexBufferHandle a, const VertexBufferHandle b, const VertexBufferHandle c, const VertexBufferHandle d)
AcResult acHostMeshSet(const AcReal value, AcMesh *mesh)
AcResult AcMeshInfo * config
Definition astaroth_utils.h:113
AcResult acVerifyMeshCompDomain(const char *label, const AcMesh model, const AcMesh candidate)
AcResult acHostReduceXYAverage(const AcReal *in, const AcMeshDims dims, AcReal *out)
AcResult acVerifyMeshWithMaximumError(const char *label, const AcMesh model, const AcMesh candidate, const long double max_ulp_error)
AcResult acHostMeshReadFromFile(const size_t id, AcMesh *mesh)
AcResult acHostMeshApplyConstantBounds(const AcReal value, AcMesh *mesh)
AcResult acHostWriteProfileToFile(const char *filepath, const AcReal *profile, const size_t profile_count)
AcResult acHostMeshClear(AcMesh *mesh)
AcResult acHostVertexBufferSet(const VertexBufferHandle handle, const AcReal value, AcMesh *mesh)
AcResult acHostInitProfileToSineWave(const AcReal spacing, const AcReal initial_pos, const AcReal amplitude, const AcReal wavenumber, const size_t mz, AcReal *profile)
AcResult acHostIntegrateStep(AcMesh mesh, const AcReal dt)
AcResult acMeshDiffWrite(const char *path, const AcMesh model, const AcMesh candidate)
AcResult acHostProfileDerzz(const AcReal *in, const size_t count, const AcReal grid_spacing, AcReal *out)
AcResult acVerifyMesh(const char *label, const AcMesh model, const AcMesh candidate)
AcResult acHostInitProfileToValue(const long double value, const size_t profile_count, AcReal *profile)
AcResult acHostProfileDerz(const AcReal *in, const size_t count, const AcReal grid_spacing, AcReal *out)
bool acEvalErrorWithMaximumError(const char *label, const Error error, const long double max_ulp_error)
#define UNUSED
Definition func_attributes.h:4
#define AC_BEGIN_C_DECLARATIONS
Definition func_define.h:14
#define AC_END_C_DECLARATIONS
Definition func_define.h:15
#define FUNC_DEFINE(return_type, func_name,...)
Definition func_define.h:69
AcResult
Definition host_datatypes.h:10
Definition host_datatypes.h:84
Definition acc_runtime.h:156
Definition astaroth_base.h:41
Definition acc_runtime.h:92
Definition astaroth_utils.h:39
int x
Definition astaroth_utils.h:47
long double ulp_error
Definition astaroth_utils.h:43
long double rel_error
Definition astaroth_utils.h:44
long double abs_error
Definition astaroth_utils.h:42
int y
Definition astaroth_utils.h:48
AcReal minimum_magnitude
Definition astaroth_utils.h:46
int z
Definition astaroth_utils.h:49
AcReal candidate
Definition astaroth_utils.h:41
AcReal maximum_magnitude
Definition astaroth_utils.h:45
AcReal model
Definition astaroth_utils.h:40
static __device__ const int dims
Definition user_kernel.h:128
error
Definition vecs.h:234