@@ -226,11 +226,11 @@ pub unsafe fn memcpy_dtoh(
226226}
227227
228228/// Similar to `cudaMemcpy2D` with `HostToDevice` copy type.
229- ///
229+ ///
230230/// `dpitch`/`spitch` is bytes between the start of two rows.
231231/// `width` is the number of *elements* (not bytes) in a row.
232232/// `height` is the total number of rows (not bytes).
233- ///
233+ ///
234234/// # Examples
235235///
236236/// ```
@@ -240,32 +240,32 @@ pub unsafe fn memcpy_dtoh(
240240/// unsafe {
241241/// // Allocate space for a 3x3 matrix of f32s
242242/// let (device_buffer, pitch) = cuda_malloc_pitched::<f32>(3, 3)?;
243- ///
243+ ///
244244/// let src_array: [f32; 9] = [
245- /// 1.0, 2.0, 3.0,
246- /// 4.0, 5.0, 6.0,
245+ /// 1.0, 2.0, 3.0,
246+ /// 4.0, 5.0, 6.0,
247247/// 7.0, 8.0, 9.0];
248- ///
248+ ///
249249/// memcpy_2d_htod(
250- /// device_buffer,
251- /// pitch,
250+ /// device_buffer,
251+ /// pitch,
252252/// src_array.as_slice().as_ptr(),
253253/// 3*std::mem::size_of::<f32>(),
254254/// 3,
255255/// 3
256256/// )?;
257- ///
257+ ///
258258/// let mut dst_array = [0.0f32; 9];
259259///
260260/// memcpy_2d_dtoh(
261261/// dst_array.as_mut_slice().as_mut_ptr(),
262262/// 3*std::mem::size_of::<f32>(),
263- /// device_buffer,
264- /// pitch,
263+ /// device_buffer,
264+ /// pitch,
265265/// 3,
266266/// 3
267- /// )?;
268- ///
267+ /// )?;
268+ ///
269269/// assert_eq!(dst_array, src_array);
270270/// cuda_free(device_buffer)?;
271271/// }
@@ -284,15 +284,16 @@ pub unsafe fn memcpy_2d_htod<T: DeviceCopy>(
284284) -> CudaResult < ( ) > {
285285 use cust_raw:: CUmemorytype ;
286286
287- let width_in_bytes = width. checked_mul ( std:: mem:: size_of :: < T > ( ) )
287+ let width_in_bytes = width
288+ . checked_mul ( std:: mem:: size_of :: < T > ( ) )
288289 . ok_or ( CudaError :: InvalidMemoryAllocation ) ?;
289290
290291 let pcopy = cust_raw:: CUDA_MEMCPY2D_st {
291292 srcXInBytes : 0 ,
292293 srcY : 0 ,
293294 srcMemoryType : CUmemorytype :: CU_MEMORYTYPE_HOST ,
294295 srcHost : src as * const c_void ,
295- srcDevice : 0 , // Ignored
296+ srcDevice : 0 , // Ignored
296297 srcArray : std:: ptr:: null_mut :: < cust_raw:: CUarray_st > ( ) , // Ignored
297298 srcPitch : spitch,
298299 dstXInBytes : 0 ,
@@ -311,11 +312,11 @@ pub unsafe fn memcpy_2d_htod<T: DeviceCopy>(
311312}
312313
313314/// Similar to `cudaMemcpy2D` with `DeviceToHost` copy type.
314- ///
315+ ///
315316/// `dpitch`/`spitch` is bytes between the start of two rows.
316317/// `width` is the number of *elements* (not bytes) in a row.
317318/// `height` is the total number of rows (not bytes).
318- ///
319+ ///
319320/// # Examples
320321///
321322/// ```
@@ -325,32 +326,32 @@ pub unsafe fn memcpy_2d_htod<T: DeviceCopy>(
325326/// unsafe {
326327/// // Allocate space for a 3x3 matrix of f32s
327328/// let (device_buffer, pitch) = cuda_malloc_pitched::<f32>(3, 3)?;
328- ///
329+ ///
329330/// let src_array: [f32; 9] = [
330- /// 1.0, 2.0, 3.0,
331- /// 4.0, 5.0, 6.0,
331+ /// 1.0, 2.0, 3.0,
332+ /// 4.0, 5.0, 6.0,
332333/// 7.0, 8.0, 9.0];
333- ///
334+ ///
334335/// memcpy_2d_htod(
335- /// device_buffer,
336- /// pitch,
336+ /// device_buffer,
337+ /// pitch,
337338/// src_array.as_slice().as_ptr(),
338339/// 3*std::mem::size_of::<f32>(),
339340/// 3,
340341/// 3
341342/// )?;
342- ///
343+ ///
343344/// let mut dst_array = [0.0f32; 9];
344345///
345346/// memcpy_2d_dtoh(
346347/// dst_array.as_mut_slice().as_mut_ptr(),
347348/// 3*std::mem::size_of::<f32>(),
348- /// device_buffer,
349- /// pitch,
349+ /// device_buffer,
350+ /// pitch,
350351/// 3,
351352/// 3
352- /// )?;
353- ///
353+ /// )?;
354+ ///
354355/// assert_eq!(dst_array, src_array);
355356/// cuda_free(device_buffer)?;
356357/// }
@@ -369,7 +370,8 @@ pub unsafe fn memcpy_2d_dtoh<T: DeviceCopy>(
369370) -> CudaResult < ( ) > {
370371 use cust_raw:: CUmemorytype ;
371372
372- let width_in_bytes = width. checked_mul ( std:: mem:: size_of :: < T > ( ) )
373+ let width_in_bytes = width
374+ . checked_mul ( std:: mem:: size_of :: < T > ( ) )
373375 . ok_or ( CudaError :: InvalidMemoryAllocation ) ?;
374376
375377 let pcopy = cust_raw:: CUDA_MEMCPY2D_st {
@@ -383,8 +385,8 @@ pub unsafe fn memcpy_2d_dtoh<T: DeviceCopy>(
383385 dstXInBytes : 0 ,
384386 dstY : 0 ,
385387 dstMemoryType : CUmemorytype :: CU_MEMORYTYPE_HOST ,
386- dstHost : dst as * mut c_void ,
387- dstDevice : 0 , // Ignored
388+ dstHost : dst as * mut c_void ,
389+ dstDevice : 0 , // Ignored
388390 dstArray : std:: ptr:: null_mut :: < cust_raw:: CUarray_st > ( ) , // Ignored
389391 dstPitch : dpitch,
390392 WidthInBytes : width_in_bytes,
0 commit comments