Skip to content

Commit

Permalink
Fix complier errors on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
AnhBe0 committed Jul 14, 2023
1 parent c74a6de commit 821e1b2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/raytracing/example_raytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ int main(int argc, char *argv[])
Kokkos::rand<GeneratorType, float>::draw(g, dz)};

float upsilon =
Kokkos::rand<GeneratorType, float>::draw(g, 2.f * M_PI);
Kokkos::rand<GeneratorType, float>::draw(g, 2.f * Kokkos::numbers::pi_v<float>);
float theta =
acos(1 - 2 * Kokkos::rand<GeneratorType, float>::draw(g));
ArborX::Experimental::Vector direction{
Expand Down
2 changes: 1 addition & 1 deletion src/ArborX_BruteForce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class BruteForce

template <typename ExecutionSpace, typename Predicates,
typename CallbackOrView, typename View, typename... Args>
std::enable_if_t<Kokkos::is_view<std::decay_t<View>>{}>
std::enable_if_t<Kokkos::is_view<std::decay_t<View>>::value>
query(ExecutionSpace const &space, Predicates const &predicates,
CallbackOrView &&callback_or_view, View &&view, Args &&...args) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/ArborX_LinearBVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class BasicBoundingVolumeHierarchy

template <typename ExecutionSpace, typename Predicates,
typename CallbackOrView, typename View, typename... Args>
std::enable_if_t<Kokkos::is_view<std::decay_t<View>>{}>
std::enable_if_t<Kokkos::is_view<std::decay_t<View>>::value>
query(ExecutionSpace const &space, Predicates const &predicates,
CallbackOrView &&callback_or_view, View &&view, Args &&...args) const
{
Expand Down
24 changes: 12 additions & 12 deletions src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ struct Iota

template <typename Tag, typename ExecutionSpace, typename Predicates,
typename OffsetView, typename OutView>
std::enable_if_t<std::is_same<Tag, SpatialPredicateTag>{} ||
std::is_same<Tag, Experimental::OrderedSpatialPredicateTag>{}>
std::enable_if_t<std::is_same_v<Tag, SpatialPredicateTag> ||
std::is_same_v<Tag, Experimental::OrderedSpatialPredicateTag>>
allocateAndInitializeStorage(Tag, ExecutionSpace const &space,
Predicates const &predicates, OffsetView &offset,
OutView &out, int buffer_size)
Expand All @@ -320,7 +320,7 @@ allocateAndInitializeStorage(Tag, ExecutionSpace const &space,

template <typename Tag, typename ExecutionSpace, typename Predicates,
typename OffsetView, typename OutView>
std::enable_if_t<std::is_same<Tag, NearestPredicateTag>{}>
std::enable_if_t<std::is_same_v<Tag, NearestPredicateTag>>
allocateAndInitializeStorage(Tag, ExecutionSpace const &space,
Predicates const &predicates, OffsetView &offset,
OutView &out, int /*buffer_size*/)
Expand All @@ -346,8 +346,8 @@ allocateAndInitializeStorage(Tag, ExecutionSpace const &space,
template <typename Tag, typename Tree, typename ExecutionSpace,
typename Predicates, typename OutputView, typename OffsetView,
typename Callback>
std::enable_if_t<!is_tagged_post_callback<Callback>{} &&
Kokkos::is_view<OutputView>{} && Kokkos::is_view<OffsetView>{}>
std::enable_if_t<!is_tagged_post_callback<Callback>::value &&
Kokkos::is_view<OutputView>::value && Kokkos::is_view<OffsetView>::value>
queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,
Predicates const &predicates, Callback const &callback,
OutputView &out, OffsetView &offset,
Expand Down Expand Up @@ -420,7 +420,7 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,

template <typename Tag, typename Tree, typename ExecutionSpace,
typename Predicates, typename Indices, typename Offset>
inline std::enable_if_t<Kokkos::is_view<Indices>{} && Kokkos::is_view<Offset>{}>
inline std::enable_if_t<Kokkos::is_view<Indices>::value && Kokkos::is_view<Offset>::value>
queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,
Predicates const &predicates, Indices &indices, Offset &offset,
Experimental::TraversalPolicy const &policy =
Expand All @@ -433,7 +433,7 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,
template <typename Tag, typename Tree, typename ExecutionSpace,
typename Predicates, typename OutputView, typename OffsetView,
typename Callback>
inline std::enable_if_t<is_tagged_post_callback<Callback>{}>
inline std::enable_if_t<is_tagged_post_callback<Callback>::value>
queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,
Predicates const &predicates, Callback const &callback,
OutputView &out, OffsetView &offset,
Expand All @@ -448,8 +448,8 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,
}

template <typename Callback, typename Predicates, typename OutputView>
std::enable_if_t<!Kokkos::is_view<Callback>{} &&
!is_tagged_post_callback<Callback>{}>
std::enable_if_t<!Kokkos::is_view<Callback>::value &&
!is_tagged_post_callback<Callback>::value>
check_valid_callback_if_first_argument_is_not_a_view(
Callback const &callback, Predicates const &predicates,
OutputView const &out)
Expand All @@ -458,8 +458,8 @@ check_valid_callback_if_first_argument_is_not_a_view(
}

template <typename Callback, typename Predicates, typename OutputView>
std::enable_if_t<!Kokkos::is_view<Callback>{} &&
is_tagged_post_callback<Callback>{}>
std::enable_if_t<!Kokkos::is_view<Callback>::value &&
is_tagged_post_callback<Callback>::value>
check_valid_callback_if_first_argument_is_not_a_view(Callback const &,
Predicates const &,
OutputView const &)
Expand All @@ -468,7 +468,7 @@ check_valid_callback_if_first_argument_is_not_a_view(Callback const &,
}

template <typename View, typename Predicates, typename OutputView>
std::enable_if_t<Kokkos::is_view<View>{}>
std::enable_if_t<Kokkos::is_view<View>::value>
check_valid_callback_if_first_argument_is_not_a_view(View const &,
Predicates const &,
OutputView const &)
Expand Down
1 change: 1 addition & 0 deletions test/tstQueryTreeManufacturedSolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <algorithm>
#include <iostream>
#include <numeric>
#include <random>
#include <tuple>

Expand Down
16 changes: 8 additions & 8 deletions test/tstRay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(intersects_box)
{ \
float t0; \
float t1; \
constexpr auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value; \
auto const inf = KokkosExt::ArithmeticTraits::infinity<float>::value; \
BOOST_TEST(!ArborX::Experimental::intersection(ray, box, t0, t1)); \
BOOST_TEST((t0 == inf || t1 == -inf)); \
} while (false)
Expand Down Expand Up @@ -250,10 +250,10 @@ BOOST_AUTO_TEST_CASE(ray_box_distance)
{
using ArborX::Box;
using ArborX::Experimental::Ray;

constexpr Box unit_box{{0, 0, 0}, {1, 1, 1}};
constexpr auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value;

// use const instead of constexpr because MSVC shows error(error:expression must have a constant value)
const Box unit_box{{0, 0, 0}, {1, 1, 1}};
auto const inf = KokkosExt::ArithmeticTraits::infinity<float>::value;
// clang-format off
// origin is within the box
BOOST_TEST(ArborX::Experimental::distance(Ray{{.5, .5, .5}, {1, 0, 0}}, unit_box) == 0.f);
Expand Down Expand Up @@ -347,7 +347,7 @@ BOOST_AUTO_TEST_CASE(overlap_distance_sphere,
{ \
float t0; \
float t1; \
constexpr auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value; \
const auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value; \
BOOST_TEST(!ArborX::Experimental::intersection(ray, sphere, t0, t1)); \
BOOST_TEST((t0 == inf && t1 == -inf)); \
} while (false)
Expand All @@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(ray_sphere_intersection,
using ArborX::Sphere;
using ArborX::Experimental::Ray;

constexpr Sphere unit_sphere{{0, 0, 0}, 1};
const Sphere unit_sphere{{0, 0, 0}, 1}; // use const instead of constexpr because MSVC shows error(error:expression must have a constant value)

auto const sqrtf_3 = std::sqrt(3.f);
auto const sqrtf_2 = std::sqrt(2.f);
Expand Down Expand Up @@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(intersects_triangle)
{ \
float t0; \
float t1; \
constexpr auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value; \
const auto inf = KokkosExt::ArithmeticTraits::infinity<float>::value; \
BOOST_TEST(!ArborX::Experimental::intersection(ray, triangle, t0, t1)); \
BOOST_TEST((t0 == inf && t1 == -inf)); \
} while (false)
Expand Down

0 comments on commit 821e1b2

Please sign in to comment.