Kokkos Node API and Local Linear Algebra Kernels Version of the Day
Kokkos_CUDANodeMemoryModel.hpp
00001 #ifndef KOKKOS_CUDA_NODE_MEMORY_MODEL_HPP_
00002 #define KOKKOS_CUDA_NODE_MEMORY_MODEL_HPP_
00003 
00004 #include "Kokkos_NodeAPIConfigDefs.hpp"
00005 #include <Teuchos_RCP.hpp>
00006 
00007 // forward declarations of Teuchos classes
00008 namespace std {
00009   template <typename CharT> class char_traits;
00010 }
00011 namespace Teuchos {
00012   class ParameterList;
00013   template <typename T> class ArrayRCP;
00014   template <typename T> class ArrayView;
00015   template <typename T> class RCP;
00016   template <typename CharT, typename Traits> class basic_FancyOStream;
00017   typedef basic_FancyOStream<char, std::char_traits<char> > FancyOStream;
00018 }
00019 
00020 namespace Kokkos {
00021 
00022   using Teuchos::ArrayRCP;
00023   using Teuchos::ArrayView;
00024   using Teuchos::RCP;
00025 
00029   class CUDANodeMemoryModel {
00030     public:
00032       static const bool isHostNode = false;
00033 
00035 
00037       CUDANodeMemoryModel();
00038 
00040 
00042 
00056       template <class T> inline
00057       ArrayRCP<T> allocBuffer(size_t size);
00058 
00070       template <class T> inline
00071       void copyFromBuffer(size_t size, const ArrayRCP<const T> &buffSrc, const ArrayView<T> &hostDest);
00072 
00084       template <class T> inline
00085       void copyToBuffer(size_t size, const ArrayView<const T> &hostSrc, const ArrayRCP<T> &buffDest);
00086 
00095       template <class T> inline
00096       void copyBuffers(size_t size, const ArrayRCP<const T> &buffSrc, const ArrayRCP<T> &buffDest);
00097 
00103       template <class T> inline
00104       ArrayRCP<const T> viewBuffer(size_t size, ArrayRCP<const T> buff);
00105 
00119       template <class T> inline
00120       ArrayRCP<T> viewBufferNonConst(ReadWriteOption rw, size_t size, const ArrayRCP<T> &buff);
00121 
00122       inline void readyBuffers(ArrayView<ArrayRCP<const char> > buffers, ArrayView<ArrayRCP<char> > ncBuffers);
00123 
00125 
00127 
00129       void printStatistics(const RCP< Teuchos::FancyOStream > &os) const;
00130       
00132       void clearStatistics();
00133 
00135 
00136     public:
00137       size_t allocSize_;
00138       size_t numCopiesD2H_, numCopiesH2D_, numCopiesD2D_;
00139       size_t bytesCopiedD2H_, bytesCopiedH2D_, bytesCopiedD2D_;
00140   };
00141 
00142 } // end of namespace Kokkos
00143 
00144 #ifndef KOKKOS_NO_INCLUDE_INSTANTIATIONS
00145 #include "Kokkos_CUDANodeMemoryModelImpl.hpp"
00146 #endif
00147 
00148 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends