13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 321617c04Sjeremylt // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 521617c04Sjeremylt // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 721617c04Sjeremylt 849aac155SJeremy L Thompson #include <ceed.h> 9ec3da8bcSJed Brown #include <ceed/backend.h> 103d576824SJeremy L Thompson #include <stdbool.h> 11fcbe8c06SSebastian Grimberg #include <stdlib.h> 123d576824SJeremy L Thompson #include <string.h> 132b730f8bSJeremy L Thompson 1421617c04Sjeremylt #include "ceed-ref.h" 1521617c04Sjeremylt 16f10650afSjeremylt //------------------------------------------------------------------------------ 17f10650afSjeremylt // Core ElemRestriction Apply Code 18f10650afSjeremylt //------------------------------------------------------------------------------ 19*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyStridedNoTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 2094648b7dSSebastian Grimberg CeedInt start, CeedInt stop, CeedInt num_elem, CeedInt elem_size, 2194648b7dSSebastian Grimberg CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 2294648b7dSSebastian Grimberg // No offsets provided, identity restriction 23d1d35e2fSjeremylt bool has_backend_strides; 24ad70ee2cSJeremy L Thompson 25*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionHasBackendStrides(rstr, &has_backend_strides)); 26d1d35e2fSjeremylt if (has_backend_strides) { 27d1d35e2fSjeremylt // CPU backend strides are {1, elem_size, elem_size*num_comp} 287f90ec76Sjeremylt // This if branch is left separate to allow better inlining 29ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 302b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 312b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt n = 0; n < elem_size; n++) { 32ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 33ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 342b730f8bSJeremy L Thompson uu[n + k * elem_size + CeedIntMin(e + j, num_elem - 1) * elem_size * num_comp]; 352b730f8bSJeremy L Thompson } 362b730f8bSJeremy L Thompson } 372b730f8bSJeremy L Thompson } 382b730f8bSJeremy L Thompson } 397f90ec76Sjeremylt } else { 407f90ec76Sjeremylt // User provided strides 417f90ec76Sjeremylt CeedInt strides[3]; 42ad70ee2cSJeremy L Thompson 43*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetStrides(rstr, &strides)); 44ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 452b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 462b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt n = 0; n < elem_size; n++) { 47ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 48ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 492b730f8bSJeremy L Thompson uu[n * strides[0] + k * strides[1] + CeedIntMin(e + j, num_elem - 1) * strides[2]]; 502b730f8bSJeremy L Thompson } 512b730f8bSJeremy L Thompson } 522b730f8bSJeremy L Thompson } 532b730f8bSJeremy L Thompson } 547509a596Sjeremylt } 5594648b7dSSebastian Grimberg return CEED_ERROR_SUCCESS; 5694648b7dSSebastian Grimberg } 5794648b7dSSebastian Grimberg 58*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyStandardNoTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 5994648b7dSSebastian Grimberg const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedInt num_elem, 6094648b7dSSebastian Grimberg CeedInt elem_size, CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 61fcbe8c06SSebastian Grimberg // Default restriction with offsets 6294648b7dSSebastian Grimberg CeedElemRestriction_Ref *impl; 63ad70ee2cSJeremy L Thompson 64*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 65ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 662b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 67ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < elem_size * block_size; i++) { 68ad70ee2cSJeremy L Thompson vv[elem_size * (k * block_size + e * num_comp) + i - v_offset] = uu[impl->offsets[i + e * elem_size] + k * comp_stride]; 69fcbe8c06SSebastian Grimberg } 70fcbe8c06SSebastian Grimberg } 71fcbe8c06SSebastian Grimberg } 7294648b7dSSebastian Grimberg return CEED_ERROR_SUCCESS; 7394648b7dSSebastian Grimberg } 7494648b7dSSebastian Grimberg 75*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyOrientedNoTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 7694648b7dSSebastian Grimberg const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedInt num_elem, 7794648b7dSSebastian Grimberg CeedInt elem_size, CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 78fcbe8c06SSebastian Grimberg // Restriction with orientations 7994648b7dSSebastian Grimberg CeedElemRestriction_Ref *impl; 80ad70ee2cSJeremy L Thompson 81*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 82ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 83fcbe8c06SSebastian Grimberg CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 84ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < elem_size * block_size; i++) { 85ad70ee2cSJeremy L Thompson vv[elem_size * (k * block_size + e * num_comp) + i - v_offset] = 867c1dbaffSSebastian Grimberg uu[impl->offsets[i + e * elem_size] + k * comp_stride] * (impl->orients[i + e * elem_size] ? -1.0 : 1.0); 87fcbe8c06SSebastian Grimberg } 88fcbe8c06SSebastian Grimberg } 89fcbe8c06SSebastian Grimberg } 9094648b7dSSebastian Grimberg return CEED_ERROR_SUCCESS; 9194648b7dSSebastian Grimberg } 9294648b7dSSebastian Grimberg 93*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyCurlOrientedNoTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 9494648b7dSSebastian Grimberg const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedInt num_elem, 9594648b7dSSebastian Grimberg CeedInt elem_size, CeedInt v_offset, const CeedScalar *uu, 9694648b7dSSebastian Grimberg CeedScalar *vv) { 9777d1c127SSebastian Grimberg // Restriction with tridiagonal transformation 9894648b7dSSebastian Grimberg CeedElemRestriction_Ref *impl; 99ad70ee2cSJeremy L Thompson 100*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 101ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 102fcbe8c06SSebastian Grimberg CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 1030c73c039SSebastian Grimberg CeedInt n = 0; 104ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 105ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 106ad70ee2cSJeremy L Thompson uu[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] * 107ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size] + 108ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n + 1) * block_size + e * elem_size] + k * comp_stride] * 109ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 2) * block_size + e * 3 * elem_size]; 1100c73c039SSebastian Grimberg } 1110c73c039SSebastian Grimberg for (n = 1; n < elem_size - 1; n++) { 112ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 113ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 114ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n - 1) * block_size + e * elem_size] + k * comp_stride] * 115ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 0) * block_size + e * 3 * elem_size] + 116ad70ee2cSJeremy L Thompson uu[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] * 117ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size] + 118ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n + 1) * block_size + e * elem_size] + k * comp_stride] * 119ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 2) * block_size + e * 3 * elem_size]; 1200c73c039SSebastian Grimberg } 1210c73c039SSebastian Grimberg } 122ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 123ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 124ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n - 1) * block_size + e * elem_size] + k * comp_stride] * 125ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 0) * block_size + e * 3 * elem_size] + 126ad70ee2cSJeremy L Thompson uu[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] * 127ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]; 1282b730f8bSJeremy L Thompson } 1292b730f8bSJeremy L Thompson } 1302b730f8bSJeremy L Thompson } 1310c73c039SSebastian Grimberg return CEED_ERROR_SUCCESS; 132fcbe8c06SSebastian Grimberg } 1330c73c039SSebastian Grimberg 134*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyCurlOrientedUnsignedNoTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, 135ad70ee2cSJeremy L Thompson const CeedInt block_size, const CeedInt comp_stride, CeedInt start, 13694648b7dSSebastian Grimberg CeedInt stop, CeedInt num_elem, CeedInt elem_size, 13794648b7dSSebastian Grimberg CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 13894648b7dSSebastian Grimberg // Restriction with (unsigned) tridiagonal transformation 1390c73c039SSebastian Grimberg CeedElemRestriction_Ref *impl; 140ad70ee2cSJeremy L Thompson 141*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 142ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 1437c1dbaffSSebastian Grimberg CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 1447c1dbaffSSebastian Grimberg CeedInt n = 0; 145ad70ee2cSJeremy L Thompson 146ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 147ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 148ad70ee2cSJeremy L Thompson uu[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] * 149ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]) + 150ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n + 1) * block_size + e * elem_size] + k * comp_stride] * 151ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 2) * block_size + e * 3 * elem_size]); 1527c1dbaffSSebastian Grimberg } 1537c1dbaffSSebastian Grimberg for (n = 1; n < elem_size - 1; n++) { 154ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 155ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 156ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n - 1) * block_size + e * elem_size] + k * comp_stride] * 157ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 0) * block_size + e * 3 * elem_size]) + 158ad70ee2cSJeremy L Thompson uu[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] * 159ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]) + 160ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n + 1) * block_size + e * elem_size] + k * comp_stride] * 161ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 2) * block_size + e * 3 * elem_size]); 1627c1dbaffSSebastian Grimberg } 1637c1dbaffSSebastian Grimberg } 164ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < block_size; j++) { 165ad70ee2cSJeremy L Thompson vv[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] = 166ad70ee2cSJeremy L Thompson uu[impl->offsets[j + (n - 1) * block_size + e * elem_size] + k * comp_stride] * 167ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 0) * block_size + e * 3 * elem_size]) + 168ad70ee2cSJeremy L Thompson uu[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] * 169ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]); 1707c1dbaffSSebastian Grimberg } 1717c1dbaffSSebastian Grimberg } 1727c1dbaffSSebastian Grimberg } 1737c1dbaffSSebastian Grimberg return CEED_ERROR_SUCCESS; 1747c1dbaffSSebastian Grimberg } 1757c1dbaffSSebastian Grimberg 176*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyStridedTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 17794648b7dSSebastian Grimberg CeedInt start, CeedInt stop, CeedInt num_elem, CeedInt elem_size, 17894648b7dSSebastian Grimberg CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 17994648b7dSSebastian Grimberg // No offsets provided, identity restriction 180d1d35e2fSjeremylt bool has_backend_strides; 181ad70ee2cSJeremy L Thompson 182*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionHasBackendStrides(rstr, &has_backend_strides)); 183d1d35e2fSjeremylt if (has_backend_strides) { 184d1d35e2fSjeremylt // CPU backend strides are {1, elem_size, elem_size*num_comp} 1857f90ec76Sjeremylt // This if brach is left separate to allow better inlining 186ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 1872b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 1882b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt n = 0; n < elem_size; n++) { 189ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < CeedIntMin(block_size, num_elem - e); j++) { 190ad70ee2cSJeremy L Thompson vv[n + k * elem_size + (e + j) * elem_size * num_comp] += uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset]; 1912b730f8bSJeremy L Thompson } 1922b730f8bSJeremy L Thompson } 1932b730f8bSJeremy L Thompson } 1942b730f8bSJeremy L Thompson } 1957f90ec76Sjeremylt } else { 1967f90ec76Sjeremylt // User provided strides 1977f90ec76Sjeremylt CeedInt strides[3]; 198ad70ee2cSJeremy L Thompson 199*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetStrides(rstr, &strides)); 200ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 2012b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt k = 0; k < num_comp; k++) { 2022b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt n = 0; n < elem_size; n++) { 203ad70ee2cSJeremy L Thompson CeedPragmaSIMD for (CeedInt j = 0; j < CeedIntMin(block_size, num_elem - e); j++) { 2042b730f8bSJeremy L Thompson vv[n * strides[0] + k * strides[1] + (e + j) * strides[2]] += 205ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset]; 2062b730f8bSJeremy L Thompson } 2072b730f8bSJeremy L Thompson } 2082b730f8bSJeremy L Thompson } 2092b730f8bSJeremy L Thompson } 210523b8ea0Sjeremylt } 21194648b7dSSebastian Grimberg return CEED_ERROR_SUCCESS; 21294648b7dSSebastian Grimberg } 21394648b7dSSebastian Grimberg 214*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyStandardTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 21594648b7dSSebastian Grimberg const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedInt num_elem, 21694648b7dSSebastian Grimberg CeedInt elem_size, CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 217fcbe8c06SSebastian Grimberg // Default restriction with offsets 21894648b7dSSebastian Grimberg CeedElemRestriction_Ref *impl; 219ad70ee2cSJeremy L Thompson 220*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 221ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 2222b730f8bSJeremy L Thompson for (CeedInt k = 0; k < num_comp; k++) { 223ad70ee2cSJeremy L Thompson for (CeedInt i = 0; i < elem_size * block_size; i += block_size) { 2248d94b059Sjeremylt // Iteration bound set to discard padding elements 225ad70ee2cSJeremy L Thompson for (CeedInt j = i; j < i + CeedIntMin(block_size, num_elem - e); j++) { 226ad70ee2cSJeremy L Thompson vv[impl->offsets[j + e * elem_size] + k * comp_stride] += uu[elem_size * (k * block_size + e * num_comp) + j - v_offset]; 227fcbe8c06SSebastian Grimberg } 228fcbe8c06SSebastian Grimberg } 229fcbe8c06SSebastian Grimberg } 230fcbe8c06SSebastian Grimberg } 23194648b7dSSebastian Grimberg return CEED_ERROR_SUCCESS; 23294648b7dSSebastian Grimberg } 23394648b7dSSebastian Grimberg 234*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyOrientedTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 23594648b7dSSebastian Grimberg const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedInt num_elem, 23694648b7dSSebastian Grimberg CeedInt elem_size, CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 237fcbe8c06SSebastian Grimberg // Restriction with orientations 23894648b7dSSebastian Grimberg CeedElemRestriction_Ref *impl; 239ad70ee2cSJeremy L Thompson 240*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 241ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 242fcbe8c06SSebastian Grimberg for (CeedInt k = 0; k < num_comp; k++) { 243ad70ee2cSJeremy L Thompson for (CeedInt i = 0; i < elem_size * block_size; i += block_size) { 244fcbe8c06SSebastian Grimberg // Iteration bound set to discard padding elements 245ad70ee2cSJeremy L Thompson for (CeedInt j = i; j < i + CeedIntMin(block_size, num_elem - e); j++) { 246f30b1135SSebastian Grimberg vv[impl->offsets[j + e * elem_size] + k * comp_stride] += 247ad70ee2cSJeremy L Thompson uu[elem_size * (k * block_size + e * num_comp) + j - v_offset] * (impl->orients[j + e * elem_size] ? -1.0 : 1.0); 248fcbe8c06SSebastian Grimberg } 249fcbe8c06SSebastian Grimberg } 250fcbe8c06SSebastian Grimberg } 251fcbe8c06SSebastian Grimberg } 25294648b7dSSebastian Grimberg return CEED_ERROR_SUCCESS; 25394648b7dSSebastian Grimberg } 25494648b7dSSebastian Grimberg 255*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyCurlOrientedTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 25694648b7dSSebastian Grimberg const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedInt num_elem, 25794648b7dSSebastian Grimberg CeedInt elem_size, CeedInt v_offset, const CeedScalar *uu, CeedScalar *vv) { 25877d1c127SSebastian Grimberg // Restriction with tridiagonal transformation 25994648b7dSSebastian Grimberg CeedElemRestriction_Ref *impl; 260ad70ee2cSJeremy L Thompson 261*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 262ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 263fcbe8c06SSebastian Grimberg for (CeedInt k = 0; k < num_comp; k++) { 264fcbe8c06SSebastian Grimberg // Iteration bound set to discard padding elements 265ad70ee2cSJeremy L Thompson CeedInt block_end = CeedIntMin(block_size, num_elem - e), n = 0; 266ad70ee2cSJeremy L Thompson for (CeedInt j = 0; j < block_end; j++) { 267ad70ee2cSJeremy L Thompson vv[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] += 268ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] * 269ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size] + 270ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n + 1) * block_size + j - v_offset] * 271ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 3) * block_size + e * 3 * elem_size]; 2720c73c039SSebastian Grimberg } 2730c73c039SSebastian Grimberg for (n = 1; n < elem_size - 1; n++) { 274ad70ee2cSJeremy L Thompson for (CeedInt j = 0; j < block_end; j++) { 275ad70ee2cSJeremy L Thompson vv[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] += 276ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n - 1) * block_size + j - v_offset] * 277ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n - 1) * block_size + e * 3 * elem_size] + 278ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] * 279ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size] + 280ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n + 1) * block_size + j - v_offset] * 281ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 3) * block_size + e * 3 * elem_size]; 2820c73c039SSebastian Grimberg } 2830c73c039SSebastian Grimberg } 284ad70ee2cSJeremy L Thompson for (CeedInt j = 0; j < block_end; j++) { 285ad70ee2cSJeremy L Thompson vv[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] += 286ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n - 1) * block_size + j - v_offset] * 287ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n - 1) * block_size + e * 3 * elem_size] + 288ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] * 289ad70ee2cSJeremy L Thompson impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]; 29021617c04Sjeremylt } 291b435c5a6Srezgarshakeri } 2922b730f8bSJeremy L Thompson } 293e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 29421617c04Sjeremylt } 29521617c04Sjeremylt 296*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApplyCurlOrientedUnsignedTranspose_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, 297ad70ee2cSJeremy L Thompson const CeedInt block_size, const CeedInt comp_stride, CeedInt start, 29894648b7dSSebastian Grimberg CeedInt stop, CeedInt num_elem, CeedInt elem_size, CeedInt v_offset, 29994648b7dSSebastian Grimberg const CeedScalar *uu, CeedScalar *vv) { 30094648b7dSSebastian Grimberg // Restriction with (unsigned) tridiagonal transformation 3017c1dbaffSSebastian Grimberg CeedElemRestriction_Ref *impl; 302ad70ee2cSJeremy L Thompson 303*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 304ad70ee2cSJeremy L Thompson for (CeedInt e = start * block_size; e < stop * block_size; e += block_size) { 3057c1dbaffSSebastian Grimberg for (CeedInt k = 0; k < num_comp; k++) { 3067c1dbaffSSebastian Grimberg // Iteration bound set to discard padding elements 307ad70ee2cSJeremy L Thompson CeedInt n = 0; 308ad70ee2cSJeremy L Thompson const CeedInt block_end = CeedIntMin(block_size, num_elem - e); 309ad70ee2cSJeremy L Thompson 310ad70ee2cSJeremy L Thompson for (CeedInt j = 0; j < block_end; j++) { 311ad70ee2cSJeremy L Thompson vv[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] += 312ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] * 313ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]) + 314ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n + 1) * block_size + j - v_offset] * 315ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 3) * block_size + e * 3 * elem_size]); 3167c1dbaffSSebastian Grimberg } 3177c1dbaffSSebastian Grimberg for (n = 1; n < elem_size - 1; n++) { 318ad70ee2cSJeremy L Thompson for (CeedInt j = 0; j < block_end; j++) { 319ad70ee2cSJeremy L Thompson vv[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] += 320ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n - 1) * block_size + j - v_offset] * 321ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n - 1) * block_size + e * 3 * elem_size]) + 322ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] * 323ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]) + 324ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n + 1) * block_size + j - v_offset] * 325ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 3) * block_size + e * 3 * elem_size]); 3267c1dbaffSSebastian Grimberg } 3277c1dbaffSSebastian Grimberg } 328ad70ee2cSJeremy L Thompson for (CeedInt j = 0; j < block_end; j++) { 329ad70ee2cSJeremy L Thompson vv[impl->offsets[j + n * block_size + e * elem_size] + k * comp_stride] += 330ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n - 1) * block_size + j - v_offset] * 331ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n - 1) * block_size + e * 3 * elem_size]) + 332ad70ee2cSJeremy L Thompson uu[e * elem_size * num_comp + (k * elem_size + n) * block_size + j - v_offset] * 333ad70ee2cSJeremy L Thompson abs(impl->curl_orients[j + (3 * n + 1) * block_size + e * 3 * elem_size]); 3347c1dbaffSSebastian Grimberg } 3357c1dbaffSSebastian Grimberg } 3367c1dbaffSSebastian Grimberg } 3377c1dbaffSSebastian Grimberg return CEED_ERROR_SUCCESS; 3387c1dbaffSSebastian Grimberg } 3397c1dbaffSSebastian Grimberg 340*1cc2c60dSJeremy L Thompson static inline int CeedElemRestrictionApply_Ref_Core(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, 341ad70ee2cSJeremy L Thompson const CeedInt comp_stride, CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, 342ad70ee2cSJeremy L Thompson bool use_orients, CeedVector u, CeedVector v, CeedRequest *request) { 343ad70ee2cSJeremy L Thompson CeedInt num_elem, elem_size, v_offset; 344ad70ee2cSJeremy L Thompson CeedRestrictionType rstr_type; 3457c1dbaffSSebastian Grimberg const CeedScalar *uu; 3467c1dbaffSSebastian Grimberg CeedScalar *vv; 347ad70ee2cSJeremy L Thompson 348*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumElements(rstr, &num_elem)); 349*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetElementSize(rstr, &elem_size)); 350ad70ee2cSJeremy L Thompson v_offset = start * block_size * elem_size * num_comp; 351*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetType(rstr, &rstr_type)); 35294648b7dSSebastian Grimberg CeedCallBackend(CeedVectorGetArrayRead(u, CEED_MEM_HOST, &uu)); 353ad70ee2cSJeremy L Thompson 35494648b7dSSebastian Grimberg if (t_mode == CEED_TRANSPOSE) { 35594648b7dSSebastian Grimberg // Sum into for transpose mode, E-vector to L-vector 35694648b7dSSebastian Grimberg CeedCallBackend(CeedVectorGetArray(v, CEED_MEM_HOST, &vv)); 35794648b7dSSebastian Grimberg } else { 35894648b7dSSebastian Grimberg // Overwrite for notranspose mode, L-vector to E-vector 35994648b7dSSebastian Grimberg CeedCallBackend(CeedVectorGetArrayWrite(v, CEED_MEM_HOST, &vv)); 36094648b7dSSebastian Grimberg } 36194648b7dSSebastian Grimberg if (t_mode == CEED_TRANSPOSE) { 3627c1dbaffSSebastian Grimberg // Restriction from E-vector to L-vector 3637c1dbaffSSebastian Grimberg // Performing v += r^T * u 3647c1dbaffSSebastian Grimberg // uu has shape [elem_size, num_comp, num_elem], row-major 3657c1dbaffSSebastian Grimberg // vv has shape [nnodes, num_comp] 3667c1dbaffSSebastian Grimberg // Sum into for transpose mode 3677c1dbaffSSebastian Grimberg switch (rstr_type) { 3687c1dbaffSSebastian Grimberg case CEED_RESTRICTION_STRIDED: 3695d10938bSJeremy L Thompson CeedCallBackend( 370*1cc2c60dSJeremy L Thompson CeedElemRestrictionApplyStridedTranspose_Ref_Core(rstr, num_comp, block_size, start, stop, num_elem, elem_size, v_offset, uu, vv)); 37194648b7dSSebastian Grimberg break; 37261a27d74SSebastian Grimberg case CEED_RESTRICTION_STANDARD: 373*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyStandardTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, elem_size, 3745d10938bSJeremy L Thompson v_offset, uu, vv)); 37594648b7dSSebastian Grimberg break; 3767c1dbaffSSebastian Grimberg case CEED_RESTRICTION_ORIENTED: 37794648b7dSSebastian Grimberg if (use_signs) { 378*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyOrientedTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 379*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 38094648b7dSSebastian Grimberg } else { 381*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyStandardTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 382*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 38394648b7dSSebastian Grimberg } 38494648b7dSSebastian Grimberg break; 38594648b7dSSebastian Grimberg case CEED_RESTRICTION_CURL_ORIENTED: 38694648b7dSSebastian Grimberg if (use_signs && use_orients) { 387*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyCurlOrientedTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 3885d10938bSJeremy L Thompson elem_size, v_offset, uu, vv)); 38994648b7dSSebastian Grimberg } else if (use_orients) { 390*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyCurlOrientedUnsignedTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, 391*1cc2c60dSJeremy L Thompson num_elem, elem_size, v_offset, uu, vv)); 39294648b7dSSebastian Grimberg } else { 393*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyStandardTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 394*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 39594648b7dSSebastian Grimberg } 39694648b7dSSebastian Grimberg break; 39794648b7dSSebastian Grimberg } 39894648b7dSSebastian Grimberg } else { 39994648b7dSSebastian Grimberg // Restriction from L-vector to E-vector 40094648b7dSSebastian Grimberg // Perform: v = r * u 40194648b7dSSebastian Grimberg // vv has shape [elem_size, num_comp, num_elem], row-major 40294648b7dSSebastian Grimberg // uu has shape [nnodes, num_comp] 40394648b7dSSebastian Grimberg // Overwrite for notranspose mode 40494648b7dSSebastian Grimberg switch (rstr_type) { 40594648b7dSSebastian Grimberg case CEED_RESTRICTION_STRIDED: 4065d10938bSJeremy L Thompson CeedCallBackend( 407*1cc2c60dSJeremy L Thompson CeedElemRestrictionApplyStridedNoTranspose_Ref_Core(rstr, num_comp, block_size, start, stop, num_elem, elem_size, v_offset, uu, vv)); 40894648b7dSSebastian Grimberg break; 40961a27d74SSebastian Grimberg case CEED_RESTRICTION_STANDARD: 410*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyStandardNoTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 411*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 41294648b7dSSebastian Grimberg break; 41394648b7dSSebastian Grimberg case CEED_RESTRICTION_ORIENTED: 41494648b7dSSebastian Grimberg if (use_signs) { 415*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyOrientedNoTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 416*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 41794648b7dSSebastian Grimberg } else { 418*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyStandardNoTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 419*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 42094648b7dSSebastian Grimberg } 42194648b7dSSebastian Grimberg break; 42294648b7dSSebastian Grimberg case CEED_RESTRICTION_CURL_ORIENTED: 42394648b7dSSebastian Grimberg if (use_signs && use_orients) { 424*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyCurlOrientedNoTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 4255d10938bSJeremy L Thompson elem_size, v_offset, uu, vv)); 42694648b7dSSebastian Grimberg } else if (use_orients) { 427*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyCurlOrientedUnsignedNoTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, 4285d10938bSJeremy L Thompson num_elem, elem_size, v_offset, uu, vv)); 42994648b7dSSebastian Grimberg } else { 430*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionApplyStandardNoTranspose_Ref_Core(rstr, num_comp, block_size, comp_stride, start, stop, num_elem, 431*1cc2c60dSJeremy L Thompson elem_size, v_offset, uu, vv)); 43294648b7dSSebastian Grimberg } 43394648b7dSSebastian Grimberg break; 43494648b7dSSebastian Grimberg } 4357c1dbaffSSebastian Grimberg } 4367c1dbaffSSebastian Grimberg CeedCallBackend(CeedVectorRestoreArrayRead(u, &uu)); 4377c1dbaffSSebastian Grimberg CeedCallBackend(CeedVectorRestoreArray(v, &vv)); 4387c1dbaffSSebastian Grimberg if (request != CEED_REQUEST_IMMEDIATE && request != CEED_REQUEST_ORDERED) *request = NULL; 4397c1dbaffSSebastian Grimberg return CEED_ERROR_SUCCESS; 4407c1dbaffSSebastian Grimberg } 4417c1dbaffSSebastian Grimberg 4427c1dbaffSSebastian Grimberg //------------------------------------------------------------------------------ 443f10650afSjeremylt // ElemRestriction Apply - Common Sizes 444f10650afSjeremylt //------------------------------------------------------------------------------ 445*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_110(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4467c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4477c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 448*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 1, 1, comp_stride, start, stop, t_mode, use_signs, use_orients, u, v, request); 449d979a051Sjeremylt } 450d979a051Sjeremylt 451*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_111(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4527c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4537c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 454*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 1, 1, 1, start, stop, t_mode, use_signs, use_orients, u, v, request); 4554d2a38eeSjeremylt } 4564d2a38eeSjeremylt 457*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_180(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4587c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4597c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 460*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 1, 8, comp_stride, start, stop, t_mode, use_signs, use_orients, u, v, request); 4619c36149bSjeremylt } 4629c36149bSjeremylt 463*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_181(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4647c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4657c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 466*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 1, 8, 1, start, stop, t_mode, use_signs, use_orients, u, v, request); 4679c36149bSjeremylt } 4689c36149bSjeremylt 469*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_310(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4707c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4717c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 472*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 3, 1, comp_stride, start, stop, t_mode, use_signs, use_orients, u, v, request); 473d979a051Sjeremylt } 474d979a051Sjeremylt 475*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_311(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4767c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4777c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 478*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 3, 1, 1, start, stop, t_mode, use_signs, use_orients, u, v, request); 479d979a051Sjeremylt } 480d979a051Sjeremylt 481*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_380(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4827c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4837c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 484*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 3, 8, comp_stride, start, stop, t_mode, use_signs, use_orients, u, v, request); 485d979a051Sjeremylt } 486d979a051Sjeremylt 487*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_381(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4887c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4897c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 490*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 3, 8, 1, start, stop, t_mode, use_signs, use_orients, u, v, request); 491d979a051Sjeremylt } 492d979a051Sjeremylt 493bf4d1581Sjeremylt // LCOV_EXCL_START 494*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_510(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 4957c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 4967c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 497*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 5, 1, comp_stride, start, stop, t_mode, use_signs, use_orients, u, v, request); 498d979a051Sjeremylt } 499bf4d1581Sjeremylt // LCOV_EXCL_STOP 500d979a051Sjeremylt 501*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_511(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 5027c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 5037c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 504*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 5, 1, 1, start, stop, t_mode, use_signs, use_orients, u, v, request); 505d979a051Sjeremylt } 506d979a051Sjeremylt 507bf4d1581Sjeremylt // LCOV_EXCL_START 508*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_580(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 5097c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 5107c1dbaffSSebastian Grimberg CeedVector v, CeedRequest *request) { 511*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 5, 8, comp_stride, start, stop, t_mode, use_signs, use_orients, u, v, request); 512d979a051Sjeremylt } 513bf4d1581Sjeremylt // LCOV_EXCL_STOP 514d979a051Sjeremylt 515*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref_581(CeedElemRestriction rstr, const CeedInt num_comp, const CeedInt block_size, const CeedInt comp_stride, 5167c1dbaffSSebastian Grimberg CeedInt start, CeedInt stop, CeedTransposeMode t_mode, bool use_signs, bool use_orients, CeedVector u, 5170c73c039SSebastian Grimberg CeedVector v, CeedRequest *request) { 518*1cc2c60dSJeremy L Thompson return CeedElemRestrictionApply_Ref_Core(rstr, 5, 8, 1, start, stop, t_mode, use_signs, use_orients, u, v, request); 5194d2a38eeSjeremylt } 5204d2a38eeSjeremylt 521f10650afSjeremylt //------------------------------------------------------------------------------ 522f10650afSjeremylt // ElemRestriction Apply 523f10650afSjeremylt //------------------------------------------------------------------------------ 524*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApply_Ref(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector v, CeedRequest *request) { 525ad70ee2cSJeremy L Thompson CeedInt num_block, block_size, num_comp, comp_stride; 526ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 527ad70ee2cSJeremy L Thompson 528*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumBlocks(rstr, &num_block)); 529*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetBlockSize(rstr, &block_size)); 530*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumComponents(rstr, &num_comp)); 531*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCompStride(rstr, &comp_stride)); 532*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 533*1cc2c60dSJeremy L Thompson CeedCallBackend(impl->Apply(rstr, num_comp, block_size, comp_stride, 0, num_block, t_mode, true, true, u, v, request)); 5345d10938bSJeremy L Thompson return CEED_ERROR_SUCCESS; 535f30b1135SSebastian Grimberg } 536f30b1135SSebastian Grimberg 537f30b1135SSebastian Grimberg //------------------------------------------------------------------------------ 538f30b1135SSebastian Grimberg // ElemRestriction Apply Unsigned 539f30b1135SSebastian Grimberg //------------------------------------------------------------------------------ 540*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApplyUnsigned_Ref(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector v, 541*1cc2c60dSJeremy L Thompson CeedRequest *request) { 542ad70ee2cSJeremy L Thompson CeedInt num_block, block_size, num_comp, comp_stride; 543ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 544ad70ee2cSJeremy L Thompson 545*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumBlocks(rstr, &num_block)); 546*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetBlockSize(rstr, &block_size)); 547*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumComponents(rstr, &num_comp)); 548*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCompStride(rstr, &comp_stride)); 549*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 550*1cc2c60dSJeremy L Thompson CeedCallBackend(impl->Apply(rstr, num_comp, block_size, comp_stride, 0, num_block, t_mode, false, true, u, v, request)); 5515d10938bSJeremy L Thompson return CEED_ERROR_SUCCESS; 5527c1dbaffSSebastian Grimberg } 5537c1dbaffSSebastian Grimberg 5547c1dbaffSSebastian Grimberg //------------------------------------------------------------------------------ 5557c1dbaffSSebastian Grimberg // ElemRestriction Apply Unoriented 5567c1dbaffSSebastian Grimberg //------------------------------------------------------------------------------ 557*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApplyUnoriented_Ref(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector v, 558*1cc2c60dSJeremy L Thompson CeedRequest *request) { 559ad70ee2cSJeremy L Thompson CeedInt num_block, block_size, num_comp, comp_stride; 560ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 561ad70ee2cSJeremy L Thompson 562*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumBlocks(rstr, &num_block)); 563*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetBlockSize(rstr, &block_size)); 564*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumComponents(rstr, &num_comp)); 565*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCompStride(rstr, &comp_stride)); 566*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 567*1cc2c60dSJeremy L Thompson CeedCallBackend(impl->Apply(rstr, num_comp, block_size, comp_stride, 0, num_block, t_mode, false, false, u, v, request)); 5685d10938bSJeremy L Thompson return CEED_ERROR_SUCCESS; 5699c36149bSjeremylt } 570be9261b7Sjeremylt 571f10650afSjeremylt //------------------------------------------------------------------------------ 572f10650afSjeremylt // ElemRestriction Apply Block 573f10650afSjeremylt //------------------------------------------------------------------------------ 574*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionApplyBlock_Ref(CeedElemRestriction rstr, CeedInt block, CeedTransposeMode t_mode, CeedVector u, CeedVector v, 575074cb416Sjeremylt CeedRequest *request) { 576ad70ee2cSJeremy L Thompson CeedInt block_size, num_comp, comp_stride; 577ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 578ad70ee2cSJeremy L Thompson 579*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetBlockSize(rstr, &block_size)); 580*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumComponents(rstr, &num_comp)); 581*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCompStride(rstr, &comp_stride)); 582*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 583*1cc2c60dSJeremy L Thompson CeedCallBackend(impl->Apply(rstr, num_comp, block_size, comp_stride, block, block + 1, t_mode, true, true, u, v, request)); 5845d10938bSJeremy L Thompson return CEED_ERROR_SUCCESS; 5859c36149bSjeremylt } 586be9261b7Sjeremylt 587f10650afSjeremylt //------------------------------------------------------------------------------ 588bd33150aSjeremylt // ElemRestriction Get Offsets 589bd33150aSjeremylt //------------------------------------------------------------------------------ 5902b730f8bSJeremy L Thompson static int CeedElemRestrictionGetOffsets_Ref(CeedElemRestriction rstr, CeedMemType mem_type, const CeedInt **offsets) { 591bd33150aSjeremylt Ceed ceed; 592ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 593ad70ee2cSJeremy L Thompson 594ad70ee2cSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 5952b730f8bSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCeed(rstr, &ceed)); 596bd33150aSjeremylt 5976574a04fSJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, ceed, CEED_ERROR_BACKEND, "Can only provide to HOST memory"); 598bd33150aSjeremylt 599bd33150aSjeremylt *offsets = impl->offsets; 600e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 601bd33150aSjeremylt } 602bd33150aSjeremylt 603bd33150aSjeremylt //------------------------------------------------------------------------------ 60477d1c127SSebastian Grimberg // ElemRestriction Get Orientations 60577d1c127SSebastian Grimberg //------------------------------------------------------------------------------ 60677d1c127SSebastian Grimberg static int CeedElemRestrictionGetOrientations_Ref(CeedElemRestriction rstr, CeedMemType mem_type, const bool **orients) { 60777d1c127SSebastian Grimberg Ceed ceed; 608ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 609ad70ee2cSJeremy L Thompson 610ad70ee2cSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 61177d1c127SSebastian Grimberg CeedCallBackend(CeedElemRestrictionGetCeed(rstr, &ceed)); 61277d1c127SSebastian Grimberg 613fcbe8c06SSebastian Grimberg CeedCheck(mem_type == CEED_MEM_HOST, ceed, CEED_ERROR_BACKEND, "Can only provide to HOST memory"); 61477d1c127SSebastian Grimberg 61577d1c127SSebastian Grimberg *orients = impl->orients; 61677d1c127SSebastian Grimberg return CEED_ERROR_SUCCESS; 61777d1c127SSebastian Grimberg } 61877d1c127SSebastian Grimberg 61977d1c127SSebastian Grimberg //------------------------------------------------------------------------------ 62077d1c127SSebastian Grimberg // ElemRestriction Get Curl-Conforming Orientations 62177d1c127SSebastian Grimberg //------------------------------------------------------------------------------ 6220c73c039SSebastian Grimberg static int CeedElemRestrictionGetCurlOrientations_Ref(CeedElemRestriction rstr, CeedMemType mem_type, const CeedInt8 **curl_orients) { 62377d1c127SSebastian Grimberg Ceed ceed; 624ad70ee2cSJeremy L Thompson CeedElemRestriction_Ref *impl; 625ad70ee2cSJeremy L Thompson 626ad70ee2cSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 62777d1c127SSebastian Grimberg CeedCallBackend(CeedElemRestrictionGetCeed(rstr, &ceed)); 62877d1c127SSebastian Grimberg 629fcbe8c06SSebastian Grimberg CeedCheck(mem_type == CEED_MEM_HOST, ceed, CEED_ERROR_BACKEND, "Can only provide to HOST memory"); 63077d1c127SSebastian Grimberg 63177d1c127SSebastian Grimberg *curl_orients = impl->curl_orients; 63277d1c127SSebastian Grimberg return CEED_ERROR_SUCCESS; 63377d1c127SSebastian Grimberg } 63477d1c127SSebastian Grimberg 63577d1c127SSebastian Grimberg //------------------------------------------------------------------------------ 636f10650afSjeremylt // ElemRestriction Destroy 637f10650afSjeremylt //------------------------------------------------------------------------------ 638*1cc2c60dSJeremy L Thompson static int CeedElemRestrictionDestroy_Ref(CeedElemRestriction rstr) { 639fe2413ffSjeremylt CeedElemRestriction_Ref *impl; 64021617c04Sjeremylt 641*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetData(rstr, &impl)); 6422b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl->offsets_allocated)); 64377d1c127SSebastian Grimberg CeedCallBackend(CeedFree(&impl->orients_allocated)); 64477d1c127SSebastian Grimberg CeedCallBackend(CeedFree(&impl->curl_orients_allocated)); 6452b730f8bSJeremy L Thompson CeedCallBackend(CeedFree(&impl)); 646e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 64721617c04Sjeremylt } 64821617c04Sjeremylt 649f10650afSjeremylt //------------------------------------------------------------------------------ 650f10650afSjeremylt // ElemRestriction Create 651f10650afSjeremylt //------------------------------------------------------------------------------ 652fcbe8c06SSebastian Grimberg int CeedElemRestrictionCreate_Ref(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients, 653*1cc2c60dSJeremy L Thompson const CeedInt8 *curl_orients, CeedElemRestriction rstr) { 654ad70ee2cSJeremy L Thompson Ceed ceed; 655ad70ee2cSJeremy L Thompson CeedInt num_elem, elem_size, num_block, block_size, num_comp, comp_stride; 656ad70ee2cSJeremy L Thompson CeedRestrictionType rstr_type; 65721617c04Sjeremylt CeedElemRestriction_Ref *impl; 658ad70ee2cSJeremy L Thompson 659*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCeed(rstr, &ceed)); 660*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumElements(rstr, &num_elem)); 661*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetElementSize(rstr, &elem_size)); 662*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumBlocks(rstr, &num_block)); 663*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetBlockSize(rstr, &block_size)); 664*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetNumComponents(rstr, &num_comp)); 665*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetCompStride(rstr, &comp_stride)); 666ad70ee2cSJeremy L Thompson CeedInt layout[3] = {1, elem_size, elem_size * num_comp}; 66721617c04Sjeremylt 6686574a04fSJeremy L Thompson CeedCheck(mem_type == CEED_MEM_HOST, ceed, CEED_ERROR_BACKEND, "Only MemType = HOST supported"); 6692b730f8bSJeremy L Thompson CeedCallBackend(CeedCalloc(1, &impl)); 6703661185eSjeremylt 67192fe105eSJeremy L Thompson // Offsets data 672*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetType(rstr, &rstr_type)); 673fcbe8c06SSebastian Grimberg if (rstr_type != CEED_RESTRICTION_STRIDED) { 6743661185eSjeremylt const char *resource; 675ad70ee2cSJeremy L Thompson 676ad70ee2cSJeremy L Thompson // Check indices for ref or memcheck backends 677ad70ee2cSJeremy L Thompson CeedCallBackend(CeedGetResource(ceed, &resource)); 6782b730f8bSJeremy L Thompson if (!strcmp(resource, "/cpu/self/ref/serial") || !strcmp(resource, "/cpu/self/ref/blocked") || !strcmp(resource, "/cpu/self/memcheck/serial") || 679d1d35e2fSjeremylt !strcmp(resource, "/cpu/self/memcheck/blocked")) { 680e79b91d9SJeremy L Thompson CeedSize l_size; 6813661185eSjeremylt 682*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionGetLVectorSize(rstr, &l_size)); 6832b730f8bSJeremy L Thompson for (CeedInt i = 0; i < num_elem * elem_size; i++) { 6846574a04fSJeremy L Thompson CeedCheck(offsets[i] >= 0 && offsets[i] + (num_comp - 1) * comp_stride < l_size, ceed, CEED_ERROR_BACKEND, 6856574a04fSJeremy L Thompson "Restriction offset %" CeedInt_FMT " (%" CeedInt_FMT ") out of range [0, %" CeedInt_FMT "]", i, offsets[i], l_size); 6862b730f8bSJeremy L Thompson } 6872b730f8bSJeremy L Thompson } 6883661185eSjeremylt 68992fe105eSJeremy L Thompson // Copy data 690d1d35e2fSjeremylt switch (copy_mode) { 69121617c04Sjeremylt case CEED_COPY_VALUES: 6922b730f8bSJeremy L Thompson CeedCallBackend(CeedMalloc(num_elem * elem_size, &impl->offsets_allocated)); 6932b730f8bSJeremy L Thompson memcpy(impl->offsets_allocated, offsets, num_elem * elem_size * sizeof(offsets[0])); 694d979a051Sjeremylt impl->offsets = impl->offsets_allocated; 69521617c04Sjeremylt break; 69621617c04Sjeremylt case CEED_OWN_POINTER: 697d979a051Sjeremylt impl->offsets_allocated = (CeedInt *)offsets; 698d979a051Sjeremylt impl->offsets = impl->offsets_allocated; 69921617c04Sjeremylt break; 70021617c04Sjeremylt case CEED_USE_POINTER: 701d979a051Sjeremylt impl->offsets = offsets; 70221617c04Sjeremylt } 703fcbe8c06SSebastian Grimberg 704fcbe8c06SSebastian Grimberg // Orientation data 705fcbe8c06SSebastian Grimberg if (rstr_type == CEED_RESTRICTION_ORIENTED) { 7060305e208SSebastian Grimberg CeedCheck(orients != NULL, ceed, CEED_ERROR_BACKEND, "No orients array provided for oriented restriction"); 707fcbe8c06SSebastian Grimberg switch (copy_mode) { 708fcbe8c06SSebastian Grimberg case CEED_COPY_VALUES: 709fcbe8c06SSebastian Grimberg CeedCallBackend(CeedMalloc(num_elem * elem_size, &impl->orients_allocated)); 710fcbe8c06SSebastian Grimberg memcpy(impl->orients_allocated, orients, num_elem * elem_size * sizeof(orients[0])); 711fcbe8c06SSebastian Grimberg impl->orients = impl->orients_allocated; 712fcbe8c06SSebastian Grimberg break; 713fcbe8c06SSebastian Grimberg case CEED_OWN_POINTER: 714fcbe8c06SSebastian Grimberg impl->orients_allocated = (bool *)orients; 715fcbe8c06SSebastian Grimberg impl->orients = impl->orients_allocated; 716fcbe8c06SSebastian Grimberg break; 717fcbe8c06SSebastian Grimberg case CEED_USE_POINTER: 718fcbe8c06SSebastian Grimberg impl->orients = orients; 719fcbe8c06SSebastian Grimberg } 720fcbe8c06SSebastian Grimberg } else if (rstr_type == CEED_RESTRICTION_CURL_ORIENTED) { 7210305e208SSebastian Grimberg CeedCheck(curl_orients != NULL, ceed, CEED_ERROR_BACKEND, "No curl_orients array provided for oriented restriction"); 722fcbe8c06SSebastian Grimberg switch (copy_mode) { 723fcbe8c06SSebastian Grimberg case CEED_COPY_VALUES: 724fcbe8c06SSebastian Grimberg CeedCallBackend(CeedMalloc(num_elem * 3 * elem_size, &impl->curl_orients_allocated)); 725fcbe8c06SSebastian Grimberg memcpy(impl->curl_orients_allocated, curl_orients, num_elem * 3 * elem_size * sizeof(curl_orients[0])); 726fcbe8c06SSebastian Grimberg impl->curl_orients = impl->curl_orients_allocated; 727fcbe8c06SSebastian Grimberg break; 728fcbe8c06SSebastian Grimberg case CEED_OWN_POINTER: 7290c73c039SSebastian Grimberg impl->curl_orients_allocated = (CeedInt8 *)curl_orients; 730fcbe8c06SSebastian Grimberg impl->curl_orients = impl->curl_orients_allocated; 731fcbe8c06SSebastian Grimberg break; 732fcbe8c06SSebastian Grimberg case CEED_USE_POINTER: 733fcbe8c06SSebastian Grimberg impl->curl_orients = curl_orients; 734fcbe8c06SSebastian Grimberg } 735fcbe8c06SSebastian Grimberg } 73692fe105eSJeremy L Thompson } 737fe2413ffSjeremylt 738*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionSetData(rstr, impl)); 739*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedElemRestrictionSetELayout(rstr, layout)); 740*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "Apply", CeedElemRestrictionApply_Ref)); 741*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "ApplyUnsigned", CeedElemRestrictionApplyUnsigned_Ref)); 742*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "ApplyUnoriented", CeedElemRestrictionApplyUnoriented_Ref)); 743*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "ApplyBlock", CeedElemRestrictionApplyBlock_Ref)); 744*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "GetOffsets", CeedElemRestrictionGetOffsets_Ref)); 745*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "GetOrientations", CeedElemRestrictionGetOrientations_Ref)); 746*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "GetCurlOrientations", CeedElemRestrictionGetCurlOrientations_Ref)); 747*1cc2c60dSJeremy L Thompson CeedCallBackend(CeedSetBackendFunction(ceed, "ElemRestriction", rstr, "Destroy", CeedElemRestrictionDestroy_Ref)); 748d979a051Sjeremylt 749ad70ee2cSJeremy L Thompson // Set apply function based upon num_comp, block_size, and comp_stride 750ad70ee2cSJeremy L Thompson CeedInt index = -1; 751ad70ee2cSJeremy L Thompson 752ad70ee2cSJeremy L Thompson if (block_size < 10) index = 100 * num_comp + 10 * block_size + (comp_stride == 1); 753ad70ee2cSJeremy L Thompson switch (index) { 754d979a051Sjeremylt case 110: 755d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_110; 756d979a051Sjeremylt break; 757d979a051Sjeremylt case 111: 758d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_111; 759d979a051Sjeremylt break; 760d979a051Sjeremylt case 180: 761d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_180; 762d979a051Sjeremylt break; 763d979a051Sjeremylt case 181: 764d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_181; 765d979a051Sjeremylt break; 766d979a051Sjeremylt case 310: 767d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_310; 768d979a051Sjeremylt break; 769d979a051Sjeremylt case 311: 770d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_311; 771d979a051Sjeremylt break; 772d979a051Sjeremylt case 380: 773d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_380; 774d979a051Sjeremylt break; 775d979a051Sjeremylt case 381: 776d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_381; 777d979a051Sjeremylt break; 778bf4d1581Sjeremylt // LCOV_EXCL_START 779d979a051Sjeremylt case 510: 780d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_510; 781d979a051Sjeremylt break; 782bf4d1581Sjeremylt // LCOV_EXCL_STOP 783d979a051Sjeremylt case 511: 784d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_511; 785d979a051Sjeremylt break; 786bf4d1581Sjeremylt // LCOV_EXCL_START 787d979a051Sjeremylt case 580: 788d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_580; 789d979a051Sjeremylt break; 790bf4d1581Sjeremylt // LCOV_EXCL_STOP 791d979a051Sjeremylt case 581: 792d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_581; 793d979a051Sjeremylt break; 794d979a051Sjeremylt default: 795d979a051Sjeremylt impl->Apply = CeedElemRestrictionApply_Ref_Core; 796d979a051Sjeremylt break; 797d979a051Sjeremylt } 798e15f9bd0SJeremy L Thompson return CEED_ERROR_SUCCESS; 79921617c04Sjeremylt } 800fc0567d9Srezgarshakeri 801fc0567d9Srezgarshakeri //------------------------------------------------------------------------------ 802