YASK
Yet Another Stencil Kit: a software framework for creating HPC stencil code. Copyright 2014-2023 Intel Corporation.
Loading...
Searching...
No Matches
yask_kernel_api.hpp
Go to the documentation of this file.
1/*****************************************************************************
2
3YASK: Yet Another Stencil Kit
4Copyright (c) 2014-2023, Intel Corporation
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to
8deal in the Software without restriction, including without limitation the
9rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10sell copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13* The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22IN THE SOFTWARE.
23
24*****************************************************************************/
25
27
28// This file uses Doxygen markup for API documentation-generation.
29// See https://www.doxygen.nl/manual/index.html.
32#pragma once
33
34#include "yask_common_api.hpp"
35#include <vector>
36#include <cinttypes>
37
38#ifndef MPI_VERSION
39typedef int MPI_Comm;
40#endif
41
42namespace yask {
43
50 // Forward declarations of classes and pointers.
51
52 class yk_env;
54 typedef std::shared_ptr<yk_env> yk_env_ptr;
55
56 class yk_solution;
58 typedef std::shared_ptr<yk_solution> yk_solution_ptr;
59
60 class yk_var;
62 typedef std::shared_ptr<yk_var> yk_var_ptr;
63
64 class yk_stats;
66 typedef std::shared_ptr<yk_stats> yk_stats_ptr;
67
69} // namespace yask.
70
72#include "aux/yk_var_api.hpp"
73
74namespace yask {
75
82 class yk_factory {
83 public:
84 yk_factory();
85 virtual ~yk_factory() {}
86
88
91 virtual std::string
93
95
123 virtual yk_env_ptr
124 new_env() const;
125
127
136 virtual yk_env_ptr
137 new_env(MPI_Comm comm) const;
138
140
145 virtual yk_solution_ptr
147
149
156 virtual yk_solution_ptr
158 const yk_solution_ptr source ) const;
161 }; // yk_factory.
162
164
167 class yk_env {
168 public:
169 virtual ~yk_env() {}
170
172
177 static void
181
183
186 static void
188
190
197 static yask_output_ptr
199
201
206 static inline void
207 print_splash(int argc, char** argv,
208 std::string invocation_leader = "invocation: ") {
209 yask_print_splash(get_debug_output()->get_ostream(),
210 argc, argv, invocation_leader);
211 }
212
214
221 static void
222 set_trace_enabled(bool enable);
223
225
231 static bool
233
235
238 virtual int
239 get_num_ranks() const =0;
240
242
245 virtual int
246 get_rank_index() const =0;
247
249
253 virtual void
254 global_barrier() const =0;
255
257
262 virtual idx_t
263 sum_over_ranks(idx_t rank_val) const =0;
264
266
275 virtual void
277 const std::string& descr) const =0;
278
280
288 virtual void
290
292 YASK_NORETURN virtual void
293 exit(int code) =0;
294
295 }; // yk_env.
296
303
306} // namespace yask.
Kernel environment.
Definition yask_kernel_api.hpp:167
static void print_splash(int argc, char **argv, std::string invocation_leader="invocation: ")
Print a YASK spash message to debug output.
Definition yask_kernel_api.hpp:207
virtual idx_t sum_over_ranks(idx_t rank_val) const =0
Find sum of an idx_t value over all ranks.
virtual void global_barrier() const =0
Wait until all ranks have reached this element.
virtual YASK_NORETURN void exit(int code)=0
Finalize the environment and exit.
static yask_output_ptr get_debug_output()
Get object to receive debug output.
virtual int get_rank_index() const =0
Get MPI rank index.
static void set_debug_output(yask_output_ptr debug)
Set object to receive debug output.
static void disable_debug_output()
Disable the debug output.
virtual void finalize()=0
Finalize the environment.
virtual void assert_equality_over_ranks(idx_t rank_val, const std::string &descr) const =0
Makes sure an idx_t values is the same over all ranks.
static bool is_trace_enabled()
Get whether tracing is enabled.
static void set_trace_enabled(bool enable)
Enable or disable additional debug tracing.
virtual int get_num_ranks() const =0
Get number of MPI ranks.
Bootstrap factory to create a stencil solution.
Definition yask_kernel_api.hpp:82
virtual std::string get_version_string()
Version information.
virtual yk_env_ptr new_env(MPI_Comm comm) const
Create a yk_env object using the provided MPI communicator.
virtual yk_solution_ptr new_solution(yk_env_ptr env, const yk_solution_ptr source) const
[Advanced] Create a stencil solution by copying the settings from another.
virtual yk_solution_ptr new_solution(yk_env_ptr env) const
Create a stencil solution.
virtual yk_env_ptr new_env() const
Create an object to hold environment information.
Stencil solution as defined by the generated code from the YASK stencil compiler.
Definition yk_solution_api.hpp:82
Statistics from calls to run_solution().
Definition yk_solution_api.hpp:1300
A run-time YASK data container.
Definition yk_var_api.hpp:185
YASK_INT64_T idx_t
Type to use for indexing grids.
Definition yask_common_api.hpp:86
std::shared_ptr< yask_output > yask_output_ptr
Shared pointer to yask_output.
Definition yask_common_api.hpp:105
void yask_print_splash(std::ostream &os, int argc, char **argv, std::string invocation_leader="invocation: ")
Print a YASK spash message to os.
std::shared_ptr< yk_stats > yk_stats_ptr
Shared pointer to yk_stats.
Definition yask_kernel_api.hpp:66
std::shared_ptr< yk_solution > yk_solution_ptr
Shared pointer to yk_solution.
Definition yask_kernel_api.hpp:58
std::shared_ptr< yk_env > yk_env_ptr
Shared pointer to yk_env.
Definition yask_kernel_api.hpp:54
std::shared_ptr< yk_var > yk_var_ptr
Shared pointer to yk_var.
Definition yask_kernel_api.hpp:62
YASK_DEPRECATED typedef yk_var yk_grid
[Deprecated] Use yk_var.
Definition yask_kernel_api.hpp:299
YASK_DEPRECATED typedef yk_var_ptr yk_grid_ptr
[Deprecated] Use yk_var_ptr.
Definition yask_kernel_api.hpp:302
#define YASK_NORETURN
No-return attribute.
Definition yask_common_api.hpp:64
#define YASK_DEPRECATED
Deprecated attribute.
Definition yask_common_api.hpp:60