ATLAS Offline Software
Public Member Functions | Private Types | Private Attributes | Friends | List of all members
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true > Class Template Reference

#include <Helpers.h>

Collaboration diagram for CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >:

Public Member Functions

CUDA_HOS_DEV indexer size () const
 
CUDA_HOS_DEV T & operator[] (const indexer i)
 
CUDA_HOS_DEV const T & operator[] (const indexer i) const
 
void clear ()
 
void resize (const indexer new_size)
 
 SimpleContainer ()
 
 SimpleContainer (const indexer sz)
 
 SimpleContainer (T *other_array, const indexer sz)
 
 SimpleContainer (const SimpleContainer &other)
 
 SimpleContainer (SimpleContainer &&other)
 
template<class other_indexer , class other_context , bool other_hold>
 SimpleContainer (const SimpleContainer< T, other_indexer, other_context, other_hold > &other)
 
template<class other_indexer , class other_context >
 SimpleContainer (SimpleContainer< T, other_indexer, other_context, true > &&other)
 
SimpleContaineroperator= (const SimpleContainer &other)
 
SimpleContaineroperator= (SimpleContainer &&other)
 
template<class other_indexer , class other_context , bool other_hold>
SimpleContaineroperator= (const SimpleContainer< T, other_indexer, other_context, other_hold > &other)
 
template<class other_indexer , class other_context >
SimpleContaineroperator= (SimpleContainer< T, other_indexer, other_context, true > &&other)
 
 ~SimpleContainer ()
 
CUDA_HOS_DEV operator const T * () const
 
CUDA_HOS_DEV operator T* ()
 
template<class stream , class str = std::basic_string<typename stream::char_type>>
void textual_output (stream &s, const str &separator=" ") const
 
template<class stream >
void textual_input (stream &s)
 
template<class stream >
void binary_output (stream &s) const
 
template<class stream >
void binary_input (stream &s)
 

Private Types

using Manager = MemoryManagement< T, indexer >
 

Private Attributes

T * m_array
 
indexer m_size
 

Friends

template<class a , class b , class c , bool d>
class SimpleContainer
 

Detailed Description

template<class T, class indexer, class Context>
class CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >

Definition at line 700 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

Member Typedef Documentation

◆ Manager

template<class T , class indexer , class Context >
using CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::Manager = MemoryManagement<T, indexer>
private

Definition at line 708 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

Constructor & Destructor Documentation

◆ SimpleContainer() [1/7]

template<class T , class indexer , class Context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( )
inline

Definition at line 749 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

749  : m_array(nullptr), m_size(0)
750  {
751  }

◆ SimpleContainer() [2/7]

template<class T , class indexer , class Context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( const indexer  sz)
inline

Definition at line 753 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

754  {
755  m_array = Manager::template allocate<Context>(sz);
756  m_size = sz;
757  }

◆ SimpleContainer() [3/7]

template<class T , class indexer , class Context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( T *  other_array,
const indexer  sz 
)
inline
Warning
We assume the pointer is in a valid memory location!

Definition at line 762 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

763  {
764  m_array = Manager::template allocate<Context>(sz);
765  Manager::template copy<Context, Context>(m_array, other_array, sz);
766  m_size = sz;
767  }

◆ SimpleContainer() [4/7]

template<class T , class indexer , class Context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( const SimpleContainer< T, indexer, Context, true > &  other)
inline

Definition at line 769 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

770  {
771  m_size = other.m_size;
772  m_array = Manager::template allocate<Context>(m_size);
773  Manager::template copy<Context, Context>(m_array, other.m_array, m_size);
774  }

◆ SimpleContainer() [5/7]

template<class T , class indexer , class Context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( SimpleContainer< T, indexer, Context, true > &&  other)
inline

Definition at line 776 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

777  {
778  m_size = other.m_size;
779  m_array = nullptr;
780  Manager::template move<Context, Context>(m_array, other.m_array, m_size);
781  other.m_size = 0;
782  }

◆ SimpleContainer() [6/7]

template<class T , class indexer , class Context >
template<class other_indexer , class other_context , bool other_hold>
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( const SimpleContainer< T, other_indexer, other_context, other_hold > &  other)
inline

Definition at line 785 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

786  {
787  m_size = other.m_size;
788  m_array = Manager::template allocate<Context>(m_size);
789  Manager::template copy<Context, other_context>(m_array, other.m_array, m_size);
790  }

◆ SimpleContainer() [7/7]

template<class T , class indexer , class Context >
template<class other_indexer , class other_context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::SimpleContainer ( SimpleContainer< T, other_indexer, other_context, true > &&  other)
inline

Definition at line 793 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

794  {
795  m_size = other.m_size;
796  m_array = nullptr;
797  Manager::template move<Context, other_context>(m_array, other.m_array, m_size);
798  other.m_size = 0;
799  }

◆ ~SimpleContainer()

template<class T , class indexer , class Context >
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::~SimpleContainer ( )
inline

Definition at line 850 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

851  {
852  Manager::template deallocate<Context>(m_array);
853  m_size = 0;
854  }

Member Function Documentation

◆ binary_input()

template<class T , class indexer , class Context >
template<class stream >
void CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::binary_input ( stream &  s)
inline

Definition at line 933 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

934  {
936  {
937  indexer new_size;
938  s.read((char *) &new_size, sizeof(indexer));
939  if (s.fail())
940  {
941  //Throw errors, perhaps? Don't know if we can/should use exceptions...
942  std::cerr << "FAILED READING " << this << "!" << std::endl;
943  new_size = 0;
944  }
945  resize(new_size);
946  for (indexer i = 0; i < m_size; ++i)
947  {
948  s.read((char *) (m_array + i), sizeof(T));
949  }
950  }
951  else
952  {
953  SimpleContainer<T, indexer, MemoryContext::CPU, true> other;
954  other.binary_input(s);
955  (*this) = other;
956  }
957  }

◆ binary_output()

template<class T , class indexer , class Context >
template<class stream >
void CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::binary_output ( stream &  s) const
inline

Definition at line 915 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

916  {
918  {
919  s.write((char *) &m_size, sizeof(indexer));
920  for (indexer i = 0; i < m_size; ++i)
921  {
922  s.write((char *) (m_array + i), sizeof(T));
923  }
924  }
925  else
926  {
927  SimpleContainer<T, indexer, MemoryContext::CPU, true> other(*this);
928  other.binary_output(s);
929  }
930  }

◆ clear()

template<class T , class indexer , class Context >
void CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::clear ( )
inline

Definition at line 727 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

728  {
730  m_size = 0;
731  }

◆ operator const T *()

template<class T , class indexer , class Context >
CUDA_HOS_DEV CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator const T * ( ) const
inline

Definition at line 856 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

857  {
858  return m_array;
859  }

◆ operator T*()

template<class T , class indexer , class Context >
CUDA_HOS_DEV CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator T* ( )
inline

Definition at line 861 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

862  {
863  return m_array;
864  }

◆ operator=() [1/4]

template<class T , class indexer , class Context >
SimpleContainer& CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator= ( const SimpleContainer< T, indexer, Context, true > &  other)
inline

Definition at line 801 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

802  {
803  if (this == &other)
804  {
805  return (*this);
806  }
807  else
808  {
809  resize(other.size());
810  Manager::template copy<Context, Context>(m_array, other.m_array, m_size);
811  return (*this);
812  }
813  }

◆ operator=() [2/4]

template<class T , class indexer , class Context >
template<class other_indexer , class other_context , bool other_hold>
SimpleContainer& CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator= ( const SimpleContainer< T, other_indexer, other_context, other_hold > &  other)
inline

Definition at line 833 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

834  {
835  resize(other.m_size);
836  Manager::template copy<Context, other_context>(m_array, other.m_array, m_size);
837  return (*this);
838  }

◆ operator=() [3/4]

template<class T , class indexer , class Context >
SimpleContainer& CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator= ( SimpleContainer< T, indexer, Context, true > &&  other)
inline

Definition at line 815 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

816  {
817  if (this == &other)
818  {
819  return (*this);
820  }
821  else
822  {
823  clear();
824  Manager::template move<Context, Context>(m_array, other.m_array, other.size());
825  m_size = other.m_size;
826  other.m_size = 0;
827  return (*this);
828  }
829  }

◆ operator=() [4/4]

template<class T , class indexer , class Context >
template<class other_indexer , class other_context >
SimpleContainer& CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator= ( SimpleContainer< T, other_indexer, other_context, true > &&  other)
inline

Definition at line 841 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

842  {
843  clear();
844  Manager::template move<Context, other_context>(m_array, other.m_array, other.m_size);
845  m_size = other.m_size;
846  other.m_size = 0;
847  return (*this);
848  }

◆ operator[]() [1/2]

template<class T , class indexer , class Context >
CUDA_HOS_DEV T& CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator[] ( const indexer  i)
inline

Definition at line 717 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

718  {
719  return m_array[i];
720  }

◆ operator[]() [2/2]

template<class T , class indexer , class Context >
CUDA_HOS_DEV const T& CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::operator[] ( const indexer  i) const
inline

Definition at line 722 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

723  {
724  return m_array[i];
725  }

◆ resize()

template<class T , class indexer , class Context >
void CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::resize ( const indexer  new_size)
inline

Definition at line 733 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

734  {
735  if (new_size == 0)
736  {
737  clear();
738  }
739  else if (new_size != m_size)
740  {
741  T * temp = m_array;
742  m_array = Manager::template allocate<Context>(new_size);
743  Manager::template copy<Context, Context>(m_array, temp, (m_size < new_size ? m_size : new_size));
744  Manager::template deallocate<Context>(temp);
745  m_size = new_size;
746  }
747  }

◆ size()

template<class T , class indexer , class Context >
CUDA_HOS_DEV indexer CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::size ( ) const
inline

Definition at line 712 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

713  {
714  return m_size;
715  }

◆ textual_input()

template<class T , class indexer , class Context >
template<class stream >
void CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::textual_input ( stream &  s)
inline

Definition at line 886 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

887  {
889  {
890  indexer new_size;
891  s >> new_size >> std::ws;
892  if (s.fail())
893  {
894  //Throw errors, perhaps? Don't know if we can/should use exceptions...
895  std::cerr << "FAILED READING " << this << "!" << std::endl;
896  new_size = 0;
897  }
898  resize(new_size);
899  for (indexer i = 0; i < m_size - 1; ++i)
900  {
901  s >> m_array[i];
902  s >> std::ws;
903  }
904  s >> m_array[m_size - 1];
905  }
906  else
907  {
908  SimpleContainer<T, indexer, MemoryContext::CPU, true> other;
909  other.textual_input(s);
910  (*this) = other;
911  }
912  }

◆ textual_output()

template<class T , class indexer , class Context >
template<class stream , class str = std::basic_string<typename stream::char_type>>
void CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::textual_output ( stream &  s,
const str separator = " " 
) const
inline

Definition at line 867 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

868  {
870  {
871  s << m_size << separator;
872  for (indexer i = 0; i < m_size - 1; ++i)
873  {
874  s << m_array[i] << separator;
875  }
876  s << m_array[m_size - 1];
877  }
878  else
879  {
880  SimpleContainer<T, indexer, MemoryContext::CPU, true> other(*this);
881  other.textual_output(s, separator);
882  }
883  }

Friends And Related Function Documentation

◆ SimpleContainer

template<class T , class indexer , class Context >
template<class a , class b , class c , bool d>
friend class SimpleContainer
friend

Definition at line 706 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

Member Data Documentation

◆ m_array

template<class T , class indexer , class Context >
T* CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::m_array
private

Definition at line 703 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

◆ m_size

template<class T , class indexer , class Context >
indexer CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::m_size
private

Definition at line 704 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.


The documentation for this class was generated from the following file:
temp
Definition: JetEventDict.h:21
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
fitman.sz
sz
Definition: fitman.py:527
taskman.template
dictionary template
Definition: taskman.py:317
athena.value
value
Definition: athena.py:122
CaloRecGPU::CUDA_Helpers::deallocate
void deallocate(void *address)
Deallocates address in GPU memory.
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::clear
void clear()
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:727
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::m_array
T * m_array
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:702
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::m_size
indexer m_size
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:704
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
CaloRecGPU::Helpers::SimpleContainer< T, indexer, Context, true >::resize
void resize(const indexer new_size)
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:733