mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-14 16:33:25 -06:00
Added test of size for copyToHost.
This commit is contained in:
parent
b4b1a7b77f
commit
0eb60e5336
@ -132,9 +132,16 @@ template <typename T>
|
||||
void
|
||||
CuVector<T>::assertSameSize(const CuVector<T>& x) const
|
||||
{
|
||||
if (x.m_numberOfElements != m_numberOfElements) {
|
||||
assertSameSize(x.m_numberOfElements);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
CuVector<T>::assertSameSize(int size) const
|
||||
{
|
||||
if (size != m_numberOfElements) {
|
||||
OPM_THROW(std::invalid_argument,
|
||||
fmt::format("Given vector has {}, while we have {}.", x.m_numberOfElements, m_numberOfElements));
|
||||
fmt::format("Given vector has {}, while we have {}.", size, m_numberOfElements));
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,6 +270,7 @@ template <class T>
|
||||
void
|
||||
CuVector<T>::copyToHost(T* dataPointer, size_t numberOfElements) const
|
||||
{
|
||||
assertSameSize(detail::to_int(numberOfElements));
|
||||
OPM_CUDA_SAFE_CALL(cudaMemcpy(dataPointer, data(), numberOfElements * sizeof(T), cudaMemcpyDeviceToHost));
|
||||
}
|
||||
|
||||
|
@ -370,6 +370,8 @@ private:
|
||||
detail::CuBlasHandle& m_cuBlasHandle;
|
||||
|
||||
void assertSameSize(const CuVector<T>& other) const;
|
||||
void assertSameSize(int size) const;
|
||||
|
||||
void assertHasElements() const;
|
||||
};
|
||||
} // namespace Opm::cuistl
|
||||
|
Loading…
Reference in New Issue
Block a user