mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-03 12:47:42 -06:00
simplify vector ctor for gpubuffer
This commit is contained in:
1 parent
2d16e20f21
commit
b35b481090
1 file changed
+1
-12
@@ -99,18 +99,7 @@ public:
|
||||
explicit GpuBuffer(const std::vector<T>& data)
|
||||
: GpuBuffer(data.size())
|
||||
{
|
||||
if constexpr (std::is_same_v<T, bool>) {
|
||||
// Special handling for std::vector<bool>
|
||||
assert(data.size() > 0);
|
||||
auto tmp = std::make_unique<bool[]>(m_numberOfElements);
|
||||
for (size_t i = 0; i < m_numberOfElements; ++i) {
|
||||
tmp[i] = static_cast<bool>(data[i]);
|
||||
}
|
||||
OPM_GPU_SAFE_CALL(cudaMemcpy(m_dataOnDevice, tmp.get(), m_numberOfElements * sizeof(bool), cudaMemcpyHostToDevice));
|
||||
} else {
|
||||
// Regular types can use data.data()
|
||||
OPM_GPU_SAFE_CALL(cudaMemcpy(m_dataOnDevice, data.data(), m_numberOfElements * sizeof(T), cudaMemcpyHostToDevice));
|
||||
}
|
||||
copyFromHost(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user