+void DeviceStream::synchronize()
+{
+ stream_.wait_and_throw();
+};
+
+void DeviceStream::synchronize() const
+{
+ /* cl::sycl::queue::wait is a non-const function. However, a lot of code in GROMACS
+ * assumes DeviceStream is const, yet wants to synchronize with it.
+ * The chapter "4.3.2 Common reference semantics" of SYCL 1.2.1 specification says:
+ * > Each of the following SYCL runtime classes: [...] queue, [...] must obey the following
+ * > statements, where T is the runtime class type:
+ * > - T must be copy constructible and copy assignable on the host application [...].
+ * > Any instance of T that is constructed as a copy of another instance, via either the
+ * > copy constructor or copy assignment operator, must behave as-if it were the original
+ * > instance and as-if any action performed on it were also performed on the original
+ * > instance [...].
+ * Same in chapter "4.5.3" of provisional SYCL 2020 specification (June 30, 2020).
+ * So, we can copy-construct a new queue and wait() on it.
+ */
+ cl::sycl::queue(stream_).wait_and_throw();
+}