/usr/include/trilinos/Kokkos_NodeHelpers.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #ifndef KOKKOS_NODE_HELPERS_HPP_
#define KOKKOS_NODE_HELPERS_HPP_
#include <Kokkos_NodeAPIConfigDefs.hpp>
#include "Teuchos_Array.hpp"
#include "Teuchos_ArrayRCP.hpp"
namespace Kokkos {
/*! A class to assist in readying buffers via the Node::readyBuffer() method. */
template <class Node>
class ReadyBufferHelper {
public:
/*! The node via which buffers are being readied. */
ReadyBufferHelper(Teuchos::RCP<Node> node);
/*! Destructor. */
virtual ~ReadyBufferHelper();
/*! Begin the ready-buffer transaction. */
void begin();
/*! Add a const buffer. */
template <class T>
const T* addConstBuffer(Teuchos::ArrayRCP<const T> buff);
/*! Add a non-const buffer. */
template <class T>
T* addNonConstBuffer(Teuchos::ArrayRCP<T> buff);
/*! End the ready-buffer transaction. */
void end();
protected:
Teuchos::RCP<Node> node_;
Teuchos::Array< Teuchos::ArrayRCP<const char> > cbufs_;
Teuchos::Array< Teuchos::ArrayRCP< char> > ncbufs_;
};
template <class Node>
ReadyBufferHelper<Node>::ReadyBufferHelper(Teuchos::RCP<Node> node)
: node_(node) {
}
template <class Node>
ReadyBufferHelper<Node>::~ReadyBufferHelper() {
}
template <class Node>
void ReadyBufferHelper<Node>::begin() {
cbufs_.clear();
ncbufs_.clear();
}
template <class Node>
template <class T>
const T* ReadyBufferHelper<Node>::addConstBuffer(Teuchos::ArrayRCP<const T> buff) {
cbufs_.push_back( Teuchos::arcp_reinterpret_cast<const char>(buff) );
return buff.get();
}
template <class Node>
template <class T>
T* ReadyBufferHelper<Node>::addNonConstBuffer(Teuchos::ArrayRCP<T> buff) {
cbufs_.push_back( Teuchos::arcp_reinterpret_cast<char>(buff) );
return buff.get();
}
template <class Node>
void ReadyBufferHelper<Node>::end() {
node_->readyBuffers(cbufs_(), ncbufs_());
}
/*! A class to efficient get an array of views */
template <class Node>
class ArrayOfViewsHelper {
public:
template <class T>
static Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> > getArrayOfNonConstViews(const Teuchos::RCP<Node> &node, ReadWriteOption rw, const Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> > &arrayOfBuffers);
private:
/*! Cannot allocate object; all static */
ArrayOfViewsHelper();
~ArrayOfViewsHelper();
};
template <class Node>
template <class T>
Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> >
ArrayOfViewsHelper<Node>::getArrayOfNonConstViews(const Teuchos::RCP<Node> &node, ReadWriteOption rw, const Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> > &arrayOfBuffers) {
Teuchos::ArrayRCP< Teuchos::ArrayRCP<T> > arrayofviews;
const size_t numBufs = arrayOfBuffers.size();
if (numBufs > 0) {
arrayofviews = Teuchos::arcp< Teuchos::ArrayRCP<T> >(numBufs);
for (size_t i=0; i < numBufs; ++i) {
if (arrayOfBuffers[i].size() > 0) {
arrayofviews[i] = node->template viewBufferNonConst<T>(rw,arrayOfBuffers[i].size(),arrayOfBuffers[i]);
}
}
}
return arrayofviews;
}
/* A trivial implementation of ArrayOfViewsHelper, for CPU-only nodes. */
template <class Node>
class ArrayOfViewsHelperTrivialImpl {
public:
template <class T>
static Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> > getArrayOfNonConstViews(const Teuchos::RCP<Node> &node, ReadWriteOption rw, const Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> > &arrayOfBuffers);
private:
/*! Cannot allocate object; all static */
ArrayOfViewsHelperTrivialImpl();
~ArrayOfViewsHelperTrivialImpl();
};
template <class Node>
template <class T>
Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> >
ArrayOfViewsHelperTrivialImpl<Node>::getArrayOfNonConstViews(const Teuchos::RCP<Node> &node, ReadWriteOption rw, const Teuchos::ArrayRCP<Teuchos::ArrayRCP<T> > &arrayOfBuffers) {
(void)node;
(void)rw;
return arrayOfBuffers;
}
} // end of namespace Kokkos
#endif
|