Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more support for nvcc #6248

Merged
merged 25 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d7d06ec
Add non-const unique_ptr retrieve functions
nilsdeppe Aug 15, 2024
8381e38
Support nvcc in Domain/Amr
nilsdeppe Aug 15, 2024
ba45f43
Print number in Flag stream operator when unknown flag
nilsdeppe Aug 20, 2024
31a5f2c
Support nvcc in ForceFree system
nilsdeppe Aug 15, 2024
77dedb7
Support nvcc in SurfaceFinder library
nilsdeppe Aug 15, 2024
ef9c050
Support nvcc in PhaseControl library
nilsdeppe Aug 15, 2024
719fb29
Support nvcc in Parallel library
nilsdeppe Aug 15, 2024
a79f422
Support nvcc in boundary conditions tests
nilsdeppe Aug 15, 2024
6d9ea94
Support nvcc in EventsAndDenseTriggers
nilsdeppe Aug 15, 2024
b9c5a41
Support nvcc in EventsAndTriggers
nilsdeppe Aug 15, 2024
693bc37
Support nvcc in XCTS initial data
nilsdeppe Aug 15, 2024
370f056
Support nvcc in ControlSystem library
nilsdeppe Aug 19, 2024
4cc12fd
Support nvcc in DataStructures library
nilsdeppe Aug 19, 2024
9df16b0
Support nvcc in Test_DomainStructure
nilsdeppe Aug 20, 2024
aa7c466
Support nvcc in DomainCreators library
nilsdeppe Aug 19, 2024
1eebe49
Support nvcc in CoordinateMaps library
nilsdeppe Aug 19, 2024
8566ac8
Support nvcc in CurvedScalarWave library
nilsdeppe Aug 19, 2024
73f92f3
Support nvcc in Evolution library
nilsdeppe Aug 19, 2024
1376d56
Support nvcc in Time library
nilsdeppe Aug 19, 2024
bdebbf3
Support nvcc in ValenciaDivClean library
nilsdeppe Aug 20, 2024
d00485a
Support nvcc to Test_ControlSystem
nilsdeppe Aug 20, 2024
e4808ea
Support nvcc in Test_Importers
nilsdeppe Aug 20, 2024
4535579
Add partial nvcc support to LinearSolver tests
nilsdeppe Aug 20, 2024
259fedd
Support nvcc in domain tests
nilsdeppe Aug 20, 2024
a607b80
Support nvcc in Interpolation
nilsdeppe Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ControlSystem/ControlErrors/Size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ void Size<DerivOrder, Horizon>::pup(PUP::er& p) {
p | delta_r_drift_outward_options_;
}

template <size_t DerivOrder, ::domain::ObjectLabel Horizon>
Size<DerivOrder,
Horizon>::DeltaRDriftOutwardOptions::DeltaRDriftOutwardOptions() = default;

template <size_t DerivOrder, ::domain::ObjectLabel Horizon>
Size<DerivOrder, Horizon>::DeltaRDriftOutwardOptions::DeltaRDriftOutwardOptions(
double max_allowed_radial_distance_in, double outward_drift_velocity_in,
double outward_drift_timescale_in)
: max_allowed_radial_distance(max_allowed_radial_distance_in),
outward_drift_velocity(outward_drift_velocity_in),
outward_drift_timescale(outward_drift_timescale_in) {}

template <size_t DerivOrder, ::domain::ObjectLabel Horizon>
void Size<DerivOrder, Horizon>::DeltaRDriftOutwardOptions::pup(PUP::er& p) {
p | max_allowed_radial_distance;
p | outward_drift_velocity;
p | outward_drift_timescale;
}

#define DERIV_ORDER(data) BOOST_PP_TUPLE_ELEM(0, data)
#define HORIZON(data) BOOST_PP_TUPLE_ELEM(1, data)

Expand Down
10 changes: 5 additions & 5 deletions src/ControlSystem/ControlErrors/Size.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ struct Size : tt::ConformsTo<protocols::ControlError> {
};
using options = tmpl::list<MaxAllowedRadialDistance, OutwardDriftVelocity,
OutwardDriftTimescale>;
void pup(PUP::er& p) {
p | max_allowed_radial_distance;
p | outward_drift_velocity;
p | outward_drift_timescale;
}
DeltaRDriftOutwardOptions();
DeltaRDriftOutwardOptions(double max_allowed_radial_distance_in,
double outward_drift_velocity_in,
double outward_drift_timescale_in);
void pup(PUP::er& p);

double max_allowed_radial_distance{};
double outward_drift_velocity{};
Expand Down
10 changes: 10 additions & 0 deletions src/DataStructures/IdPair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@
*/
template <typename IdType, typename DataType>
struct IdPair {
IdPair();
IdPair(IdType id_in, DataType data_in);

IdType id{};
DataType data{};
};

template <typename IdType, typename DataType>
IdPair<IdType, DataType>::IdPair() = default;

template <typename IdType, typename DataType>
IdPair<IdType, DataType>::IdPair(IdType id_in, DataType data_in)
: id(std::move(id_in)), data(std::move(data_in)) {}

template <typename IdType, typename DataType>
IdPair<std::decay_t<IdType>, std::decay_t<DataType>> make_id_pair(
IdType&& id, DataType&& data) {
Expand Down
5 changes: 4 additions & 1 deletion src/DataStructures/SpinWeighted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "DataStructures/ComplexDataVector.hpp"
#include "DataStructures/VectorImpl.hpp"
#include "Utilities/ForceInline.hpp"
#include "Utilities/Requires.hpp"
#include "Utilities/SetNumberOfGridPoints.hpp"
Expand Down Expand Up @@ -451,7 +452,9 @@ SPECTRE_ALWAYS_INLINE
operator/(const T& lhs, const SpinWeighted<T, Spin>& rhs) {
return {lhs / rhs.data()};
}
template <typename T, int Spin>
template <
typename T, int Spin,
Requires<not std::is_same_v<T, get_vector_element_type_t<T>>> = nullptr>
SPECTRE_ALWAYS_INLINE SpinWeighted<
decltype(std::declval<get_vector_element_type_t<T>>() / std::declval<T>()),
-Spin>
Expand Down
39 changes: 31 additions & 8 deletions src/DataStructures/Variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <pup.h>
#include <string>
#include <tuple>
#include <type_traits>

#include "DataStructures/DataBox/PrefixHelpers.hpp"
#include "DataStructures/DataBox/Subitems.hpp"
Expand Down Expand Up @@ -439,16 +440,27 @@ class Variables<tmpl::list<Tags...>> {
return *this;
}

template <typename... WrappedTags,
Requires<tmpl2::flat_all<std::is_same_v<
db::remove_all_prefixes<WrappedTags>,
db::remove_all_prefixes<Tags>>...>::value> = nullptr>
template <
typename... WrappedTags,
Requires<
sizeof...(WrappedTags) == sizeof...(Tags) and
tmpl2::flat_all_v<std::is_same_v<db::remove_all_prefixes<WrappedTags>,
db::remove_all_prefixes<Tags>>...>
#ifdef __CUDACC__
and tmpl2::flat_all_v<std::is_same_v<typename WrappedTags::type,
typename Tags::type>...>
#endif
> = nullptr>
friend SPECTRE_ALWAYS_INLINE decltype(auto) operator+(
const Variables<tmpl::list<WrappedTags...>>& lhs, const Variables& rhs) {
#ifndef __CUDACC__
// nvcc incorrectly hits this static_assert and variants of it, but using
// the additional requires part above is fine.
static_assert(
(std::is_same_v<typename Tags::type, typename WrappedTags::type> and
...),
"Tensor types do not match!");
#endif
return lhs.get_variable_data() + rhs.variable_data_;
}
template <typename VT, bool VF>
Expand All @@ -462,16 +474,27 @@ class Variables<tmpl::list<Tags...>> {
return lhs.variable_data_ + *rhs;
}

template <typename... WrappedTags,
Requires<tmpl2::flat_all<std::is_same_v<
db::remove_all_prefixes<WrappedTags>,
db::remove_all_prefixes<Tags>>...>::value> = nullptr>
template <
typename... WrappedTags,
Requires<
sizeof...(WrappedTags) == sizeof...(Tags) and
tmpl2::flat_all_v<std::is_same_v<db::remove_all_prefixes<WrappedTags>,
db::remove_all_prefixes<Tags>>...>
#ifdef __CUDACC__
and tmpl2::flat_all_v<std::is_same_v<typename WrappedTags::type,
typename Tags::type>...>
#endif
> = nullptr>
friend SPECTRE_ALWAYS_INLINE decltype(auto) operator-(
const Variables<tmpl::list<WrappedTags...>>& lhs, const Variables& rhs) {
#ifndef __CUDACC__
// nvcc incorrectly hits this static_assert and variants of it, but using
// the additional requires part above is fine.
static_assert(
(std::is_same_v<typename Tags::type, typename WrappedTags::type> and
...),
"Tensor types do not match!");
#endif
return lhs.get_variable_data() - rhs.variable_data_;
}
template <typename VT, bool VF>
Expand Down
3 changes: 2 additions & 1 deletion src/Domain/Amr/Flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ std::ostream& operator<<(std::ostream& os, const Flag& flag) {
os << "Split";
break;
default:
ERROR("An undefined flag was passed to the stream operator.");
ERROR("An unknown flag was passed to the stream operator. "
<< static_cast<int>(flag));
}
return os;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Domain/Amr/Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@
#include "Domain/Amr/Info.hpp"
#include "NumericalAlgorithms/Spectral/Mesh.hpp"
#include "Utilities/GenerateInstantiations.hpp"
#include "Utilities/MakeArray.hpp"
#include "Utilities/StdHelpers.hpp"

namespace amr {
template <size_t VolumeDim>
Info<VolumeDim>::Info()
: flags(make_array<VolumeDim>(Flag::Undefined)), new_mesh{} {}

template <size_t VolumeDim>
Info<VolumeDim>::Info(std::array<Flag, VolumeDim> flags_in,
Mesh<VolumeDim> new_mesh_in)
: flags(std::move(flags_in)), new_mesh(std::move(new_mesh_in)) {}

template <size_t VolumeDim>
void Info<VolumeDim>::pup(PUP::er& p) {
p | flags;
Expand Down
3 changes: 3 additions & 0 deletions src/Domain/Amr/Info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace amr {
/// amr::Flag%s and Mesh of an element.
template <size_t VolumeDim>
struct Info {
Info();
Info(std::array<Flag, VolumeDim> flags_in, Mesh<VolumeDim> new_mesh_in);

std::array<Flag, VolumeDim> flags;
Mesh<VolumeDim> new_mesh;

Expand Down
51 changes: 27 additions & 24 deletions src/Domain/CoordinateMaps/CoordinateMap.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,21 @@ auto CoordinateMap<SourceFrame, TargetFrame, Maps...>::inv_jacobian_impl(
tnsr::Ij<T, dim, Frame::NoFrame> noframe_inv_jac{};

if (UNLIKELY(count == 0)) {
detail::get_inv_jacobian(make_not_null(&noframe_inv_jac), map,
mapped_point, time, functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
::domain::detail::get_inv_jacobian(
make_not_null(&noframe_inv_jac), map, mapped_point, time,
functions_of_time, domain::is_jacobian_time_dependent_t<Map, T>{});
for (size_t source = 0; source < dim; ++source) {
for (size_t target = 0; target < dim; ++target) {
inv_jac.get(source, target) =
std::move(noframe_inv_jac.get(source, target));
}
}
} else if (LIKELY(not map.is_identity())) {
detail::get_inv_jacobian(make_not_null(&noframe_inv_jac), map,
mapped_point, time, functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
detail::multiply_inv_jacobian(make_not_null(&inv_jac), noframe_inv_jac);
::domain::detail::get_inv_jacobian(
make_not_null(&noframe_inv_jac), map, mapped_point, time,
functions_of_time, domain::is_jacobian_time_dependent_t<Map, T>{});
::domain::detail::multiply_inv_jacobian(make_not_null(&inv_jac),
noframe_inv_jac);
}

// Compute the source coordinates for the next map, only if we are not
Expand Down Expand Up @@ -378,19 +379,19 @@ auto CoordinateMap<SourceFrame, TargetFrame, Maps...>::jacobian_impl(
tnsr::Ij<T, dim, Frame::NoFrame> noframe_jac{};

if (UNLIKELY(count == 0)) {
detail::get_jacobian(make_not_null(&noframe_jac), map, mapped_point, time,
functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
::domain::detail::get_jacobian(
make_not_null(&noframe_jac), map, mapped_point, time,
functions_of_time, domain::is_jacobian_time_dependent_t<Map, T>{});
for (size_t target = 0; target < dim; ++target) {
for (size_t source = 0; source < dim; ++source) {
jac.get(target, source) = std::move(noframe_jac.get(target, source));
}
}
} else if (LIKELY(not map.is_identity())) {
detail::get_jacobian(make_not_null(&noframe_jac), map, mapped_point, time,
functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
detail::multiply_jacobian(make_not_null(&jac), noframe_jac);
::domain::detail::get_jacobian(
make_not_null(&noframe_jac), map, mapped_point, time,
functions_of_time, domain::is_jacobian_time_dependent_t<Map, T>{});
::domain::detail::multiply_jacobian(make_not_null(&jac), noframe_jac);
}

// Compute the source coordinates for the next map, only if we are not
Expand Down Expand Up @@ -454,9 +455,10 @@ auto CoordinateMap<SourceFrame, TargetFrame, Maps...>::
tnsr::Ij<T, dim, Frame::NoFrame> noframe_jac{};
if constexpr (count == 0) {
// Set Jacobian
detail::get_jacobian(make_not_null(&noframe_jac), map, mapped_point,
time, functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
::domain::detail::get_jacobian(
make_not_null(&noframe_jac), map, mapped_point, time,
functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
for (size_t target = 0; target < dim; ++target) {
for (size_t source = 0; source < dim; ++source) {
jac.get(target, source) =
Expand All @@ -468,8 +470,8 @@ auto CoordinateMap<SourceFrame, TargetFrame, Maps...>::
if constexpr (domain::is_map_time_dependent_v<std::tuple_element_t<
0, std::decay_t<decltype(maps)>>>) {
std::array<T, dim> noframe_frame_velocity =
detail::get_frame_velocity(map, mapped_point, time,
functions_of_time);
::domain::detail::get_frame_velocity(map, mapped_point, time,
functions_of_time);
for (size_t i = 0; i < dim; ++i) {
frame_velocity.get(i) =
std::move(gsl::at(noframe_frame_velocity, i));
Expand All @@ -486,18 +488,19 @@ auto CoordinateMap<SourceFrame, TargetFrame, Maps...>::
// velocity is also zero. That is, we do not optimize for the map
// being instantaneously zero.

detail::get_jacobian(make_not_null(&noframe_jac), map, mapped_point,
time, functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});
::domain::detail::get_jacobian(
make_not_null(&noframe_jac), map, mapped_point, time,
functions_of_time,
domain::is_jacobian_time_dependent_t<Map, T>{});

// Perform matrix multiplication for Jacobian
detail::multiply_jacobian(make_not_null(&jac), noframe_jac);
::domain::detail::multiply_jacobian(make_not_null(&jac), noframe_jac);

// Set frame velocity, only if map is time-dependent
std::array<T, dim> noframe_frame_velocity{};
if constexpr (domain::is_map_time_dependent_v<
std::tuple_element_t<count, std::decay_t<decltype(maps)>>>) {
noframe_frame_velocity = detail::get_frame_velocity(
noframe_frame_velocity = ::domain::detail::get_frame_velocity(
map, mapped_point, time, functions_of_time);
for (size_t target_frame_index = 0; target_frame_index < dim;
++target_frame_index) {
Expand Down
8 changes: 8 additions & 0 deletions src/Domain/Creators/BinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class BinaryCompactObject : public DomainCreator<3> {
using options = tmpl::list<BoundaryCondition<
domain::BoundaryConditions::get_boundary_conditions_base<
typename Metavariables::system>>>;
Excision() = default;
// NOLINTNEXTLINE(google-explicit-constructor)
Excision(std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
boundary_condition_in)
: boundary_condition(std::move(boundary_condition_in)) {}
std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
boundary_condition;
};
Expand Down Expand Up @@ -301,6 +306,9 @@ class BinaryCompactObject : public DomainCreator<3> {
static constexpr Options::String help = {"x-coordinate of center."};
};
using options = tmpl::list<XCoord>;
CartesianCubeAtXCoord() = default;
// NOLINTNEXTLINE(google-explicit-constructor)
CartesianCubeAtXCoord(const double x_coord_in) : x_coord(x_coord_in) {}
bool is_excised() const { return false; }
double x_coord;
};
Expand Down
2 changes: 2 additions & 0 deletions src/Domain/Creators/Sphere.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ struct InnerCube {
static double upper_bound() { return 1.0; }
};
using options = tmpl::list<Sphericity>;
InnerCube() = default;
explicit InnerCube(double sphericity_in) : sphericity(sphericity_in) {}
double sphericity = std::numeric_limits<double>::signaling_NaN();
};

Expand Down
16 changes: 16 additions & 0 deletions src/Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ struct TimeDependentMapOptions {
};
using options = tmpl::list<InitialValues, AsymptoticVelocityOuterBoundary,
DecayTimescaleOuterBoundaryVelocity>;
ExpansionMapOptions() = default;
ExpansionMapOptions(std::array<double, 2> initial_values_in,
double outer_boundary_velocity_in,
double outer_boundary_decay_time_in)
: initial_values(initial_values_in),
outer_boundary_velocity(outer_boundary_velocity_in),
outer_boundary_decay_time(outer_boundary_decay_time_in) {}

std::array<double, 2> initial_values{
std::numeric_limits<double>::signaling_NaN(),
Expand All @@ -193,6 +200,11 @@ struct TimeDependentMapOptions {

using options = tmpl::list<InitialAngularVelocity>;

RotationMapOptions() = default;
explicit RotationMapOptions(
std::array<double, 3> initial_angular_velocity_in)
: initial_angular_velocity(initial_angular_velocity_in) {}

std::array<double, 3> initial_angular_velocity{};
};

Expand All @@ -213,6 +225,10 @@ struct TimeDependentMapOptions {
};

using options = tmpl::list<InitialValues>;
TranslationMapOptions() = default;
explicit TranslationMapOptions(
std::array<std::array<double, 3>, 3> initial_values_in)
: initial_values(initial_values_in) {}

std::array<std::array<double, 3>, 3> initial_values{};
};
Expand Down
18 changes: 18 additions & 0 deletions src/Domain/Creators/TimeDependentOptions/ShapeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
#include "Utilities/StdArrayHelpers.hpp"

namespace domain::creators::time_dependent_options {
KerrSchildFromBoyerLindquist::KerrSchildFromBoyerLindquist() = default;
KerrSchildFromBoyerLindquist::KerrSchildFromBoyerLindquist(
const double mass_in, const std::array<double, 3> spin_in)
: mass(mass_in), spin(spin_in) {}

YlmsFromFile::YlmsFromFile() = default;
YlmsFromFile::YlmsFromFile(std::string h5_filename_in,
std::vector<std::string> subfile_names_in,
double match_time_in,
std::optional<double> match_time_epsilon_in,
bool set_l1_coefs_to_zero_in, bool check_frame_in)
: h5_filename(std::move(h5_filename_in)),
subfile_names(std::move(subfile_names_in)),
match_time(match_time_in),
match_time_epsilon(match_time_epsilon_in),
set_l1_coefs_to_zero(set_l1_coefs_to_zero_in),
check_frame(check_frame_in) {}

template <bool IncludeTransitionEndsAtCube, domain::ObjectLabel Object>
std::pair<std::array<DataVector, 3>, std::array<DataVector, 4>>
initial_shape_and_size_funcs(
Expand Down
Loading
Loading