Skip to content

Commit

Permalink
Merge pull request #64 from lanl/mauneyc/fix/span_test_constexpr
Browse files Browse the repository at this point in the history
Fix non-constexpr math function
  • Loading branch information
Yurlungur authored Nov 14, 2024
2 parents 0e9b649 + eb0b423 commit a983eec
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/test_span.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ports-of-call/span.hpp"
#include "ports-of-call/portability.hpp"
#include <type_traits>
#include "ports-of-call/span.hpp"
#include <cmath>
#include <type_traits>

// ========================================================================================
// © (or copyright) 2019-2024. Triad National Security, LLC. All rights
Expand Down Expand Up @@ -564,19 +564,17 @@ TEST_CASE("span portability", "[PortsOfCall::span]") {
constexpr const std::size_t Nb = N * sizeof(Real);
constexpr const Real tol = 1.0E-8;

constexpr const Real pi = std::acos(-1);
constexpr const Real pi = M_PI;

constexpr Real d_gp = 2. * pi / static_cast<Real>(N);

std::vector<Real> h_gp(N);
for(auto i = 0; i < N; ++i)
{
for (auto i = 0; i < N; ++i) {
h_gp[i] = -pi + static_cast<Real>(i) * d_gp;
}

Real *p_a = (Real *)PORTABLE_MALLOC(Nb);

Real *p_a = (Real*) PORTABLE_MALLOC(Nb);

// device span, host span
span d_s(p_a, N);
span h_s(h_gp);
Expand All @@ -586,11 +584,13 @@ TEST_CASE("span portability", "[PortsOfCall::span]") {

// integrate cos x dx over [-pi,pi]
Real res_sum{0.0};
portableReduce( "integrate", 0, N, PORTABLE_LAMBDA(const int i, Real& rsum){ rsum += (std::cos(d_s[i])*d_gp) ;}, res_sum);
portableReduce(
"integrate", 0, N,
PORTABLE_LAMBDA(const int i, Real &rsum) { rsum += (std::cos(d_s[i]) * d_gp); },
res_sum);

// require sum < tol
REQUIRE(std::abs(res_sum) < tol);

REQUIRE(std::abs(res_sum) < tol);

PORTABLE_FREE(p_a);
}
Expand Down

0 comments on commit a983eec

Please sign in to comment.