YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
interp_method.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifdef HAVE_CONFIG_H
6// Get the definition of the 'restrict' keyword.
7#include "config.h"
8#endif
9
13#include "instrument_internal.h"
14#include "yac_mpi_common.h"
15
17 struct interp_method ** method, struct yac_interp_grid * interp_grid) {
18
19 YAC_INSTRUMENT_START(YAC_INSTR_INTERP_SEARCH);
20
22 MPI_Comm interp_grid_comm = yac_interp_grid_get_MPI_Comm(interp_grid);
23 enum yac_location src_field_locations[num_src_fields];
24 for (size_t i = 0; i < num_src_fields; ++i)
25 src_field_locations[i] =
27 struct yac_interp_weights * weights =
29 interp_grid_comm, yac_interp_grid_get_tgt_field_location(interp_grid),
30 src_field_locations, num_src_fields);
31
32 // (no early return here; the instrumented region has to be closed
33 // unconditionally below)
34 if (*method != NULL) {
35
36 size_t temp_count;
37 size_t * tgt_points;
38 yac_interp_grid_get_tgt_points(interp_grid, &tgt_points, &temp_count);
39
40 size_t final_count = 0;
41 int interpolation_complete = 0;
42 while (*method != NULL) {
43 final_count +=
44 (*method)->vtable->do_search(
45 *method, interp_grid, tgt_points + final_count,
46 temp_count - final_count, weights, &interpolation_complete);
48 MPI_Allreduce(
49 MPI_IN_PLACE, &interpolation_complete, 1, MPI_INT,
50 MPI_MAX, interp_grid_comm), interp_grid_comm);
51 ++method;
52 }
53
54 free(tgt_points);
55 }
56
57 YAC_INSTRUMENT_STOP(YAC_INSTR_INTERP_SEARCH);
58
59 return weights;
60}
61
63
64 while (*method != NULL) {
65 struct interp_method * curr_method = *method;
66 curr_method->vtable->delete(curr_method);
67 ++method;
68 }
69}
70
#define YAC_INSTRUMENT_START(ID)
Enter an instrumented region.
#define YAC_INSTRUMENT_STOP(ID)
Exit an instrumented region entered with YAC_INSTRUMENT_START(ID).
enum yac_location yac_interp_grid_get_tgt_field_location(struct yac_interp_grid *interp_grid)
size_t yac_interp_grid_get_num_src_fields(struct yac_interp_grid *interp_grid)
void yac_interp_grid_get_tgt_points(struct yac_interp_grid *interp_grid, size_t **tgt_indices, size_t *count)
Definition interp_grid.c:99
MPI_Comm yac_interp_grid_get_MPI_Comm(struct yac_interp_grid *interp_grid)
enum yac_location yac_interp_grid_get_src_field_location(struct yac_interp_grid *interp_grid, size_t src_field_idx)
void yac_interp_method_cleanup()
Free static internal resources of all interpolation methods.
void yac_interp_method_delete(struct interp_method **method)
Delete an interpolation stack and free its resources (but not the pointer array).
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
Perform weight computation using given interpolation stack and grid.
void yac_interp_method_callback_buf_free()
void yac_interp_method_check_buf_free()
struct yac_interp_weights * yac_interp_weights_new(MPI_Comm comm, enum yac_location tgt_location, enum yac_location *src_locations, size_t num_src_fields)
yac_location
Definition location.h:12
void(* delete)(struct interp_method *method)
struct interp_method_vtable * vtable
#define yac_mpi_call(call, comm)