cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
copy_parameters.hpp
Go to the documentation of this file.
1 
6 #ifndef CUDA_API_WRAPPERS_COPY_PARAMETERS_HPP
7 #define CUDA_API_WRAPPERS_COPY_PARAMETERS_HPP
8 
9 #include "array.hpp"
10 #include "pointer.hpp"
11 #include "constants.hpp"
12 #include "error.hpp"
13 
14 namespace cuda {
15 
16 namespace memory {
17 
19 enum class endpoint_t { source, destination };
20 
22 template<dimensionality_t NumDimensions>
23 struct copy_parameters_t;
25 
26 namespace detail_ {
27 
29 template<dimensionality_t NumDimensions>
30 struct base_copy_params;
31 
32 template<>
33 struct base_copy_params<2> {
34  using intra_context_type = CUDA_MEMCPY2D;
35  using type = intra_context_type; // Why is there no inter-context type, CUDA_MEMCPY2D_PEER ?
36 };
37 
38 template<>
39 struct base_copy_params<3> {
40  using type = CUDA_MEMCPY3D_PEER;
41  using intra_context_type = CUDA_MEMCPY3D;
42 };
43 
44 // Note these, by default, support inter-context
45 template<dimensionality_t NumDimensions>
46 using base_copy_params_t = typename base_copy_params<NumDimensions>::type;
47 
48 template<size_t NumDimensions>
50 non_array_endpoint_dimensions(endpoint_t endpoint, const copy_parameters_t<NumDimensions>& params);
51 
52 } //namespace detail_
53 
67 template<dimensionality_t NumDimensions>
68 struct copy_parameters_t : detail_::base_copy_params_t<NumDimensions> {
69  using parent = detail_::base_copy_params_t<NumDimensions>;
71  // TODO: Perhaps use proxies?
72 
75  using intra_context_type = typename detail_::base_copy_params<NumDimensions>::intra_context_type;
76 
78  using dimension_type = array::dimension_t;
79 
82  bool is_intra_context() const noexcept { return parent::srcContext == parent::dstContext; }
83 
85  this_type& set_context(endpoint_t endpoint, const context_t& context) noexcept;
86 
88  this_type& set_single_context(const context_t& context) noexcept
89  {
90  set_context(endpoint_t::source, context);
91  set_context(endpoint_t::destination, context);
92  return *this;
93  }
94 
100  template<typename T>
101  this_type& set_endpoint(endpoint_t endpoint, const cuda::array_t<T, NumDimensions> &array) noexcept;
102 
103  this_type& set_endpoint_ptr(endpoint_t endpoint, context::handle_t context_handle, void *ptr);
104 
111  this_type& set_endpoint_untyped(
112  endpoint_t endpoint,
113  context::handle_t context_handle,
114  void *ptr,
115  dimensions_type dimensions);
116 
123  template<typename T>
125  this_type& set_endpoint(endpoint_t endpoint, T *ptr, dimensions_type dimensions);
126 
127  template<typename T>
128  this_type& set_endpoint(
129  endpoint_t endpoint,
130  context::handle_t context_handle,
131  T *ptr,
132  dimensions_type dimensions) noexcept;
134 
141  template<typename T>
142  this_type& set_endpoint(endpoint_t endpoint, span <T> span) noexcept
143  {
144  return set_endpoint(endpoint, span.data(), dimensions_type(span.size()));
145  }
146 
152  template<typename T>
154  {
155  return set_endpoint(endpoint_t::source, array);
156  }
157 
165  this_type& set_source_untyped(context::handle_t context_handle, void *ptr, dimensions_type dimensions)
166  {
167  return set_endpoint_untyped(endpoint_t::source, context_handle, ptr, dimensions);
168  }
169 
170  this_type& set_source_ptr(context::handle_t context_handle, void *ptr)
171  {
172  return set_endpoint_ptr(endpoint_t::source, context_handle, ptr);
173  }
174 
181  template<typename T>
183  this_type& set_source(T *ptr, dimensions_type dimensions) noexcept
184  {
185  return set_endpoint(endpoint_t::source, ptr, dimensions);
186  }
187 
188  template<typename T>
189  this_type& set_source(context::handle_t context_handle, T *ptr, dimensions_type dimensions) noexcept
190  {
191  return set_endpoint(endpoint_t::source, context_handle, ptr, dimensions);
192  }
194 
201  template<typename T>
202  this_type& set_source(span <T> span) noexcept
203  {
204  return set_source(span.data(), dimensions_type{span.size()});
205  }
206 
212  template<typename T>
214  {
215  return set_endpoint(endpoint_t::destination, array);
216  }
217 
225  void set_destination_untyped(context::handle_t context_handle, void *ptr, dimensions_type dimensions) noexcept
226  {
227  set_endpoint_untyped(endpoint_t::destination, context_handle, ptr, dimensions);
228  }
229 
230  void set_destination_ptr(context::handle_t context_handle, void *ptr) noexcept
231  {
232  set_endpoint_untyped(endpoint_t::destination, context_handle, ptr);
233  }
234 
241  template<typename T>
243  this_type& set_destination(T *ptr, dimensions_type dimensions) noexcept
244  {
245  return set_endpoint(endpoint_t::destination, ptr, dimensions);
246  }
247 
248  template<typename T>
249  this_type& set_destination(context::handle_t context_handle, T *ptr, dimensions_type dimensions) noexcept
250  {
251  return set_endpoint(endpoint_t::destination, context_handle, ptr, dimensions);
252  }
254 
261  template<typename T>
262  this_type& set_destination(span<T> span) noexcept
263  {
264  return set_destination(span.data(), {span.size(), 1, 1});
265  }
266 
269  this_type& set_bytes_offset(endpoint_t endpoint, dimensions_type offset) noexcept;
270 
273  template<typename T>
274  this_type& set_offset(endpoint_t endpoint, dimensions_type offset) noexcept;
275 
278  this_type& clear_offset(endpoint_t endpoint) noexcept
279  {
280  return set_bytes_offset(endpoint, dimensions_type::zero());
281  }
282 
285  {
286  clear_offset(endpoint_t::source);
287  clear_offset(endpoint_t::destination);
288  return *this;
289  }
290 
294  this_type& set_bytes_pitch(endpoint_t endpoint, dimension_type pitch_in_bytes) noexcept
295  {
296  (endpoint == endpoint_t::source ? parent::srcPitch : parent::dstPitch) = pitch_in_bytes;
297  return *this;
298  }
299 
303  template<typename T>
304  this_type& set_pitch(endpoint_t endpoint, dimension_type pitch_in_elements) noexcept
305  {
306  return set_bytes_pitch(endpoint, pitch_in_elements * sizeof(T));
307  }
308 
312  template<typename T>
313  this_type& set_pitches(dimension_type uniform_pitch_in_elements) noexcept
314  {
315  auto uniform_pitch_in_bytes { uniform_pitch_in_elements * sizeof(T) };
316  set_pitch<T>(endpoint_t::source, uniform_pitch_in_bytes);
317  set_pitch<T>(endpoint_t::destination, uniform_pitch_in_bytes);
318  return *this;
319  }
320 
321  // Note: Must be called after copy extents have been set
322  this_type& set_default_pitch(endpoint_t endpoint) noexcept
323  {
324  return set_bytes_pitch(endpoint, parent::WidthInBytes);
325  }
326 
327  // Note: Must be called after copy extents have been set
328  this_type& set_default_pitches() noexcept
329  {
330  set_default_pitch(endpoint_t::source);
331  set_default_pitch(endpoint_t::destination);
332  return *this;
333  }
334 
340  this_type& set_bytes_extent(dimensions_type extent_in_bytes) noexcept;
341 
347  template<typename T>
348  this_type& set_extent(dimensions_type extent_in_elements) noexcept;
349  // Sets how much is being copies, as opposed to the sizes of the endpoints which may be larger
350 
356  dimensions_type bytes_extent() const noexcept;
357 
363  template <typename T>
364  dimensions_type extent() const noexcept
365  {
366  auto extent_ = bytes_extent();
367 #ifndef NDEBUG
368  if (extent_.width % sizeof(T) != 0) {
369  throw ::std::invalid_argument(
370  "Attempt to get the copy extent with assumed type of size "
371  + ::std::to_string(sizeof(T)) + " while the byte extent's "
372  + "minor dimension is not a multiple of this size");
373  }
374 #endif
375  extent_.width /= sizeof(T);
376  return extent_;
377  }
378 
379  this_type& set_pitches(dimension_type uniform_pitch_in_bytes) noexcept
380  {
381  set_pitch(endpoint_t::source, uniform_pitch_in_bytes);
382  set_pitch(endpoint_t::destination, uniform_pitch_in_bytes);
383  return *this;
384  }
385 
386  this_type& clear_rest() noexcept;
387  // Clear any dummy fields which are required to be set to 0. Note that important fields,
388  // which you have not set explicitly, will _not_ be cleared by this method.
389 
390 };
391 
392 template<>
394  endpoint_t endpoint,
395  context::handle_t context_handle,
396  void * ptr);
397 
398 template<>
400  endpoint_t endpoint,
401  context::handle_t context_handle,
402  void * ptr);
403 
404 template<>
406  endpoint_t endpoint,
407  context::handle_t context_handle,
408  void * ptr,
409  array::dimensions_t<2> dimensions);
410 
411 template<>
413  endpoint_t endpoint,
414  context::handle_t context_handle,
415  void * ptr,
416  array::dimensions_t<3> dimensions);
417 
418 template<>
419 template<typename T>
421  endpoint_t endpoint,
422  context::handle_t context_handle,
423  T * ptr,
424  array::dimensions_t<2> dimensions) noexcept
425 {
426  array::dimensions_t<2> untyped_dims = {dimensions.width * sizeof(T), dimensions.height};
427  return set_endpoint_untyped(endpoint, context_handle, ptr, untyped_dims);
428 }
429 
430 template<>
431 template<typename T>
433  endpoint_t endpoint,
434  T * ptr,
435  array::dimensions_t<2> dimensions)
436 {
437  // We would have _liked_ to say:
438  // auto context_handle = context::current::detail_::get_handle();
439  // ... here, but alas, 2D copy structures don't support contexts, so...
440  auto context_handle = context::detail_::none;
441  return set_endpoint<T>(endpoint, context_handle, ptr, dimensions);
442 }
443 
444 template<>
445 template<typename T>
447 {
448  (endpoint == endpoint_t::source ? srcMemoryType : dstMemoryType) = CU_MEMORYTYPE_ARRAY;
449  (endpoint == endpoint_t::source ? srcArray : dstArray) = array.get();
450  (endpoint == endpoint_t::source ? srcDevice : dstDevice) = array.device_id();
451  // Can't set the endpoint context - the basic data structure doesn't support that!
452  return *this;
453 }
454 
455 namespace detail_ {
456 
457 template<>
458 inline array::dimensions_t<2> non_array_endpoint_dimensions<2>(endpoint_t endpoint, const copy_parameters_t<2>& params)
459 {
460  using dims_type = copy_parameters_t<2>::dimensions_type;
461  return (endpoint == endpoint_t::source) ?
462  dims_type{ params.WidthInBytes, params.Height } :
463  dims_type{ params.WidthInBytes, params.Height };
464 }
465 
466 template<>
467 inline array::dimensions_t<3> non_array_endpoint_dimensions<3>(endpoint_t endpoint, const copy_parameters_t<3>& params)
468 {
469  using dims_type = copy_parameters_t<3>::dimensions_type;
470  return (endpoint == endpoint_t::source) ?
471  dims_type{ params.srcPitch, params.Height, params.Depth } :
472  dims_type{ params.WidthInBytes, params.Height, params.Depth };
473 }
474 
475 } //
476 
477 template<>
478 template<typename T>
480 {
481  (endpoint == endpoint_t::source ? srcMemoryType : dstMemoryType) = CU_MEMORYTYPE_ARRAY;
482  (endpoint == endpoint_t::source ? srcArray : dstArray) = array.get();
483  (endpoint == endpoint_t::source ? srcContext : dstContext) = array.context_handle();
484  return *this;
485 }
486 
487 // 2D copy parameters only have an intra-context variant; should we silently assume the context
488 // is the same for both ends?
489 template<>
490 inline copy_parameters_t<2>& copy_parameters_t<2>::set_context(endpoint_t endpoint, const context_t& context) noexcept = delete;
491 
492 template<>
493 inline copy_parameters_t<3>& copy_parameters_t<3>::set_context(endpoint_t endpoint, const context_t& context) noexcept
494 {
495  (endpoint == endpoint_t::source ? srcContext : dstContext) = context.handle();
496  return *this;
497 }
498 
499 template<>
500 template<typename T>
502  endpoint_t endpoint,
503  context::handle_t context_handle,
504  T *ptr,
505  array::dimensions_t<3> dimensions) noexcept
506 {
507  array::dimensions_t<3> untyped_dims = {dimensions.width * sizeof(T), dimensions.height, dimensions.depth};
508  return set_endpoint_untyped(endpoint, context_handle, ptr, untyped_dims);
509 }
510 
511 template<>
512 template<typename T>
514  endpoint_t endpoint,
515  T *ptr,
516  array::dimensions_t<3> dimensions)
517 {
518  return set_endpoint<T>(endpoint, context::current::detail_::get_handle(), ptr, dimensions);
519 }
520 
521 template<>
523 {
524  return *this;
525 }
526 
527 template<>
529 {
530  srcLOD = 0;
531  dstLOD = 0;
532  return *this;
533 }
534 
535 template<>
536 template<typename T>
538 {
539  WidthInBytes = extent_in_elements.width * sizeof(T);
540  Height = extent_in_elements.height;
541  return *this;
542 }
543 
544 template<>
546 {
547  WidthInBytes = extent_in_elements.width;
548  Height = extent_in_elements.height;
549  return *this;
550 }
551 
552 template<>
554 {
555  WidthInBytes = extent_in_elements.width;
556  Height = extent_in_elements.height;
557  Depth = extent_in_elements.depth;
558  return *this;
559 }
560 
561 template<>
563 {
564  return { WidthInBytes, Height };
565 }
566 
567 template<>
569 {
570  return { WidthInBytes, Height, Depth };
571 }
572 
573 template<>
574 inline copy_parameters_t<2>& copy_parameters_t<2>::set_endpoint_ptr(
575  endpoint_t endpoint,
577  void * ptr)
578 {
579  auto memory_type = type_of(ptr);
580  if (memory_type == array) {
581  throw ::std::invalid_argument("Attempt to use the non-array endpoint setter with array memory at " + cuda::detail_::ptr_as_hex(ptr));
582  }
583  if (memory_type == unified_ or memory_type == device_)
584  {
585  (endpoint == endpoint_t::source ? srcDevice : dstDevice) = device::address(ptr);
586  }
587  else {
588  // Either host or non_cuda memory
589  if (endpoint == endpoint_t::source) { srcHost = ptr; }
590  else { dstHost = ptr; }
591  }
592  (endpoint == endpoint_t::source ? srcMemoryType : dstMemoryType) =
593  static_cast<CUmemorytype>(memory_type == non_cuda ? host_ : memory_type);
594  // Can't set the endpoint context - the basic data structure doesn't support that!
595  // (endpoint == endpoint_t::source ? srcContext : dstContext) = context_handle;
596  return *this;
597 }
598 
599 template<>
601  endpoint_t endpoint,
602  context::handle_t context_handle,
603  void * ptr,
604  array::dimensions_t<2> dimensions)
605 {
606  set_endpoint_ptr(endpoint, context_handle, ptr);
607  set_bytes_pitch(endpoint, dimensions.width);
608  set_bytes_extent(dimensions);
609  return *this;
610 }
611 
612 template<>
613 inline copy_parameters_t<3>& copy_parameters_t<3>::set_endpoint_ptr(
614  endpoint_t endpoint,
615  context::handle_t context_handle,
616  void * ptr)
617 {
618  auto memory_type = type_of(ptr);
619  if (memory_type == array) {
620  throw ::std::invalid_argument("Attempt to use the non-array endpoint setter with array memory at " + cuda::detail_::ptr_as_hex(ptr));
621  }
622  if (memory_type == unified_ or memory_type == device_)
623  {
624  (endpoint == endpoint_t::source ? srcDevice : dstDevice) = device::address(ptr);
625  }
626  else {
627  // Either host or non_cuda memory
628  if (endpoint == endpoint_t::source) { srcHost = ptr; }
629  else { dstHost = ptr; }
630  }
631  (endpoint == endpoint_t::source ? srcMemoryType : dstMemoryType) =
632  static_cast<CUmemorytype> (memory_type == non_cuda ? host_ : memory_type);
633  (endpoint == endpoint_t::source ? srcContext : dstContext) = context_handle;
634  return *this;
635 }
636 
637 template<>
639  endpoint_t endpoint,
640  context::handle_t context_handle,
641  void * ptr,
642  array::dimensions_t<3> dimensions)
643 {
644  set_endpoint_ptr(endpoint, context_handle, ptr);
645  (endpoint == endpoint_t::source ? srcHeight : dstHeight) = dimensions.height;
646  set_bytes_pitch(endpoint, dimensions.width);
647  set_bytes_extent(dimensions);
648  return *this;
649 }
650 
651 template<>
652 template<typename T>
654 {
655  dimensions_type extent_in_bytes{
656  extent_in_elements.width * sizeof(T),
657  extent_in_elements.height,
658  extent_in_elements.depth
659  };
660  return set_bytes_extent(extent_in_bytes);
661 }
662 
663 template<>
664 inline copy_parameters_t<3>&
666 {
667  (endpoint == endpoint_t::source ? srcXInBytes : dstXInBytes) = offset.width;
668  (endpoint == endpoint_t::source ? srcY : dstY) = offset.height;
669  (endpoint == endpoint_t::source ? srcZ : dstZ) = offset.depth;
670  return *this;
671 }
672 
673 template<>
674 inline copy_parameters_t<2> &
676 {
677  (endpoint == endpoint_t::source ? srcXInBytes : dstXInBytes) = offset.width;
678  (endpoint == endpoint_t::source ? srcY : dstY) = offset.height;
679  return *this;
680 }
681 
682 template<>
683 template<typename T>
685 {
686  dimensions_type offset_in_bytes{offset.width * sizeof(T), offset.height, offset.depth};
687  return set_bytes_offset(endpoint, offset_in_bytes);
688 }
689 
690 template<>
691 template<typename T>
693 {
694  dimensions_type offset_in_bytes{offset.width * sizeof(T), offset.height};
695  return set_bytes_offset(endpoint, offset_in_bytes);
696 }
697 
699 inline as_intra_context_parameters(const copy_parameters_t<3>& params)
700 {
701  if (params.srcDevice != params.dstDevice) {
702  throw ::std::invalid_argument("Attempt to use inter-device copy parameters for an intra-context copy");
703  }
704  if (params.srcContext != params.dstContext) {
705  throw ::std::invalid_argument("Attempt to use inter-context copy parameters for an intra-context copy");
706  }
707 
708  // TODO: Use designated initializers in C++20
710 
711  result.srcXInBytes = params.srcXInBytes;
712  result.srcY = params.srcY;
713  result.srcZ = params.srcZ;
714  result.srcLOD = params.srcLOD;
715  result.srcMemoryType = params.srcMemoryType;
716  result.srcHost = params.srcHost;
717  result.srcDevice = params.srcDevice;
718  result.srcArray = params.srcArray;
719  result.reserved0 = nullptr; // srcContext
720  result.srcPitch = params.srcPitch;
721  result.srcHeight = params.srcHeight;
722 
723  result.dstXInBytes = params.dstXInBytes;
724  result.dstY = params.dstY;
725  result.dstZ = params.dstZ;
726  result.dstLOD = params.dstLOD;
727  result.dstMemoryType = params.dstMemoryType;
728  result.dstHost = params.dstHost;
729  result.dstDevice = params.dstDevice;
730  result.dstArray = params.dstArray;
731  result.reserved1 = nullptr;
732  result.dstPitch = params.dstPitch;
733  result.dstHeight = params.dstHeight;
734 
735  result.WidthInBytes = params.WidthInBytes;
736  result.Height = params.Height;
737  result.Depth = params.Depth;
738  return result;
739 }
740 
741 } //namespace memory
742 
743 } // namespace cuda
744 
745 #endif //CUDA_API_WRAPPERS_COPY_PARAMETERS_HPP
this_type & set_destination(const cuda::array_t< T, NumDimensions > &array) noexcept
Set the source endpoint of the copy operation to be a CUDA array.
Definition: copy_parameters.hpp:213
this_type & set_endpoint(endpoint_t endpoint, span< T > span) noexcept
Set one of the copy endpoints to a multi-dimensional elements, starting at the beginning of a span of...
Definition: copy_parameters.hpp:142
endpoint_t
Type for choosing between endpoints of copy operations.
Definition: copy_parameters.hpp:19
this_type & set_single_context(const context_t &context) noexcept
Set the same context for both endpoints of the copy operation.
Definition: copy_parameters.hpp:88
Wrapper class for a CUDA context.
Definition: context.hpp:249
this_type & set_source(const cuda::array_t< T, NumDimensions > &array) noexcept
Set the source endpoint of the copy operation to be a CUDA array.
Definition: copy_parameters.hpp:153
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
this_type & set_endpoint_untyped(endpoint_t endpoint, context::handle_t context_handle, void *ptr, dimensions_type dimensions)
Set one of the copy endpoints to a multi-dimensional elements, with dimensions specified in bytes rat...
CUcontext handle_t
Raw CUDA driver handle for a context; see {context_t}.
Definition: types.hpp:880
this_type & clear_offsets() noexcept
Clear the offsets into both the source and the destination endpoint regions.
Definition: copy_parameters.hpp:284
dimension_t width
The three constituent individual dimensions, named.
Definition: types.hpp:109
Owning wrapper for CUDA 2D and 3D arrays.
Definition: array.hpp:29
this_type & set_context(endpoint_t endpoint, const context_t &context) noexcept
Set the context for one end of the copy operation.
Dimensions for 2D CUDA arrays.
Definition: types.hpp:156
memory::type_t type_of(const void *ptr)
Determine the type of memory at a given address vis-a-vis the CUDA ecosystem: Was it allocated by the...
Definition: pointer.hpp:112
Dimensions for 3D CUDA arrays.
Definition: types.hpp:106
void set_destination_untyped(context::handle_t context_handle, void *ptr, dimensions_type dimensions) noexcept
Set the destination of the copy operation to be a sequence of multi-dimensional elements, with dimensions specified in bytes rather than actual elements, starting somewhere in memory (in any CUDA memory space)
Definition: copy_parameters.hpp:225
dimension_t width
The two constituent individual dimensions, named; no "depth" for the 2D case.
Definition: types.hpp:159
dimensions_type extent() const noexcept
Definition: copy_parameters.hpp:364
dimensions_type bytes_extent() const noexcept
this_type & set_destination(T *ptr, dimensions_type dimensions) noexcept
Set one of the copy endpoints to a multi-dimensional elements, starting somewhere in memory (in any C...
Definition: copy_parameters.hpp:243
this_type & set_source(T *ptr, dimensions_type dimensions) noexcept
Set one of the copy endpoints to a multi-dimensional elements, starting somewhere in memory (in any C...
Definition: copy_parameters.hpp:183
Contains a proxy class for CUDA arrays - GPU memory with 2-D or 3-D locality and hardware support for...
this_type & set_extent(dimensions_type extent_in_elements) noexcept
Set how much is to be copied in each dimension - in elements.
this_type & set_offset(endpoint_t endpoint, dimensions_type offset) noexcept
Set the (multi-dimensional) offset, in elements, into multidimensional range of elements at one of th...
this_type & clear_offset(endpoint_t endpoint) noexcept
Set the copy operation to use the multi-dimensional region of the specified endpoint without skipping...
Definition: copy_parameters.hpp:278
A builder-ish subclass template around the basic 2D or 3D copy parameters which CUDA&#39;s complex copyin...
Definition: copy_parameters.hpp:68
this_type & set_bytes_offset(endpoint_t endpoint, dimensions_type offset) noexcept
Set the (multi-dimensional) offset, in bytes, into multidimensional range of elements at one of the e...
typename detail_::base_copy_params< NumDimensions >::intra_context_type intra_context_type
A Raw CUDA Driver API type punning the general copy parameters, which is used for copy operations wit...
Definition: copy_parameters.hpp:75
Facilities for exception-based handling of Runtime and Driver API errors, including a basic exception...
address_t address(const void *device_ptr) noexcept
Definition: types.hpp:684
size_t dimension_t
An individual dimension extent for an array.
Definition: types.hpp:91
A wrapper class for host and/or device pointers, allowing easy access to CUDA&#39;s pointer attributes...
this_type & set_destination(span< T > span) noexcept
Set the desintation of the copy operation to a range of multi-dimensional elements, starting at the beginning of a span of memory (in any CUDA memory space)
Definition: copy_parameters.hpp:262
Fundamental CUDA-related constants and enumerations, not dependent on any more complex abstractions...
bool is_intra_context() const noexcept
Definition: copy_parameters.hpp:82
this_type & set_endpoint(endpoint_t endpoint, const cuda::array_t< T, NumDimensions > &array) noexcept
Set one of the copy endpoints to a CUDA array.
this_type & set_source(span< T > span) noexcept
Set one of the copy endpoints to a multi-dimensional elements, starting at the beginning of a span of...
Definition: copy_parameters.hpp:202
this_type & set_pitches(dimension_type uniform_pitch_in_elements) noexcept
Set the difference, in elements, between the beginning of sequences of the minor-most dimension...
Definition: copy_parameters.hpp:313
this_type & set_source_untyped(context::handle_t context_handle, void *ptr, dimensions_type dimensions)
Set the source of the copy operation to be a sequence of multi-dimensional elements, with dimensions specified in bytes rather than actual elements, starting somewhere in memory (in any CUDA memory space)
Definition: copy_parameters.hpp:165
this_type & set_bytes_pitch(endpoint_t endpoint, dimension_type pitch_in_bytes) noexcept
Set the difference, in bytes, between the beginning of sequences of the minor-most dimension...
Definition: copy_parameters.hpp:294
this_type & set_pitch(endpoint_t endpoint, dimension_type pitch_in_elements) noexcept
Set the difference, in elements, between the beginning of sequences of the minor-most dimension...
Definition: copy_parameters.hpp:304
CUDA&#39;s array memory-objects are multi-dimensional; but their dimensions, or extents, are not the same as cuda::grid::dimensions_t ; they may be much larger in each axis.
Definition: types.hpp:102
void zero(void *start, size_t num_bytes, optional_ref< const stream_t > stream={})
Sets all bytes in a region of memory to 0 (zero)
Definition: memory.hpp:418
this_type & set_bytes_extent(dimensions_type extent_in_bytes) noexcept
Set how much is to be copied in each dimension - in bytes.