@@ -49,25 +49,45 @@ class BackendMemoryAllocator
4949 * @param dst Destination pointer (allocated by this allocator)
5050 * @param src Source pointer (host memory)
5151 * @param bytes Number of bytes to copy
52+ * @throws std::invalid_argument if dst or src is nullptr and bytes > 0
5253 */
53- virtual void copy_from_host (void * dst, const void * src, size_t bytes) = 0 ;
54+ void copy_from_host (void * dst, const void * src, size_t bytes);
5455
5556 /* *
5657 * @brief Copy data from allocated memory to host (CPU) memory
5758 * @param dst Destination pointer (host memory)
5859 * @param src Source pointer (allocated by this allocator)
5960 * @param bytes Number of bytes to copy
61+ * @throws std::invalid_argument if dst or src is nullptr and bytes > 0
6062 */
61- virtual void copy_to_host (void * dst, const void * src, size_t bytes) = 0 ;
63+ void copy_to_host (void * dst, const void * src, size_t bytes);
6264
6365 /* *
6466 * @brief Copy data between two allocations from this allocator
6567 * @param dst Destination pointer (allocated by this allocator)
6668 * @param src Source pointer (allocated by this allocator)
6769 * @param bytes Number of bytes to copy
70+ * @throws std::invalid_argument if dst or src is nullptr and bytes > 0
6871 */
69- virtual void copy_device_to_device (void * dst, const void * src, size_t bytes) = 0 ;
72+ void copy_device_to_device (void * dst, const void * src, size_t bytes);
7073
74+ protected:
75+ /* *
76+ * @brief Implementation of copy_from_host (to be overridden by backends)
77+ */
78+ virtual void copy_from_host_impl (void * dst, const void * src, size_t bytes) = 0;
79+
80+ /* *
81+ * @brief Implementation of copy_to_host (to be overridden by backends)
82+ */
83+ virtual void copy_to_host_impl (void * dst, const void * src, size_t bytes) = 0;
84+
85+ /* *
86+ * @brief Implementation of copy_device_to_device (to be overridden by backends)
87+ */
88+ virtual void copy_device_to_device_impl (void * dst, const void * src, size_t bytes) = 0;
89+
90+ public:
7191 /* *
7292 * @brief Check if this allocator manages device (non-host) memory
7393 * @return true if memory is on device (GPU, etc.), false if host memory
0 commit comments