Skip to content

Commit bad9c7f

Browse files
committed
Minor bug fix in opencl.hpp
1 parent feef36d commit bad9c7f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/opencl.hpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,13 @@ template<typename T> class Memory {
327327
delete_host_buffer();
328328
}
329329
inline void reset(const T value=(T)0) {
330-
if(host_buffer_exists) std::fill(host_buffer, host_buffer+range(), value); // faster than "for(ulong i=0ull; i<range(); i++) host_buffer[i] = value;"
331-
cl_queue.enqueueFillBuffer(device_buffer, value, 0ull, capacity()); // faster than "write_to_device();"
332-
cl_queue.finish();
330+
if(host_buffer_exists) {
331+
std::fill(host_buffer, host_buffer+range(), value); // faster than "for(ulong i=0ull; i<range(); i++) host_buffer[i] = value;"
332+
}
333+
if(device_buffer_exists) {
334+
cl_queue.enqueueFillBuffer(device_buffer, value, 0ull, capacity()); // faster than "write_to_device();"
335+
cl_queue.finish();
336+
}
333337
}
334338
inline const ulong length() const { return N; }
335339
inline const uint dimensions() const { return d; }

0 commit comments

Comments
 (0)