@@ -276,6 +276,9 @@ class HostTensorPlanarComplex {
276
276
// / Gets pointer to device data with a pointer offset
277
277
Element const * device_data_ptr_offset (LongIndex ptr_element_offset) const { return device_.get () + ptr_element_offset; }
278
278
279
+ // / Gets a pointer to the device data imaginary part
280
+ Element * device_data_imag () { return device_.get () + imaginary_stride (); }
281
+
279
282
// / Accesses the tensor reference pointing to data
280
283
TensorRef host_ref (LongIndex ptr_element_offset=0 ) {
281
284
return TensorRef (host_data_ptr_offset (ptr_element_offset), layout_, imaginary_stride ());
@@ -416,6 +419,166 @@ class HostTensorPlanarComplex {
416
419
device_data (), host_data (), imaginary_stride () * 2 );
417
420
}
418
421
}
422
+
423
+ // / Copy data from a caller-supplied device pointer into host memory.
424
+ void copy_in_device_to_host (
425
+ Element const * ptr_device_real, // /< source device memory
426
+ Element const * ptr_device_imag, // /< source device memory
427
+ LongIndex count = -1 ) { // /< number of elements to transfer; if negative, entire tensor is overwritten.
428
+
429
+ if (count < 0 ) {
430
+ count = capacity ();
431
+ }
432
+ else {
433
+ count = __NV_STD_MIN (capacity (), count);
434
+ }
435
+
436
+ device_memory::copy_to_host (
437
+ host_data (), ptr_device_real, count);
438
+
439
+ device_memory::copy_to_host (
440
+ host_data_imag (), ptr_device_imag, count);
441
+ }
442
+
443
+ // / Copy data from a caller-supplied device pointer into host memory.
444
+ void copy_in_device_to_device (
445
+ Element const * ptr_device_real, // /< source device memory
446
+ Element const * ptr_device_imag, // /< source device memory
447
+ LongIndex count = -1 ) { // /< number of elements to transfer; if negative, entire tensor is overwritten.
448
+
449
+ if (count < 0 ) {
450
+ count = capacity ();
451
+ }
452
+ else {
453
+ count = __NV_STD_MIN (capacity (), count);
454
+ }
455
+
456
+ device_memory::copy_device_to_device (
457
+ device_data (), ptr_device_real, count);
458
+
459
+ device_memory::copy_device_to_device (
460
+ device_data_imag (), ptr_device_imag, count);
461
+ }
462
+
463
+ // / Copy data from a caller-supplied device pointer into host memory.
464
+ void copy_in_host_to_device (
465
+ Element const * ptr_host_real, // /< source host memory
466
+ Element const * ptr_host_imag, // /< source host memory
467
+ LongIndex count = -1 ) { // /< number of elements to transfer; if negative, entire tensor is overwritten.
468
+
469
+ if (count < 0 ) {
470
+ count = capacity ();
471
+ }
472
+ else {
473
+ count = __NV_STD_MIN (capacity (), count);
474
+ }
475
+
476
+ device_memory::copy_to_device (
477
+ device_data (), ptr_host_real, count);
478
+
479
+ device_memory::copy_to_device (
480
+ device_data_imag (), ptr_host_imag, count);
481
+ }
482
+
483
+ // / Copy data from a caller-supplied device pointer into host memory.
484
+ void copy_in_host_to_host (
485
+ Element const * ptr_host_real, // /< source host memory
486
+ Element const * ptr_host_imag, // /< source host memory
487
+ LongIndex count = -1 ) { // /< number of elements to transfer; if negative, entire tensor is overwritten.
488
+
489
+ if (count < 0 ) {
490
+ count = capacity ();
491
+ }
492
+ else {
493
+ count = __NV_STD_MIN (capacity (), count);
494
+ }
495
+
496
+ device_memory::copy_host_to_host (
497
+ host_data (), ptr_host_real, count);
498
+
499
+ device_memory::copy_host_to_host (
500
+ host_data_imag (), ptr_host_imag, count);
501
+ }
502
+
503
+ // / Copy data from a caller-supplied device pointer into host memory.
504
+ void copy_out_device_to_host (
505
+ Element * ptr_host_real, // /< source device memory
506
+ Element * ptr_host_imag, // /< source device memory
507
+ LongIndex count = -1 ) const { // /< number of elements to transfer; if negative, entire tensor is overwritten.
508
+
509
+ if (count < 0 ) {
510
+ count = capacity ();
511
+ }
512
+ else {
513
+ count = __NV_STD_MIN (capacity (), count);
514
+ }
515
+
516
+ device_memory::copy_to_host (
517
+ ptr_host_real, device_data (), count);
518
+
519
+ device_memory::copy_to_host (
520
+ ptr_host_imag, device_data_imag (), count);
521
+ }
522
+
523
+ // / Copy data from a caller-supplied device pointer into host memory.
524
+ void copy_out_device_to_device (
525
+ Element * ptr_device_real, // /< source device memory
526
+ Element * ptr_device_imag, // /< source device memory
527
+ LongIndex count = -1 ) const { // /< number of elements to transfer; if negative, entire tensor is overwritten.
528
+
529
+ if (count < 0 ) {
530
+ count = capacity ();
531
+ }
532
+ else {
533
+ count = __NV_STD_MIN (capacity (), count);
534
+ }
535
+
536
+ device_memory::copy_device_to_device (
537
+ ptr_device_real, device_data (), count);
538
+
539
+ device_memory::copy_device_to_device (
540
+ ptr_device_imag, device_data_imag (), count);
541
+ }
542
+
543
+ // / Copy data from a caller-supplied device pointer into host memory.
544
+ void copy_out_host_to_device (
545
+ Element * ptr_device_real, // /< source device memory
546
+ Element * ptr_device_imag, // /< source device memory
547
+ LongIndex count = -1 ) const { // /< number of elements to transfer; if negative, entire tensor is overwritten.
548
+
549
+ if (count < 0 ) {
550
+ count = capacity ();
551
+ }
552
+ else {
553
+ count = __NV_STD_MIN (capacity (), count);
554
+ }
555
+
556
+ device_memory::copy_to_device (
557
+ ptr_device_real, host_data (), count);
558
+
559
+ device_memory::copy_to_device (
560
+ ptr_device_imag, host_data_imag (), count);
561
+ }
562
+
563
+ // / Copy data from a caller-supplied device pointer into host memory.
564
+ void copy_out_host_to_host (
565
+ Element * ptr_host_real, // /< source host memory
566
+ Element * ptr_host_imag, // /< source host memory
567
+ LongIndex count = -1 ) const { // /< number of elements to transfer; if negative, entire tensor is overwritten.
568
+
569
+ if (count < 0 ) {
570
+ count = capacity ();
571
+ }
572
+ else {
573
+ count = __NV_STD_MIN (capacity (), count);
574
+ }
575
+
576
+ device_memory::copy_host_to_host (
577
+ ptr_host_real, host_data (), count);
578
+
579
+ device_memory::copy_host_to_host (
580
+ ptr_host_imag, host_data_imag (), count);
581
+ }
419
582
};
420
583
421
584
// /////////////////////////////////////////////////////////////////////////////////////////////////
0 commit comments