Skip to content

Commit

Permalink
Derivs: extend calc_derivs2 for vec and smat
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Aug 23, 2024
1 parent ddcb93a commit 53d6ddd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Derivs/src/derivs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,29 @@ calc_derivs2(const GF3D5<T> &gf, const vec<GF3D5<T>, dim> &dgf,
}
}

template <int CI, int CJ, int CK, typename T>
CCTK_ATTRIBUTE_NOINLINE void calc_derivs2(
const vec<GF3D5<T>, dim> &gf, const vec<vec<GF3D5<T>, dim>, dim> &dgf,
const vec<smat<GF3D5<T>, dim>, dim> &ddgf, const GF3D5layout layout,
const GridDescBaseDevice &grid, const vec<GF3D2<const T>, dim> &gf0,
const vect<T, dim> dx, const int deriv_order) {
for (int a = 0; a < dim; ++a)
calc_derivs2<CI, CJ, CK>(gf(a), dgf(a), ddgf(a), layout, grid, gf0(a), dx,
deriv_order);
}

template <int CI, int CJ, int CK, typename T>
CCTK_ATTRIBUTE_NOINLINE void calc_derivs2(
const smat<GF3D5<T>, dim> &gf, const smat<vec<GF3D5<T>, dim>, dim> &dgf,
const smat<smat<GF3D5<T>, dim>, dim> &ddgf, const GF3D5layout layout,
const GridDescBaseDevice &grid, const smat<GF3D2<const T>, dim> &gf0,
const vect<T, dim> dx, const int deriv_order) {
for (int a = 0; a < dim; ++a)
for (int b = a; b < dim; ++b)
calc_derivs2<CI, CJ, CK>(gf(a, b), dgf(a, b), ddgf(a, b), layout, grid,
gf0(a, b), dx, deriv_order);
}

////////////////////////////////////////////////////////////////////////////////

// Template instantiations
Expand Down Expand Up @@ -238,4 +261,16 @@ calc_derivs2<0, 0, 0>(const GF3D5<T> &gf, const vec<GF3D5<T>, dim> &dgf,
const GridDescBaseDevice &grid, const GF3D2<const T> &gf0,
const vect<T, dim> dx, const int deriv_order);

template void calc_derivs2<0, 0, 0>(
const vec<GF3D5<T>, dim> &gf, const vec<vec<GF3D5<T>, dim>, dim> &dgf,
const vec<smat<GF3D5<T>, dim>, dim> &ddgf, const GF3D5layout layout,
const GridDescBaseDevice &grid, const vec<GF3D2<const T>, dim> &gf0,
const vect<T, dim> dx, const int deriv_order);

template void calc_derivs2<0, 0, 0>(
const smat<GF3D5<T>, dim> &gf, const smat<vec<GF3D5<T>, dim>, dim> &dgf,
const smat<smat<GF3D5<T>, dim>, dim> &ddgf, const GF3D5layout layout,
const GridDescBaseDevice &grid, const smat<GF3D2<const T>, dim> &gf0,
const vect<T, dim> dx, const int deriv_order);

} // namespace Derivs
18 changes: 18 additions & 0 deletions Derivs/src/derivs.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,24 @@ CCTK_ATTRIBUTE_NOINLINE void calc_derivs2(
const Loop::GF3D2<const T> &gf0, const Arith::vect<T, Loop::dim> dx,
const int deriv_order);

template <int CI, int CJ, int CK, typename T>
CCTK_ATTRIBUTE_NOINLINE void calc_derivs2(
const Arith::vec<Loop::GF3D5<T>, Loop::dim> &gf,
const Arith::vec<Arith::vec<Loop::GF3D5<T>, Loop::dim>, Loop::dim> &dgf,
const Arith::vec<Arith::smat<Loop::GF3D5<T>, Loop::dim>, Loop::dim> &ddgf,
const Loop::GF3D5layout layout, const Loop::GridDescBaseDevice &grid,
const Arith::vec<Loop::GF3D2<const T>, Loop::dim> &gf0,
const Arith::vect<T, Loop::dim> dx, const int deriv_order);

template <int CI, int CJ, int CK, typename T>
CCTK_ATTRIBUTE_NOINLINE void calc_derivs2(
const Arith::smat<Loop::GF3D5<T>, Loop::dim> &gf,
const Arith::smat<Arith::vec<Loop::GF3D5<T>, Loop::dim>, Loop::dim> &dgf,
const Arith::smat<Arith::smat<Loop::GF3D5<T>, Loop::dim>, Loop::dim> &ddgf,
const Loop::GF3D5layout layout, const Loop::GridDescBaseDevice &grid,
const Arith::smat<Loop::GF3D2<const T>, Loop::dim> &gf0,
const Arith::vect<T, Loop::dim> dx, const int deriv_order);

} // namespace Derivs

#endif // #ifndef CARPETX_DERIVS_DERIVS_HXX

0 comments on commit 53d6ddd

Please sign in to comment.