ASCOT5
Loading...
Searching...
No Matches
offload.h
1
5#ifndef OFFLOAD_ACC_OMP_H
6#define OFFLOAD_ACC_OMP_H
7
8#include "ascot5.h"
9
13#if defined(GPU) && defined(_OPENMP)
14#define GPU_PARALLEL_LOOP_ALL_LEVELS \
15 str_pragma(omp target teams distribute parallel for simd)
16#elif defined(GPU) && defined(_OPENACC)
17#define GPU_PARALLEL_LOOP_ALL_LEVELS str_pragma(acc parallel loop)
18#else
19#define GPU_PARALLEL_LOOP_ALL_LEVELS str_pragma(omp simd)
20#endif
21
25#if defined(GPU) && defined(_OPENMP)
26#define GPU_PARALLEL_LOOP_ALL_LEVELS_REDUCTION(...) \
27 str_pragma(omp target teams distribute parallel for simd \
28 reduction(+:__VA_ARGS__))
29#elif defined(GPU) && defined(_OPENACC)
30#define GPU_PARALLEL_LOOP_ALL_LEVELS_REDUCTION(...) \
31 str_pragma(acc parallel loop reduction(+:__VA_ARGS__))
32#else
33#define GPU_PARALLEL_LOOP_ALL_LEVELS_REDUCTION(...)
34#endif
35
39#if defined(GPU) && defined(_OPENMP)
40#define DECLARE_TARGET str_pragma(omp declare target)
41#elif defined(GPU) && defined(_OPENACC)
42#define DECLARE_TARGET str_pragma(acc routine seq)
43#else
44#define DECLARE_TARGET
45#endif
46
50#if defined(GPU) && defined(_OPENMP)
51#define DECLARE_TARGET_END str_pragma(omp end declare target)
52#elif defined(GPU) && defined(_OPENACC)
53#define DECLARE_TARGET_END
54#else
55#define DECLARE_TARGET_END
56#endif
57
61#if defined(GPU) && defined(_OPENMP)
62#define GPU_MAP_TO_DEVICE(...) \
63 str_pragma(omp target enter data map (to: __VA_ARGS__))
64#elif defined(GPU) && defined(_OPENACC)
65#define GPU_MAP_TO_DEVICE(...) str_pragma(acc enter data copyin (__VA_ARGS__))
66#else
67#define GPU_MAP_TO_DEVICE(...)
68#endif
69
73#if defined(GPU) && defined(_OPENMP)
74#define GPU_UPDATE_FROM_DEVICE(...) \
75 str_pragma(omp target update from (__VA_ARGS__))
76#elif defined(GPU) && defined(_OPENACC)
77#define GPU_UPDATE_FROM_DEVICE(...) str_pragma(acc update host (__VA_ARGS__))
78#else
79#define GPU_UPDATE_FROM_DEVICE(...)
80#endif
81
85#if defined(GPU) && defined(_OPENMP)
86#define GPU_MAP_FROM_DEVICE(...) \
87 str_pragma(omp target exit data map (from: __VA_ARGS__))
88#elif defined(GPU) && defined(_OPENACC)
89#define GPU_MAP_FROM_DEVICE(...) \
90 str_pragma(acc exit data copyout (__VA_ARGS__))
91#else
92#define GPU_MAP_FROM_DEVICE(...)
93#endif
94
98#if defined(GPU) && defined(_OPENMP)
99#define GPU_MAP_DELETE_DEVICE(...) \
100 str_pragma(omp target exit data (delete: __VA_ARGS__))
101#elif defined(GPU) && defined(_OPENACC)
102#define GPU_MAP_DELETE_DEVICE(...) \
103 str_pragma(acc exit data delete (__VA_ARGS__))
104#else
105#define GPU_MAP_DELETE_DEVICE(...)
106#endif
107
111#if defined(GPU) && defined(_OPENMP)
112#define GPU_ATOMIC str_pragma(omp atomic)
113#elif defined(GPU) && defined(_OPENACC)
114#define GPU_ATOMIC str_pragma(omp atomic)
115#else
116#define GPU_ATOMIC str_pragma(omp atomic)
117#endif
118
122#if defined(GPU) && defined(_OPENMP)
123#define DECLARE_TARGET_SIMD
124#elif defined(GPU) && defined(_OPENACC)
125#define DECLARE_TARGET_SIMD
126#elif defined(__INTEL_LLVM_COMPILER)
127/* icx: avoid vector-function ABI (fixes _ZGV... undefined references) */
128#define DECLARE_TARGET_SIMD
129#else
130#warning "omp declare simd"
131#define DECLARE_TARGET_SIMD str_pragma(omp declare simd)
132#endif
133
137#if defined(GPU) && defined(_OPENMP)
138#define DECLARE_TARGET_SIMD_UNIFORM(...)
139#elif defined(GPU) && defined(_OPENACC)
140#define DECLARE_TARGET_SIMD_UNIFORM(...) \
141 str_pragma(omp declare simd uniform (__VA_ARGS__))
142#else
143#define DECLARE_TARGET_SIMD_UNIFORM(...)
144#endif
145
149#if defined(GPU) && defined(_OPENMP)
150#define GPU_DECLARE_TARGET_SIMD str_pragma(omp declare target)
151#elif defined(GPU) && defined(_OPENACC)
152#define GPU_DECLARE_TARGET_SIMD str_pragma(acc routine seq)
153#elif defined(__INTEL_LLVM_COMPILER)
154/* icx: avoid vector-function ABI (fixes _ZGV... undefined references) */
155#define GPU_DECLARE_TARGET_SIMD
156#else
157#define GPU_DECLARE_TARGET_SIMD str_pragma(omp declare simd)
158#endif
159
163#if defined(GPU) && defined(_OPENMP)
164#define GPU_DECLARE_TARGET_SIMD_END str_pragma(omp end declare target)
165#elif defined(GPU) && defined(_OPENACC)
166#define GPU_DECLARE_TARGET_SIMD_END
167#else
168#define GPU_DECLARE_TARGET_SIMD_END
169#endif
170
174#if defined(GPU) && defined(_OPENMP)
175#define GPU_DECLARE_TARGET_SIMD_UNIFORM(...) str_pragma(omp declare target)
176#elif defined(GPU) && defined(_OPENACC)
177#define GPU_DECLARE_TARGET_SIMD_UNIFORM(...) str_pragma(acc routine seq)
178#elif defined(__INTEL_LLVM_COMPILER)
179#define GPU_DECLARE_TARGET_SIMD_UNIFORM(...)
180#else
181#define GPU_DECLARE_TARGET_SIMD_UNIFORM(...) \
182 str_pragma(omp declare simd uniform (__VA_ARGS__))
183#endif
184
188#if defined(GPU) && defined(_OPENMP)
189#define GPU_DECLARE_TARGET_SIMD_UNIFORM_END str_pragma(omp end declare target)
190#elif defined(GPU) && defined(_OPENACC)
191#define GPU_DECLARE_TARGET_SIMD_UNIFORM_END
192#else
193#define GPU_DECLARE_TARGET_SIMD_UNIFORM_END
194#endif
195
199#if defined(GPU)
200#define OMP_PARALLEL_CPU_ONLY
201#else
202#define OMP_PARALLEL_CPU_ONLY str_pragma(omp parallel)
203#endif
204
209#if defined(GPU) && defined(_OPENACC)
210#define GPU_SEQUENTIAL_LOOP str_pragma(acc loop seq)
211#else
212#define GPU_SEQUENTIAL_LOOP
213#endif
214
219#if defined(GPU) && defined(_OPENACC)
220#define GPU_DATA_IS_MAPPED(...) str_pragma(acc data present(__VA_ARGS__))
221#else
222#define GPU_DATA_IS_MAPPED(...)
223#endif
224
225#ifdef _OPENACC
229#define NGANGS 1024
230
234#define NWORKERS 8
235
239#define NVECTORS 32
240#endif // _OPENACC
241
242#endif
Main header file for ASCOT5.