24 #include <type_traits> 
   26 #include <kvikio/error.hpp> 
   27 #include <kvikio/shim/cuda.hpp> 
   31 std::size_t get_page_size();
 
   33 [[nodiscard]] off_t convert_size2off(std::size_t x);
 
   35 [[nodiscard]] ssize_t convert_size2ssize(std::size_t x);
 
   37 [[nodiscard]] CUdeviceptr convert_void2deviceptr(
void const* devPtr);
 
   42 template <
typename T, std::enable_if_t<std::is_
integral_v<T>>* = 
nullptr>
 
   45   if constexpr (std::numeric_limits<T>::max() > std::numeric_limits<std::int64_t>::max()) {
 
   46     KVIKIO_EXPECT(value <= std::numeric_limits<std::int64_t>::max(),
 
   47                   "convert_to_64bit(x): x too large to fit std::int64_t",
 
   50   return std::int64_t(value);
 
   57 [[nodiscard]] 
inline std::uint64_t 
convert_to_64bit(std::uint64_t value) { 
return value; }
 
   62 template <
typename T, std::enable_if_t<std::is_
floating_po
int_v<T>>* = 
nullptr>
 
   76 #ifdef KVIKIO_CUDA_FOUND 
  151 std::tuple<void*, std::size_t, std::size_t> get_alloc_info(
void const* devPtr,
 
  152                                                            CUcontext* ctx = 
nullptr);
 
  165 template <
typename T>
 
  168   std::promise<std::decay_t<T>> p;
 
  169   auto fut = p.get_future();
 
  170   p.set_value(std::forward<T>(t));
 
  185 template <
typename T>
 
  189                 "The future object does not refer to a valid shared state.",
 
  190                 std::invalid_argument);
 
  191   return future.wait_for(std::chrono::seconds(0)) != std::future_status::timeout;
 
Push CUDA context on creation and pop it on destruction.
 
#define KVIKIO_EXPECT(...)
Macro for checking pre-conditions or conditions that throws an exception when a condition is violated...
 
CUcontext get_context_from_pointer(void const *devPtr)
Return a CUDA context that can be used with the given device pointer.
 
constexpr bool is_host_memory(void const *ptr)
Check if ptr points to host memory (as opposed to device memory)
 
std::int64_t convert_to_64bit(T value)
Help function to convert value to 64 bit signed integer.
 
bool current_context_can_access_pointer(CUdeviceptr dev_ptr)
Check if the current CUDA context can access the given device pointer.
 
bool is_future_done(T const &future)
Check the status of the future object. True indicates that the result is available in the future's sh...
 
KVIKIO_EXPORT CUcontext get_primary_cuda_context(int ordinal)
Given a device ordinal, return the primary context of the device.
 
std::future< std::decay_t< T > > make_ready_future(T &&t)
Create a shared state in a future object that is immediately ready.
 
std::optional< CUcontext > get_context_associated_pointer(CUdeviceptr dev_ptr)
Return the CUDA context associated the given device pointer, if any.
 
int get_device_ordinal_from_pointer(CUdeviceptr dev_ptr)
Return the device owning the pointer.