Misc api improvements and cleanups

This commit is contained in:
Benoit Steiner
2014-08-23 14:35:41 -07:00
parent fb5c1e9097
commit 36fffe48f7
4 changed files with 55 additions and 19 deletions

View File

@@ -27,6 +27,10 @@ struct DefaultDevice {
EIGEN_STRONG_INLINE void memset(void* buffer, int c, size_t n) const {
::memset(buffer, c, n);
}
EIGEN_STRONG_INLINE size_t numThreads() const {
return 1;
}
};
@@ -115,6 +119,11 @@ struct GpuDevice {
cudaMemsetAsync(buffer, c, n, *stream_);
}
EIGEN_STRONG_INLINE size_t numThreads() const {
// Fixme:
return 32;
}
private:
// TODO: multigpu.
const cudaStream_t* stream_;

View File

@@ -195,6 +195,32 @@ struct DSizes : array<DenseIndex, NumDims> {
}
EIGEN_DEVICE_FUNC explicit DSizes(const array<DenseIndex, NumDims>& a) : Base(a) { }
EIGEN_DEVICE_FUNC explicit DSizes(const DenseIndex i0) {
(*this)[0] = i0;
}
EIGEN_DEVICE_FUNC explicit DSizes(const DenseIndex i0, const DenseIndex i1) {
(*this)[0] = i0;
(*this)[1] = i1;
}
EIGEN_DEVICE_FUNC explicit DSizes(const DenseIndex i0, const DenseIndex i1, const DenseIndex i2) {
(*this)[0] = i0;
(*this)[1] = i1;
(*this)[2] = i2;
}
EIGEN_DEVICE_FUNC explicit DSizes(const DenseIndex i0, const DenseIndex i1, const DenseIndex i2, const DenseIndex i3) {
(*this)[0] = i0;
(*this)[1] = i1;
(*this)[2] = i2;
(*this)[3] = i3;
}
EIGEN_DEVICE_FUNC explicit DSizes(const DenseIndex i0, const DenseIndex i1, const DenseIndex i2, const DenseIndex i3, const DenseIndex i4) {
(*this)[0] = i0;
(*this)[1] = i1;
(*this)[2] = i2;
(*this)[3] = i3;
(*this)[4] = i4;
}
DSizes& operator = (const array<DenseIndex, NumDims>& other) {
*static_cast<Base*>(this) = other;
return *this;