Skip to content

Commit

Permalink
Update benchmark imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
icui committed Feb 5, 2025
1 parent ce08ab2 commit e058c0b
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 17 deletions.
1 change: 1 addition & 0 deletions benchmarks/chunk.hpp → benchmarks/impl_chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "enumerations/dimension.hpp"
#include "point/coordinates.hpp"
#include "point/field_derivatives.hpp"
#include <Kokkos_Core.hpp>
#include <string>
#include <type_traits>
Expand Down
File renamed without changes.
114 changes: 114 additions & 0 deletions benchmarks/impl_stress.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#pragma once

#include "point/stress.hpp"
#include <Kokkos_Core.hpp>

namespace specfem {
namespace benchmarks {


template <bool UseSIMD>
KOKKOS_INLINE_FUNCTION specfem::point::stress<
specfem::dimension::type::dim2, specfem::element::medium_tag::acoustic,
UseSIMD>
compute_stress(
const specfem::point::properties<
specfem::dimension::type::dim2, specfem::element::medium_tag::acoustic,
specfem::element::property_tag::isotropic, UseSIMD> &properties,
const specfem::point::field_derivatives<
specfem::dimension::type::dim2, specfem::element::medium_tag::acoustic,
UseSIMD> &field_derivatives) {

const auto &du = field_derivatives.du;

specfem::datatype::VectorPointViewType<type_real, 2, 1, UseSIMD> T;

T(0, 0) = properties.rho_inverse * du(0, 0);
T(1, 0) = properties.rho_inverse * du(1, 0);

return { T };
}


template <bool UseSIMD>
KOKKOS_INLINE_FUNCTION specfem::point::stress<
specfem::dimension::type::dim2, specfem::element::medium_tag::elastic,
UseSIMD>
compute_stress(
const specfem::point::properties<
specfem::dimension::type::dim2, specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic, UseSIMD> &properties,
const specfem::point::field_derivatives<
specfem::dimension::type::dim2, specfem::element::medium_tag::elastic,
UseSIMD> &field_derivatives) {

using datatype =
typename specfem::datatype::simd<type_real, UseSIMD>::datatype;
const auto &du = field_derivatives.du;

datatype sigma_xx, sigma_zz, sigma_xz;

// P_SV case
// sigma_xx
sigma_xx = properties.c11 * du(0, 0) + properties.c13 * du(1, 1) +
properties.c15 * (du(1, 0) + du(0, 1));

// sigma_zz
sigma_zz = properties.c13 * du(0, 0) + properties.c33 * du(1, 1) +
properties.c35 * (du(1, 0) + du(0, 1));

// sigma_xz
sigma_xz = properties.c15 * du(0, 0) + properties.c35 * du(1, 1) +
properties.c55 * (du(1, 0) + du(0, 1));

specfem::datatype::VectorPointViewType<type_real, 2, 2, UseSIMD> T;

T(0, 0) = sigma_xx;
T(0, 1) = sigma_xz;
T(1, 0) = sigma_xz;
T(1, 1) = sigma_zz;

return { T };
}


template <bool UseSIMD>
KOKKOS_INLINE_FUNCTION specfem::point::stress<
specfem::dimension::type::dim2, specfem::element::medium_tag::elastic,
UseSIMD>
compute_stress(
const specfem::point::properties<
specfem::dimension::type::dim2, specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic, UseSIMD> &properties,
const specfem::point::field_derivatives<
specfem::dimension::type::dim2, specfem::element::medium_tag::elastic,
UseSIMD> &field_derivatives) {

using datatype =
typename specfem::datatype::simd<type_real, UseSIMD>::datatype;
const auto &du = field_derivatives.du;

datatype sigma_xx, sigma_zz, sigma_xz;

// P_SV case
// sigma_xx
sigma_xx = properties.lambdaplus2mu * du(0, 0) + properties.lambda * du(1, 1);

// sigma_zz
sigma_zz = properties.lambdaplus2mu * du(1, 1) + properties.lambda * du(0, 0);

// sigma_xz
sigma_xz = properties.mu * (du(0, 1) + du(1, 0));

specfem::datatype::VectorPointViewType<type_real, 2, 2, UseSIMD> T;

T(0, 0) = sigma_xx;
T(0, 1) = sigma_xz;
T(1, 0) = sigma_xz;
T(1, 1) = sigma_zz;

return { T };
}

} // namespace medium
} // namespace specfem
4 changes: 2 additions & 2 deletions benchmarks/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void run_benchmark(const YAML::Node &parameter_dict,

benchmark(assembly, time_scheme, 1);
benchmark(assembly, time_scheme, 0);
benchmark(assembly, time_scheme, 1);
benchmark(assembly, time_scheme, 0);
// benchmark(assembly, time_scheme, 1);
// benchmark(assembly, time_scheme, 0);
std::cout << std::endl;
}

Expand Down
25 changes: 10 additions & 15 deletions benchmarks/stiffness.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
#pragma once

#include "boundary_conditions/boundary_conditions.hpp"
#include "enumerations/dimension.hpp"
#include "enumerations/medium.hpp"
#include "enumerations/wavefield.hpp"

#include "chunk_element/field.hpp"
#include "chunk_element/stress_integrand.hpp"

#include "impl_load.hpp"
#include "impl_chunk.hpp"
#include "impl_stress.hpp"

#include "compute/assembly/assembly.hpp"
#include "datatypes/simd.hpp"
#include "element/quadrature.hpp"
#include "enumerations/dimension.hpp"
#include "enumerations/medium.hpp"
#include "enumerations/wavefield.hpp"
#include "load.hpp"
#include "medium/compute_stress.hpp"
#include "parallel_configuration/chunk_config.hpp"
#include "point/boundary.hpp"
#include "point/field.hpp"
#include "point/field_derivatives.hpp"
#include "point/partial_derivatives.hpp"
#include "point/properties.hpp"
#include "point/sources.hpp"
#include "chunk.hpp"
#include <Kokkos_Core.hpp>

namespace specfem {
Expand Down Expand Up @@ -192,7 +187,7 @@ void compute_stiffness_interaction(const specfem::compute::assembly &assembly,

PointFieldDerivativesType field_derivatives(df);

const auto point_stress = specfem::medium::compute_stress(
const auto point_stress = specfem::benchmarks::compute_stress(
point_property, field_derivatives);

const auto F = point_stress * point_partial_derivatives2;
Expand Down

0 comments on commit e058c0b

Please sign in to comment.