Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //---------------------------------*-CUDA-*----------------------------------//
0002 // Copyright 2021-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/Filler.device.t.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "Filler.hh"
0011 
0012 #include <thrust/device_malloc.h>
0013 #include <thrust/device_ptr.h>
0014 #include <thrust/execution_policy.h>
0015 #include <thrust/fill.h>
0016 
0017 #include "corecel/DeviceRuntimeApi.hh"  // IWYU pragma: keep
0018 
0019 #include "corecel/sys/Thrust.device.hh"  // IWYU pragma: keep
0020 
0021 namespace celeritas
0022 {
0023 //---------------------------------------------------------------------------//
0024 template<class T, MemSpace M>
0025 void Filler<T, M>::fill_device_impl(Span<T> data) const
0026 {
0027     if (stream_)
0028     {
0029         thrust::fill_n(thrust_execute_on(stream_),
0030                        thrust::device_pointer_cast<T>(data.data()),
0031                        data.size(),
0032                        value_);
0033     }
0034     else
0035     {
0036         thrust::fill_n(thrust_execute(),
0037                        thrust::device_pointer_cast<T>(data.data()),
0038                        data.size(),
0039                        value_);
0040     }
0041     CELER_DEVICE_API_CALL(PeekAtLastError());
0042 }
0043 
0044 //---------------------------------------------------------------------------//
0045 }  // namespace celeritas