ceed-operator.c (5d1e906964b04cb5161d672bdc4191311737c811) ceed-operator.c (edb2538e3dd6743c029967fc4e89c6fcafedb8c2)
1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3//
4// SPDX-License-Identifier: BSD-2-Clause
5//
6// This file is part of CEED: http://github.com/ceed
7
8#include <ceed-impl.h>

--- 20 unchanged lines hidden (view full) ---

29 @param[in] r Operator Field ElemRestriction
30 @param[in] b Operator Field Basis
31
32 @return An error code: 0 - success, otherwise - failure
33
34 @ref Developer
35**/
36static int CeedOperatorCheckField(Ceed ceed, CeedQFunctionField qf_field, CeedElemRestriction r, CeedBasis b) {
1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3//
4// SPDX-License-Identifier: BSD-2-Clause
5//
6// This file is part of CEED: http://github.com/ceed
7
8#include <ceed-impl.h>

--- 20 unchanged lines hidden (view full) ---

29 @param[in] r Operator Field ElemRestriction
30 @param[in] b Operator Field Basis
31
32 @return An error code: 0 - success, otherwise - failure
33
34 @ref Developer
35**/
36static int CeedOperatorCheckField(Ceed ceed, CeedQFunctionField qf_field, CeedElemRestriction r, CeedBasis b) {
37 CeedInt dim = 1, num_comp = 1, q_comp = 1, restr_num_comp = 1, size = qf_field->size;
37 CeedInt dim = 1, num_comp = 1, q_comp = 1, rstr_num_comp = 1, size = qf_field->size;
38 CeedEvalMode eval_mode = qf_field->eval_mode;
39
40 // Restriction
41 CeedCheck((r == CEED_ELEMRESTRICTION_NONE) == (eval_mode == CEED_EVAL_WEIGHT), ceed, CEED_ERROR_INCOMPATIBLE,
42 "CEED_ELEMRESTRICTION_NONE and CEED_EVAL_WEIGHT must be used together.");
43 if (r != CEED_ELEMRESTRICTION_NONE) {
38 CeedEvalMode eval_mode = qf_field->eval_mode;
39
40 // Restriction
41 CeedCheck((r == CEED_ELEMRESTRICTION_NONE) == (eval_mode == CEED_EVAL_WEIGHT), ceed, CEED_ERROR_INCOMPATIBLE,
42 "CEED_ELEMRESTRICTION_NONE and CEED_EVAL_WEIGHT must be used together.");
43 if (r != CEED_ELEMRESTRICTION_NONE) {
44 CeedCall(CeedElemRestrictionGetNumComponents(r, &restr_num_comp));
44 CeedCall(CeedElemRestrictionGetNumComponents(r, &rstr_num_comp));
45 }
46 // Basis
47 CeedCheck((b == CEED_BASIS_NONE) == (eval_mode == CEED_EVAL_NONE), ceed, CEED_ERROR_INCOMPATIBLE,
48 "CEED_BASIS_NONE and CEED_EVAL_NONE must be used together.");
49 if (b != CEED_BASIS_NONE) {
50 CeedCall(CeedBasisGetDimension(b, &dim));
51 CeedCall(CeedBasisGetNumComponents(b, &num_comp));
52 CeedCall(CeedBasisGetNumQuadratureComponents(b, eval_mode, &q_comp));
45 }
46 // Basis
47 CeedCheck((b == CEED_BASIS_NONE) == (eval_mode == CEED_EVAL_NONE), ceed, CEED_ERROR_INCOMPATIBLE,
48 "CEED_BASIS_NONE and CEED_EVAL_NONE must be used together.");
49 if (b != CEED_BASIS_NONE) {
50 CeedCall(CeedBasisGetDimension(b, &dim));
51 CeedCall(CeedBasisGetNumComponents(b, &num_comp));
52 CeedCall(CeedBasisGetNumQuadratureComponents(b, eval_mode, &q_comp));
53 CeedCheck(r == CEED_ELEMRESTRICTION_NONE || restr_num_comp == num_comp, ceed, CEED_ERROR_DIMENSION,
53 CeedCheck(r == CEED_ELEMRESTRICTION_NONE || rstr_num_comp == num_comp, ceed, CEED_ERROR_DIMENSION,
54 "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction has %" CeedInt_FMT " components, but Basis has %" CeedInt_FMT
55 " components",
54 "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction has %" CeedInt_FMT " components, but Basis has %" CeedInt_FMT
55 " components",
56 qf_field->field_name, qf_field->size, CeedEvalModes[qf_field->eval_mode], restr_num_comp, num_comp);
56 qf_field->field_name, qf_field->size, CeedEvalModes[qf_field->eval_mode], rstr_num_comp, num_comp);
57 }
58 // Field size
59 switch (eval_mode) {
60 case CEED_EVAL_NONE:
57 }
58 // Field size
59 switch (eval_mode) {
60 case CEED_EVAL_NONE:
61 CeedCheck(size == restr_num_comp, ceed, CEED_ERROR_DIMENSION,
61 CeedCheck(size == rstr_num_comp, ceed, CEED_ERROR_DIMENSION,
62 "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction has %" CeedInt_FMT " components", qf_field->field_name,
62 "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction has %" CeedInt_FMT " components", qf_field->field_name,
63 qf_field->size, CeedEvalModes[qf_field->eval_mode], restr_num_comp);
63 qf_field->size, CeedEvalModes[qf_field->eval_mode], rstr_num_comp);
64 break;
65 case CEED_EVAL_INTERP:
66 case CEED_EVAL_GRAD:
67 case CEED_EVAL_DIV:
68 case CEED_EVAL_CURL:
69 CeedCheck(size == num_comp * q_comp, ceed, CEED_ERROR_DIMENSION,
70 "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction/Basis has %" CeedInt_FMT " components", qf_field->field_name,
71 qf_field->size, CeedEvalModes[qf_field->eval_mode], num_comp * q_comp);

--- 1115 unchanged lines hidden (view full) ---

1187 CeedOperatorField *input_fields, *output_fields;
1188
1189 CeedCall(CeedOperatorGetFields(op, &num_input_fields, &input_fields, &num_output_fields, &output_fields));
1190 CeedCall(CeedOperatorGetNumElements(op, &num_elem));
1191
1192 // Input FLOPs
1193 for (CeedInt i = 0; i < num_input_fields; i++) {
1194 if (input_fields[i]->vec == CEED_VECTOR_ACTIVE) {
64 break;
65 case CEED_EVAL_INTERP:
66 case CEED_EVAL_GRAD:
67 case CEED_EVAL_DIV:
68 case CEED_EVAL_CURL:
69 CeedCheck(size == num_comp * q_comp, ceed, CEED_ERROR_DIMENSION,
70 "Field '%s' of size %" CeedInt_FMT " and EvalMode %s: ElemRestriction/Basis has %" CeedInt_FMT " components", qf_field->field_name,
71 qf_field->size, CeedEvalModes[qf_field->eval_mode], num_comp * q_comp);

--- 1115 unchanged lines hidden (view full) ---

1187 CeedOperatorField *input_fields, *output_fields;
1188
1189 CeedCall(CeedOperatorGetFields(op, &num_input_fields, &input_fields, &num_output_fields, &output_fields));
1190 CeedCall(CeedOperatorGetNumElements(op, &num_elem));
1191
1192 // Input FLOPs
1193 for (CeedInt i = 0; i < num_input_fields; i++) {
1194 if (input_fields[i]->vec == CEED_VECTOR_ACTIVE) {
1195 CeedSize restr_flops, basis_flops;
1195 CeedSize rstr_flops, basis_flops;
1196
1196
1197 CeedCall(CeedElemRestrictionGetFlopsEstimate(input_fields[i]->elem_rstr, CEED_NOTRANSPOSE, &restr_flops));
1198 *flops += restr_flops;
1197 CeedCall(CeedElemRestrictionGetFlopsEstimate(input_fields[i]->elem_rstr, CEED_NOTRANSPOSE, &rstr_flops));
1198 *flops += rstr_flops;
1199 CeedCall(CeedBasisGetFlopsEstimate(input_fields[i]->basis, CEED_NOTRANSPOSE, op->qf->input_fields[i]->eval_mode, &basis_flops));
1200 *flops += basis_flops * num_elem;
1201 }
1202 }
1203 // QF FLOPs
1204 {
1205 CeedInt num_qpts;
1206 CeedSize qf_flops;
1207
1208 CeedCall(CeedOperatorGetNumQuadraturePoints(op, &num_qpts));
1209 CeedCall(CeedQFunctionGetFlopsEstimate(op->qf, &qf_flops));
1210 *flops += num_elem * num_qpts * qf_flops;
1211 }
1212
1213 // Output FLOPs
1214 for (CeedInt i = 0; i < num_output_fields; i++) {
1215 if (output_fields[i]->vec == CEED_VECTOR_ACTIVE) {
1199 CeedCall(CeedBasisGetFlopsEstimate(input_fields[i]->basis, CEED_NOTRANSPOSE, op->qf->input_fields[i]->eval_mode, &basis_flops));
1200 *flops += basis_flops * num_elem;
1201 }
1202 }
1203 // QF FLOPs
1204 {
1205 CeedInt num_qpts;
1206 CeedSize qf_flops;
1207
1208 CeedCall(CeedOperatorGetNumQuadraturePoints(op, &num_qpts));
1209 CeedCall(CeedQFunctionGetFlopsEstimate(op->qf, &qf_flops));
1210 *flops += num_elem * num_qpts * qf_flops;
1211 }
1212
1213 // Output FLOPs
1214 for (CeedInt i = 0; i < num_output_fields; i++) {
1215 if (output_fields[i]->vec == CEED_VECTOR_ACTIVE) {
1216 CeedSize restr_flops, basis_flops;
1216 CeedSize rstr_flops, basis_flops;
1217
1217
1218 CeedCall(CeedElemRestrictionGetFlopsEstimate(output_fields[i]->elem_rstr, CEED_TRANSPOSE, &restr_flops));
1219 *flops += restr_flops;
1218 CeedCall(CeedElemRestrictionGetFlopsEstimate(output_fields[i]->elem_rstr, CEED_TRANSPOSE, &rstr_flops));
1219 *flops += rstr_flops;
1220 CeedCall(CeedBasisGetFlopsEstimate(output_fields[i]->basis, CEED_TRANSPOSE, op->qf->output_fields[i]->eval_mode, &basis_flops));
1221 *flops += basis_flops * num_elem;
1222 }
1223 }
1224 }
1225 return CEED_ERROR_SUCCESS;
1226}
1227

--- 416 unchanged lines hidden ---
1220 CeedCall(CeedBasisGetFlopsEstimate(output_fields[i]->basis, CEED_TRANSPOSE, op->qf->output_fields[i]->eval_mode, &basis_flops));
1221 *flops += basis_flops * num_elem;
1222 }
1223 }
1224 }
1225 return CEED_ERROR_SUCCESS;
1226}
1227

--- 416 unchanged lines hidden ---