Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:47

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file corecel/data/ObserverPtr.device.hh
0007 //! \brief Interoperability with Thrust
0008 //---------------------------------------------------------------------------//
0009 #pragma once
0010 
0011 #include <thrust/device_ptr.h>
0012 
0013 #include "ObserverPtr.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 //! Create an observer pointer from a Thrust device pointer
0019 template<class T>
0020 ObserverPtr<T, MemSpace::device> make_observer(thrust::device_ptr<T> ptr)
0021 {
0022     return ObserverPtr<T, MemSpace::device>{ptr.get()};
0023 }
0024 
0025 //---------------------------------------------------------------------------//
0026 //! Create a Thrust device pointer from an Observer pointer
0027 template<class T>
0028 thrust::device_ptr<T> device_pointer_cast(ObserverPtr<T, MemSpace::device> ptr)
0029 {
0030     return thrust::device_ptr<T>{ptr.get()};
0031 }
0032 
0033 //---------------------------------------------------------------------------//
0034 }  // namespace celeritas