Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:54:12

0001 /*
0002  * SPDX-PackageName: "covfie, a part of the ACTS project"
0003  * SPDX-FileCopyrightText: 2022 CERN
0004  * SPDX-License-Identifier: MPL-2.0
0005  */
0006 
0007 #pragma once
0008 
0009 #include <memory>
0010 
0011 #include <hip/hip_runtime.h>
0012 
0013 #include <covfie/hip/error_check.hpp>
0014 
0015 namespace covfie::utility::hip {
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         hipErrorCheck(hipFree(p));
0027     }
0028 };
0029 
0030 template <typename T>
0031 using unique_device_ptr = std::unique_ptr<T, device_deleter<T>>;
0032 }