 -- |
 -- Copy the given number of elements from the first device array (source) to the
 -- second (destination). The copied areas may not overlap. This operation is
--- asynchronous with respect to host, but will never overlap with kernel
--- execution.
+-- asynchronous with respect to the host, and may be associated with a
+-- particular stream.
 --
 {-# INLINEABLE copyArrayAsync #-}
 copyArrayAsync :: Storable a => Int -> DevicePtr a -> DevicePtr a -> Maybe Stream -> IO ()
 copyArrayAsync !n !src !dst !mst =
   memcpyAsync (useDevicePtr dst) (useDevicePtr src) n DeviceToDevice mst
+
+
+-- |
+-- Copy a 2D memory area from the first device array (source) to the second
+-- (destination). The copied areas may not overlap. This operation is
+-- asynchronous with respect to the host, but will not overlap other device
+-- operations.
+--
+{-# INLINEABLE copyArray2D #-}
+copyArray2D
+    :: Storable a
+    => Int                      -- ^ width to copy (elements)
+    -> Int                      -- ^ height to copy (elements)
+    -> DevicePtr a              -- ^ source array
+    -> Int                      -- ^ source array width
+    -> DevicePtr a              -- ^ destination array
+    -> Int                      -- ^ destination array width
+    -> IO ()
+copyArray2D !w !h !src !sw !dst !dw =
+  memcpy2D (useDevicePtr dst) dw (useDevicePtr src) sw w h DeviceToDevice
+
+
+-- |
+-- Copy a 2D memory area from the first device array (source) to the second
+-- device array (destination). The copied areas may not overlay. This operation
+-- is asynchronous with respect to the host, and may be associated with a
+-- particular stream.
+--
+{-# INLINEABLE copyArray2DAsync #-}
+copyArray2DAsync
+    :: Storable a
+    => Int                      -- ^ width to copy (elements)
+    -> Int                      -- ^ height to copy (elements)
+    -> DevicePtr a              -- ^ source array
+    -> Int                      -- ^ source array width
+    -> DevicePtr a              -- ^ destination array
+    -> Int                      -- ^ destination array width
+    -> Maybe Stream
+    -> IO ()
+copyArray2DAsync !w !h !src !sw !dst !dw !mst =
+  memcpy2DAsync (useDevicePtr dst) dw (useDevicePtr src) sw w h DeviceToDevice mst
 
 
 --

  , useStream `Stream'        } -> `Status' cToEnum #}


--------------------------------------------------------------------------------
-- Combined Allocation and Marshalling
--------------------------------------------------------------------------------


-- System
import Data.Int
import Data.Maybe
import Control.Exception

import Foreign.C
