diff --git a/examples/Makefile.inc b/examples/Makefile.inc index 70e1173e..979192cc 100644 --- a/examples/Makefile.inc +++ b/examples/Makefile.inc @@ -67,11 +67,11 @@ DEFINES = -DGIT_SHA1="\"$(shell git rev-parse HEAD)\"" # ARCH = -m64 # endif -NVCCFLAGS += -std=c++14 +NVCCFLAGS += -std=c++17 NVCCFLAGS += $(SM_TARGETS) NVCCFLAGS += --expt-extended-lambda --expt-relaxed-constexpr --use_fast_math --ptxas-options -v --relocatable-device-code true -CXXFLAGS += -std=c++14 +CXXFLAGS += -std=c++17 CXXFLAGS += -Wall CXXFLAGS += -Wno-unused-local-typedefs -Wno-strict-aliasing -Wno-unused-function -Wno-format-security diff --git a/gunrock/graph/graph.hxx b/gunrock/graph/graph.hxx index d42c0121..11cb218b 100644 --- a/gunrock/graph/graph.hxx +++ b/gunrock/graph/graph.hxx @@ -135,7 +135,7 @@ class graph_t : public graph_view_t... { } __host__ __device__ __forceinline__ edge_type - get_starting_edge(vertex_type const& v) const { + get_starting_edge(vertex_type const& v) const override { return first_view_t::get_starting_edge(v); } diff --git a/gunrock/util/type_limits.hxx b/gunrock/util/type_limits.hxx index c78b7435..85365454 100644 --- a/gunrock/util/type_limits.hxx +++ b/gunrock/util/type_limits.hxx @@ -13,36 +13,40 @@ namespace gunrock { -template +template struct numeric_limits : std::numeric_limits {}; // Numeric Limits (additional support) for invalid() values. -template <> -struct numeric_limits : std::numeric_limits { - // XXX: This doesn't seem like the right thing to do for a signed integral - // type. It implies, -1 is an invalid value. Integers do not have a notion of - // invalid values. - constexpr static int invalid() { return ~((int)0); } -}; - -template <> -struct numeric_limits : std::numeric_limits { - constexpr static float invalid() { - return std::numeric_limits::quiet_NaN(); +template +struct numeric_limits< + type_t, + typename std::enable_if_t::value && + std::is_signed::value>> + : std::numeric_limits { + constexpr static type_t invalid() { + return std::integral_constant::value; } }; -template <> -struct numeric_limits : std::numeric_limits { - constexpr static double invalid() { - return std::numeric_limits::quiet_NaN(); +template +struct numeric_limits< + type_t, + typename std::enable_if_t::value && + std::is_unsigned::value>> + : std::numeric_limits { + constexpr static type_t invalid() { + return std::integral_constant::max()>::value; } }; -template <> -struct numeric_limits : std::numeric_limits { - constexpr static long double invalid() { - return std::numeric_limits::quiet_NaN(); +template +struct numeric_limits< + type_t, + typename std::enable_if_t::value>> + : std::numeric_limits { + constexpr static type_t invalid() { + return std::numeric_limits::quiet_NaN(); } }; @@ -52,17 +56,16 @@ namespace gunrock { namespace util { namespace limits { -// XXX: Revisit later... -template -__host__ __device__ __forceinline__ bool is_valid(numeric_t const& value) { - static_assert(std::is_arithmetic_v); - return !isnan(value); -} - -template -__host__ __device__ __forceinline__ bool is_invalid(numeric_t const& value) { - static_assert(std::is_arithmetic_v); - return isnan(value); +template +__host__ __device__ __forceinline__ bool is_valid(type_t value) { + static_assert((std::is_integral::value || + std::is_floating_point::value), + "type_t must be an arithmetic type."); + if constexpr (std::is_integral::value) + return (value != gunrock::numeric_limits::invalid()); + else + // XXX: test this on device + return (bool)!isnan(value); } } // namespace limits diff --git a/gunrock/util/type_traits.hxx b/gunrock/util/type_traits.hxx index 01d1cde2..0bf5f9a1 100644 --- a/gunrock/util/type_traits.hxx +++ b/gunrock/util/type_traits.hxx @@ -4,6 +4,7 @@ namespace std { +#if __cplusplus == 201402L // Supported in C++ 17 (https://en.cppreference.com/w/cpp/types/disjunction) template struct disjunction : std::false_type {}; @@ -25,4 +26,5 @@ constexpr bool is_arithmetic_v = is_arithmetic::value; // (https://en.cppreference.com/w/cpp/types/is_floating_point) template constexpr bool is_floating_point_v = is_floating_point::value; +#endif } // namespace std \ No newline at end of file diff --git a/unittests/Makefile.inc b/unittests/Makefile.inc index 70e1173e..979192cc 100644 --- a/unittests/Makefile.inc +++ b/unittests/Makefile.inc @@ -67,11 +67,11 @@ DEFINES = -DGIT_SHA1="\"$(shell git rev-parse HEAD)\"" # ARCH = -m64 # endif -NVCCFLAGS += -std=c++14 +NVCCFLAGS += -std=c++17 NVCCFLAGS += $(SM_TARGETS) NVCCFLAGS += --expt-extended-lambda --expt-relaxed-constexpr --use_fast_math --ptxas-options -v --relocatable-device-code true -CXXFLAGS += -std=c++14 +CXXFLAGS += -std=c++17 CXXFLAGS += -Wall CXXFLAGS += -Wno-unused-local-typedefs -Wno-strict-aliasing -Wno-unused-function -Wno-format-security diff --git a/unittests/type_limits/test_type_limits.cu b/unittests/type_limits/test_type_limits.cu index 43481113..ab268e4c 100644 --- a/unittests/type_limits/test_type_limits.cu +++ b/unittests/type_limits/test_type_limits.cu @@ -4,9 +4,10 @@ #include void test_type_limits() { - float i = gunrock::numeric_limits::invalid(); - std::cout << i << " is valid? " << std::boolalpha - << gunrock::util::limits::is_valid(i) << std::endl; + using type_t = short unsigned int; + type_t i = gunrock::numeric_limits::invalid(); + std::cout << "i = " << i << " (is valid? " << std::boolalpha + << gunrock::util::limits::is_valid(i) << ")" << std::endl; } int main(int argc, char** argv) {