File indexing completed on 2025-09-17 08:54:12
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010
0011 #include <cuda_runtime.h>
0012
0013 #include <covfie/cuda/error_check.hpp>
0014
0015 namespace covfie::utility::cuda {
0016 template <typename T>
0017 struct device_deleter {
0018 static_assert(
0019 std::is_trivially_destructible_v<std::remove_extent_t<T>>,
0020 "Allocation pointer type must be trivially destructible."
0021 );
0022
0023 public:
0024 void operator()(void * p) const
0025 {
0026 cudaErrorCheck(cudaFree(p));
0027 }
0028 };
0029
0030 template <typename T>
0031 using unique_device_ptr = std::unique_ptr<T, device_deleter<T>>;
0032 }