durations.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <limits>
20 
21 #include <cuda/std/chrono>
22 
23 namespace cudf {
24 
35 using duration_D = cuda::std::chrono::duration<int32_t, cuda::std::chrono::days::period>;
39 using duration_s = cuda::std::chrono::duration<int64_t, cuda::std::chrono::seconds::period>;
43 using duration_ms = cuda::std::chrono::duration<int64_t, cuda::std::chrono::milliseconds::period>;
47 using duration_us = cuda::std::chrono::duration<int64_t, cuda::std::chrono::microseconds::period>;
51 using duration_ns = cuda::std::chrono::duration<int64_t, cuda::std::chrono::nanoseconds::period>;
52 
53 static_assert(sizeof(duration_D) == sizeof(typename duration_D::rep), "");
54 static_assert(sizeof(duration_s) == sizeof(typename duration_s::rep), "");
55 static_assert(sizeof(duration_ms) == sizeof(typename duration_ms::rep), "");
56 static_assert(sizeof(duration_us) == sizeof(typename duration_us::rep), "");
57 static_assert(sizeof(duration_ns) == sizeof(typename duration_ns::rep), "");
58  // end of group
60 } // namespace cudf
61 
62 namespace std {
68 #define DURATION_LIMITS(TypeName) \
69  template <> \
70  struct numeric_limits<TypeName> { \
71  static constexpr TypeName max() noexcept { return TypeName::max(); } \
72  static constexpr TypeName lowest() noexcept \
73  { \
74  return TypeName(std::numeric_limits<typename TypeName::rep>::lowest()); \
75  } \
76  static constexpr TypeName min() noexcept { return TypeName::min(); } \
77  }
78 
84 
85 #undef DURATION_LIMITS
86 
87 } // namespace std
cudf::duration_s
cuda::std::chrono::duration< int64_t, cuda::std::chrono::seconds::period > duration_s
Type alias representing an int64_t duration of seconds.
Definition: durations.hpp:39
cudf::duration_D
cuda::std::chrono::duration< int32_t, cuda::std::chrono::days::period > duration_D
Type alias representing an int32_t duration of days.
Definition: durations.hpp:35
DURATION_LIMITS
#define DURATION_LIMITS(TypeName)
Specialization of std::numeric_limits for cudf::detail::duration.
Definition: durations.hpp:68
cudf::duration_ns
cuda::std::chrono::duration< int64_t, cuda::std::chrono::nanoseconds::period > duration_ns
Type alias representing an int64_t duration of nanoseconds.
Definition: durations.hpp:51
cudf
cuDF interfaces
Definition: aggregation.hpp:34
cudf::duration_us
cuda::std::chrono::duration< int64_t, cuda::std::chrono::microseconds::period > duration_us
Type alias representing an int64_t duration of microseconds.
Definition: durations.hpp:47
cudf::duration_ms
cuda::std::chrono::duration< int64_t, cuda::std::chrono::milliseconds::period > duration_ms
Type alias representing an int64_t duration of milliseconds.
Definition: durations.hpp:43