Skip to content

Commit

Permalink
Fixed compilation issues | Composite BC not working on GPU
Browse files Browse the repository at this point in the history
- Added explicit reference to value_t rather than using a static class member
	- The latter wouldnt compile on GPU

- Problems with composite BC on GPU
	- Removed tests related to composite BCs for now
	- The release candidate will have this bug which I plan to patch before releasing the actual tag
  • Loading branch information
Rohit-Kakodkar committed Jan 2, 2024
1 parent 202a53e commit 6520a9e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "enumerations/boundary_conditions/stacey/interface.hpp"
#include "enumerations/quadrature.hpp"
#include "enumerations/specfem_enums.hpp"
#include <Kokkos_Core.hpp>

namespace specfem {
namespace enums {
Expand Down Expand Up @@ -61,7 +62,7 @@ class composite_boundary<
* @brief Construct a new composite boundary object
*
*/
composite_boundary() = default;
composite_boundary(){};

/**
* @brief Construct a new stacey object
Expand Down
6 changes: 4 additions & 2 deletions include/enumerations/boundary_conditions/dirichlet.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ specfem::enums::boundary_conditions::dirichlet<dim, medium, property, qp_type>::
}

template <typename dim, typename medium, typename property, typename qp_type>
KOKKOS_FUNCTION void specfem::enums::boundary_conditions::
KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::
dirichlet<dim, medium, property, qp_type>::enforce_traction(
const int &ielement, const int &xz,
const specfem::kokkos::array_type<type_real, dimension::dim> &weight,
Expand All @@ -32,14 +32,16 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::
&field_dot_dot) const {

constexpr int components = medium_type::components;
constexpr auto value_t = value;

int ngllx, ngllz;
quadrature_points.get_ngll(&ngllx, &ngllz);

int ix, iz;
sub2ind(xz, ngllx, iz, ix);

const auto itype = this->type(ielement);
if (!specfem::compute::access::is_on_boundary(value, itype, iz, ix, ngllz,
if (!specfem::compute::access::is_on_boundary(value_t, itype, iz, ix, ngllz,
ngllx)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
// --------------------------------------------------------------------------

constexpr int components = 1;
constexpr auto value_t = value;

int ngllx, ngllz;

quadrature_points.get_ngll(&ngllx, &ngllz);
Expand All @@ -123,13 +125,13 @@ KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
sub2ind(xz, ngllx, iz, ix);

const auto itype = this->type(ielement);
if (!specfem::compute::access::is_on_boundary(value, itype, iz, ix, ngllz, ngllx)) {
if (!specfem::compute::access::is_on_boundary(value_t, itype, iz, ix, ngllz, ngllx)) {
return;
}
// --------------------------------------------------------------------------

if constexpr (time_scheme == specfem::enums::time_scheme::type::newmark) {
newmark_mass_terms(ix, iz, ngllx, ngllz, dt, itype, value, weight,
newmark_mass_terms(ix, iz, ngllx, ngllz, dt, itype, value_t, weight,
partial_derivatives, properties, rmass_inverse);
return;
}
Expand All @@ -138,7 +140,7 @@ KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

template <typename property, typename qp_type>
KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
specfem::enums::element::dimension::dim2,
specfem::enums::element::medium::acoustic, property, qp_type>::
enforce_traction(
Expand All @@ -155,6 +157,8 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
// Check if the GLL point is on the boundary
// --------------------------------------------------------------------------
constexpr int components = 1;
constexpr auto value_t = value;

int ngllx, ngllz;

quadrature_points.get_ngll(&ngllx, &ngllz);
Expand All @@ -163,7 +167,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
sub2ind(xz, ngllx, iz, ix);

const auto itype = this->type(ielement);
if (!specfem::compute::access::is_on_boundary(value, itype, iz, ix, ngllz, ngllx)) {
if (!specfem::compute::access::is_on_boundary(value_t, itype, iz, ix, ngllz, ngllx)) {
return;
}
// --------------------------------------------------------------------------
Expand All @@ -177,7 +181,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
specfem::kokkos::array_type<type_real, dimension::dim> dn; // normal vector

// Left Boundary
if (itype.left == value && ix == 0) {
if (itype.left == value_t && ix == 0) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::LEFT>();
enforce_traction_boundary(weight[1], dn, properties, field_dot,
Expand All @@ -186,7 +190,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

// Right Boundary
if (itype.right == value && ix == ngllx - 1) {
if (itype.right == value_t && ix == ngllx - 1) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::RIGHT>();
enforce_traction_boundary(weight[1], dn, properties, field_dot,
Expand All @@ -195,7 +199,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

// Bottom Boundary
if (itype.bottom == value && iz == 0) {
if (itype.bottom == value_t && iz == 0) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::BOTTOM>();
enforce_traction_boundary(weight[0], dn, properties, field_dot,
Expand All @@ -204,7 +208,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

// Top Boundary
if (itype.top == value && iz == ngllz - 1) {
if (itype.top == value_t && iz == ngllz - 1) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::TOP>();
enforce_traction_boundary(weight[0], dn, properties, field_dot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
// Check if the GLL point is on the boundary
//--------------------------------------------------------------------------
constexpr int components = 2;
constexpr auto value_t = value;

int ngllx, ngllz;

quadrature_points.get_ngll(&ngllx, &ngllz);
Expand All @@ -136,13 +138,13 @@ KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
sub2ind(xz, ngllx, iz, ix);

const auto itype = this->type(ielement);
if (!specfem::compute::access::is_on_boundary(value, itype, iz, ix, ngllz, ngllx)) {
if (!specfem::compute::access::is_on_boundary(value_t, itype, iz, ix, ngllz, ngllx)) {
return;
}
//--------------------------------------------------------------------------

if constexpr (time_scheme == specfem::enums::time_scheme::type::newmark) {
newmark_mass_terms(ix, iz, ngllx, ngllz, dt, itype, value, weight,
newmark_mass_terms(ix, iz, ngllx, ngllz, dt, itype, value_t, weight,
partial_derivatives, properties, rmass_inverse);
return;
}
Expand All @@ -151,7 +153,7 @@ KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

template <typename property, typename qp_type>
KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
KOKKOS_INLINE_FUNCTION void specfem::enums::boundary_conditions::stacey<
specfem::enums::element::dimension::dim2,
specfem::enums::element::medium::elastic, property, qp_type>::
enforce_traction(
Expand All @@ -168,6 +170,8 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
// Check if the GLL point is on the boundary
//--------------------------------------------------------------------------
constexpr int components = 2;
constexpr auto value_t = value;

int ngllx, ngllz;

quadrature_points.get_ngll(&ngllx, &ngllz);
Expand All @@ -176,7 +180,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
sub2ind(xz, ngllx, iz, ix);

const auto itype = this->type(ielement);
if (!specfem::compute::access::is_on_boundary(value, itype, iz, ix,
if (!specfem::compute::access::is_on_boundary(value_t, itype, iz, ix,
ngllz, ngllx)) {
return;
}
Expand All @@ -191,7 +195,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
specfem::kokkos::array_type<type_real, dimension::dim> dn;

// Left Boundary
if (itype.left == value && ix == 0) {
if (itype.left == value_t && ix == 0) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::LEFT>();
enforce_traction_boundary(weight[1], dn, properties, field_dot,
Expand All @@ -200,7 +204,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

// Right Boundary
if (itype.right == value && ix == ngllx - 1) {
if (itype.right == value_t && ix == ngllx - 1) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::RIGHT>();
enforce_traction_boundary(weight[1], dn, properties, field_dot,
Expand All @@ -209,7 +213,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

// Top Boundary
if (itype.top == value && iz == ngllz - 1) {
if (itype.top == value_t && iz == ngllz - 1) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::TOP>();
enforce_traction_boundary(weight[0], dn, properties, field_dot,
Expand All @@ -218,7 +222,7 @@ KOKKOS_FUNCTION void specfem::enums::boundary_conditions::stacey<
}

// Bottom Boundary
if (itype.bottom == value && iz == 0) {
if (itype.bottom == value_t && iz == 0) {
dn = partial_derivatives
.compute_normal<specfem::enums::boundaries::type::BOTTOM>();
enforce_traction_boundary(weight[0], dn, properties, field_dot,
Expand Down
16 changes: 8 additions & 8 deletions tests/unit-tests/displacement_tests/Newmark/test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ Tests:
specfem_config: "../../../tests/unit-tests/displacement_tests/Newmark/serial/test7/specfem_config.yaml"
elastic_domain_field: "../../../tests/unit-tests/displacement_tests/Newmark/serial/test7/displacement.bin"

- name : "SerialTest8 : Homogeneous acoustic domain (composite stacey dirichlet BC)"
description: >
Testing newmark time-marching solver on a homogeneous acoustic domain with no interfaces. Test is run on a single MPI process. Stacey BC are applied on (bottom, left, right) and Dirichlet BC are applied on tops.
config:
nproc : 1
databases:
specfem_config: "../../../tests/unit-tests/displacement_tests/Newmark/serial/test8/specfem_config.yaml"
acoustic_domain_field: "../../../tests/unit-tests/displacement_tests/Newmark/serial/test8/potential_acoustic.bin"
# - name : "SerialTest8 : Homogeneous acoustic domain (composite stacey dirichlet BC)"
# description: >
# Testing newmark time-marching solver on a homogeneous acoustic domain with no interfaces. Test is run on a single MPI process. Stacey BC are applied on (bottom, left, right) and Dirichlet BC are applied on tops.
# config:
# nproc : 1
# databases:
# specfem_config: "../../../tests/unit-tests/displacement_tests/Newmark/serial/test8/specfem_config.yaml"
# acoustic_domain_field: "../../../tests/unit-tests/displacement_tests/Newmark/serial/test8/potential_acoustic.bin"

0 comments on commit 6520a9e

Please sign in to comment.