44 #ifndef KOKKOS_EXPERIMENTAL_ERROR_REPORTER_HPP 
   45 #define KOKKOS_EXPERIMENTAL_ERROR_REPORTER_HPP 
   48 #include <Kokkos_Core.hpp> 
   49 #include <Kokkos_View.hpp> 
   53 namespace Experimental {
 
   55 template <
typename ReportType, 
typename DeviceType>
 
   60   typedef ReportType                                      report_type;
 
   61   typedef DeviceType                                      device_type;
 
   62   typedef typename device_type::execution_space           execution_space;
 
   64   ErrorReporter(
int max_results)
 
   65     : m_numReportsAttempted(
""),
 
   66       m_reports(
"", max_results),
 
   67       m_reporters(
"", max_results)
 
   72   int getCapacity()
 const { 
return m_reports.h_view.extent(0); }
 
   76   int getNumReportAttempts();
 
   78   void getReports(std::vector<int> &reporters_out, std::vector<report_type> &reports_out);
 
   84   void resize(
const size_t new_size);
 
   86   bool full() {
return (getNumReportAttempts() >= getCapacity()); }
 
   88   KOKKOS_INLINE_FUNCTION
 
   89   bool add_report(
int reporter_id, report_type report)
 const 
   91     int idx = Kokkos::atomic_fetch_add(&m_numReportsAttempted(), 1);
 
   93     if (idx >= 0 && (idx < static_cast<int>(m_reports.d_view.extent(0)))) {
 
   94       m_reporters.d_view(idx) = reporter_id;
 
   95       m_reports.d_view(idx)   = report;
 
  106   typedef Kokkos::DualView<report_type *, execution_space>    reports_dualview_t;
 
  108   typedef typename reports_dualview_t::host_mirror_space  host_mirror_space;
 
  110   reports_dualview_t                   m_reports;
 
  111   Kokkos::DualView<int *, execution_space> m_reporters;
 
  116 template <
typename ReportType, 
typename DeviceType>
 
  117 inline int ErrorReporter<ReportType, DeviceType>::getNumReports()
 
  121   if (num_reports > static_cast<int>(m_reports.h_view.extent(0))) {
 
  122     num_reports = m_reports.h_view.extent(0);
 
  127 template <
typename ReportType, 
typename DeviceType>
 
  128 inline int ErrorReporter<ReportType, DeviceType>::getNumReportAttempts()
 
  135 template <
typename ReportType, 
typename DeviceType>
 
  136 void ErrorReporter<ReportType, DeviceType>::getReports(std::vector<int> &reporters_out, std::vector<report_type> &reports_out)
 
  138   int num_reports = getNumReports();
 
  139   reporters_out.clear();
 
  140   reporters_out.reserve(num_reports);
 
  142   reports_out.reserve(num_reports);
 
  144   if (num_reports > 0) {
 
  145     m_reports.template sync<host_mirror_space>();
 
  146     m_reporters.template sync<host_mirror_space>();
 
  148     for (
int i = 0; i < num_reports; ++i) {
 
  149       reporters_out.push_back(m_reporters.h_view(i));
 
  150       reports_out.push_back(m_reports.h_view(i));
 
  155 template <
typename ReportType, 
typename DeviceType>
 
  156 void ErrorReporter<ReportType, DeviceType>::getReports(
 
  160   int num_reports = getNumReports();
 
  164   if (num_reports > 0) {
 
  165     m_reports.template sync<host_mirror_space>();
 
  166     m_reporters.template sync<host_mirror_space>();
 
  168     for (
int i = 0; i < num_reports; ++i) {
 
  169       reporters_out(i) = m_reporters.h_view(i);
 
  170       reports_out(i) = m_reports.h_view(i);
 
  175 template <
typename ReportType, 
typename DeviceType>
 
  176 void ErrorReporter<ReportType, DeviceType>::clear()
 
  180   m_reports.template modify<execution_space>();
 
  181   m_reporters.template modify<execution_space>();
 
  184 template <
typename ReportType, 
typename DeviceType>
 
  187   m_reports.resize(new_size);
 
  188   m_reporters.resize(new_size);
 
Declaration and definition of Kokkos::DualView. 
std::enable_if< std::is_same< typename Kokkos::View< T, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::View< T, P...>::array_layout, Kokkos::LayoutRight >::value >::type resize(Kokkos::View< T, P...> &v, const size_t n0=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n1=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n2=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n3=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n4=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n5=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n6=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n7=KOKKOS_IMPL_CTOR_DEFAULT_ARG)
Resize a view with copying old data to new data at the corresponding indices. 
void deep_copy(const View< DT, DP...> &dst, typename ViewTraits< DT, DP...>::const_value_type &value, typename std::enable_if< std::is_same< typename ViewTraits< DT, DP...>::specialize, void >::value >::type *=0)
Deep copy a value from Host memory into a view. 
View to an array of data. 
void resize(DynRankView< T, P...> &v, const size_t n0=KOKKOS_INVALID_INDEX, const size_t n1=KOKKOS_INVALID_INDEX, const size_t n2=KOKKOS_INVALID_INDEX, const size_t n3=KOKKOS_INVALID_INDEX, const size_t n4=KOKKOS_INVALID_INDEX, const size_t n5=KOKKOS_INVALID_INDEX, const size_t n6=KOKKOS_INVALID_INDEX, const size_t n7=KOKKOS_INVALID_INDEX)
Resize a view with copying old data to new data at the corresponding indices. 
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > HostMirror
Compatible HostMirror view.