Astaroth
3.1
Scalable Multi-GPU Stencil Computations
Loading...
Searching...
No Matches
datatypes.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2014-2026, Johannes Pekkila, Miikka Vaisala, Touko Puro.
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
#pragma GCC system_header
// NOTE: Silences errors originating from HIP and CUDA
21
// headers
22
23
#include <float.h>
// DBL/FLT_EPSILON
24
#include <math.h>
25
26
#include "
acreal.h
"
27
#include "
astaroth_device_headers.h
"
28
#include "builtin_enums.h"
29
#include "
host_datatypes.h
"
30
31
#ifdef __cplusplus
32
#include <array>
33
#endif
34
35
#if AC_CPU_BUILD == 0
36
#if AC_USE_HIP
37
#include <hip/hip_runtime_api.h>
38
39
#include "
hip.h
"
40
#else
41
#include <cuda_runtime_api.h>
// cuda_assert
42
#include <vector_types.h>
// CUDA vector types
43
#endif
44
#endif
45
46
// convert 3-array into vector
47
#define TOVEC3(type,arr) ((type){arr[0],arr[1],arr[2]})
48
#define TOACREAL3(arr) TOVEC3(AcReal3,arr)
49
#define AcVector AcReal3
50
51
#ifdef __cplusplus
52
53
#define AcArray std::array
54
55
static
HOST_DEVICE_INLINE
size3_t
56
operator+(
const
size3_t
& a,
const
size3_t
& b)
57
{
58
return
(
size3_t
)
59
{
60
a.x + b.x,
61
a.y + b.y,
62
a.z + b.z
63
};
64
}
65
static
HOST_DEVICE_INLINE
int3
66
operator+(
const
size3_t
& a,
const
int3& b)
67
{
68
return
(int3)
69
{
70
(int)a.x + b.x,
71
(
int
)a.y + b.y,
72
(int)a.z + b.z
73
};
74
}
75
static
HOST_DEVICE_INLINE
bool
76
operator==(
const
size3_t
& a,
const
int3& b)
77
{
78
return
79
(
int
)a.x == b.x &&
80
(int)a.y == b.y &&
81
(
int
)a.z == b.z;
82
}
83
84
static
HOST_DEVICE_INLINE
bool
85
operator==(
const
int3& a,
const
size3_t
& b)
86
{
87
return
88
a.x == (int)b.x &&
89
a.y == (
int
)b.y &&
90
a.z == (int)b.z;
91
}
92
93
#endif
acreal.h
astaroth_device_headers.h
HOST_DEVICE_INLINE
#define HOST_DEVICE_INLINE
Definition
func_attributes.h:15
hip.h
host_datatypes.h
size3_t
Volume size3_t
Definition
host_datatypes.h:76
acc-runtime
api
datatypes.h
Generated by
1.15.0