Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file corecel/sys/detail/TraceCounterImpl.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <cstdint>
0010 
0011 #include "corecel/Config.hh"
0012 
0013 #include "corecel/Assert.hh"
0014 
0015 namespace celeritas
0016 {
0017 namespace detail
0018 {
0019 //---------------------------------------------------------------------------//
0020 template<class T>
0021 void trace_counter_impl(char const* name, T value);
0022 
0023 #if CELERITAS_USE_PERFETTO || CELERITAS_USE_CUDA
0024 
0025 // On some platform size_t is equivalent to uint64_t, which would cause
0026 // duplicate template instantiation
0027 template<class T>
0028 using trace_counter_type = std::conditional_t<
0029     std::is_same_v<T, std::size_t>,
0030     std::conditional_t<sizeof(std::size_t) == sizeof(std::uint64_t),
0031                        std::uint64_t,
0032                        std::uint32_t>,
0033     T>;
0034 
0035 // Explicit instantiations
0036 extern template void trace_counter_impl(char const*, double);
0037 extern template void trace_counter_impl(char const*, float);
0038 extern template void trace_counter_impl(char const*, std::int32_t);
0039 extern template void trace_counter_impl(char const*, std::int64_t);
0040 extern template void trace_counter_impl(char const*, std::uint32_t);
0041 extern template void trace_counter_impl(char const*, std::uint64_t);
0042 
0043 #else
0044 
0045 template<class T>
0046 using trace_counter_type = T;
0047 
0048 template<class T>
0049 inline void trace_counter_impl(char const*, T)
0050 {
0051     // CUDA/PERFETTO are disabled
0052     CELER_ASSERT_UNREACHABLE();
0053 }
0054 
0055 #endif
0056 
0057 //---------------------------------------------------------------------------//
0058 }  // namespace detail
0059 }  // namespace celeritas