69 integer,
public :: nst
70 integer,
public :: dim
73 integer,
allocatable :: ist_idim_index(:, :)
78 integer,
allocatable,
public :: ist(:)
85 logical :: is_allocated
88 integer,
public :: nst_linear
94 integer :: status_host
103 type(type_t) :: type_of
104 integer :: device_buffer_count
105 integer :: host_buffer_count
106 logical :: special_memory
107 logical :: needs_finish_unpack
111 real(real64),
pointer,
contiguous,
public :: dff(:, :, :)
113 complex(real64),
pointer,
contiguous,
public :: zff(:, :, :)
115 real(real64),
pointer,
contiguous,
public :: dff_linear(:, :)
117 complex(real64),
pointer,
contiguous,
public :: zff_linear(:, :)
121 real(real64),
pointer,
contiguous,
public :: dff_pack(:, :)
123 complex(real64),
pointer,
contiguous,
public :: zff_pack(:, :)
126 integer(int64),
public :: pack_size(1:2)
128 integer(int64),
public :: pack_size_real(1:2)
132 type(accel_mem_t),
public :: ff_device
142 generic :: do_pack => do_pack_generic, do_pack_target
192 integer,
public,
parameter :: &
193 batch_not_packed = 0, & !< functions are stored in CPU memory, unpacked order
211 class(
batch_t),
intent(inout) :: this
212 logical,
optional,
intent(in) :: copy
217 if (this%own_memory .and. this%is_packed())
then
220 call this%deallocate_packed_device()
223 call this%deallocate_packed_host()
227 this%host_buffer_count = 0
228 this%device_buffer_count = 0
233 if (this%is_allocated)
then
234 call this%deallocate_unpacked_host()
237 safe_deallocate_a(this%ist_idim_index)
238 safe_deallocate_a(this%ist)
253 this%is_allocated = .false.
255 if (this%special_memory)
then
256 if (
associated(this%dff))
then
259 if (
associated(this%zff))
then
263 safe_deallocate_p(this%dff)
264 safe_deallocate_p(this%zff)
267 nullify(this%dff_linear)
269 nullify(this%zff_linear)
280 class(batch_t),
intent(inout) :: this
284 if (this%special_memory)
then
285 if (
associated(this%dff_pack))
then
288 if (
associated(this%zff_pack))
then
292 safe_deallocate_p(this%dff_pack)
293 safe_deallocate_p(this%zff_pack)
295 nullify(this%dff_pack)
296 nullify(this%zff_pack)
320 class(
batch_t),
intent(inout) :: this
325 call this%dallocate_unpacked_host()
327 call this%zallocate_unpacked_host()
339 class(
batch_t),
intent(inout) :: this
344 call this%dallocate_packed_host()
346 call this%zallocate_packed_host()
358 class(
batch_t),
intent(inout) :: this
363 product(this%pack_size))
376 type(
batch_t),
intent(out) :: this
377 integer,
intent(in) :: dim
378 integer,
intent(in) :: nst
379 integer,
intent(in) :: np
383 this%is_allocated = .false.
384 this%own_memory = .false.
385 this%special_memory = .false.
386 this%needs_finish_unpack = .false.
391 this%nst_linear = nst*dim
394 this%device_buffer_count = 0
395 this%host_buffer_count = 0
400 safe_allocate(this%ist_idim_index(1:this%nst_linear, 1:this%ndims))
401 safe_allocate(this%ist(1:this%nst))
403 nullify(this%dff, this%zff, this%dff_linear, this%zff_linear)
404 nullify(this%dff_pack, this%zff_pack)
415 subroutine batch_clone_to(this, dest, pack, copy_data, new_np, special, dest_type)
416 class(
batch_t),
intent(in) :: this
417 class(
batch_t),
allocatable,
intent(out) :: dest
418 logical,
optional,
intent(in) :: pack
420 logical,
optional,
intent(in) :: copy_data
422 integer,
optional,
intent(in) :: new_np
423 logical,
optional,
intent(in) :: special
425 type(
type_t),
optional,
intent(in) :: dest_type
429 if (.not.
allocated(dest))
then
430 safe_allocate_type(
batch_t, dest)
432 message(1) =
"Internal error: destination batch in batch_clone_to has been previously allocated."
436 call this%copy_to(dest, pack, copy_data, new_np, special, dest_type)
443 subroutine batch_clone_to_array(this, dest, n_batches, pack, copy_data, new_np, special, dest_type)
444 class(
batch_t),
intent(in) :: this
445 class(
batch_t),
allocatable,
intent(out) :: dest(:)
446 integer,
intent(in) :: n_batches
447 logical,
optional,
intent(in) :: pack
449 logical,
optional,
intent(in) :: copy_data
451 integer,
optional,
intent(in) :: new_np
452 logical,
optional,
intent(in) :: special
454 type(
type_t),
optional,
intent(in) :: dest_type
460 if (.not.
allocated(dest))
then
461 safe_allocate_type_array(
batch_t, dest, (1:n_batches))
463 message(1) =
"Internal error: destination batch in batch_clone_to_array has been previously allocated."
468 call this%copy_to(dest(ib), pack, copy_data, new_np, special, dest_type)
479 subroutine batch_copy_to(this, dest, pack, copy_data, new_np, special, dest_type)
480 class(
batch_t),
intent(in) :: this
481 class(
batch_t),
intent(out) :: dest
482 logical,
optional,
intent(in) :: pack
484 logical,
optional,
intent(in) :: copy_data
486 integer,
optional,
intent(in) :: new_np
487 logical,
optional,
intent(in) :: special
489 type(
type_t),
optional,
intent(in) :: dest_type
491 logical :: host_packed, special_
499 host_packed = this%host_buffer_count > 0
503 if (
present(special))
then
504 special_ = this%special_memory
506 special_ = this%special_memory .and. .not. this%device_buffer_count > 0
509 if (
present(dest_type))
then
516 call dbatch_init(dest, this%dim, 1, this%nst, np_, packed=host_packed, special=special_)
518 call zbatch_init(dest, this%dim, 1, this%nst, np_, packed=host_packed, special=special_)
520 message(1) =
"Internal error: unknown batch type in batch_copy_to."
524 if (this%status() /= dest%status() .and.
optional_default(pack, this%is_packed()))
call dest%do_pack(copy = .false.)
526 dest%ist_idim_index(1:this%nst_linear, 1:this%ndims) = this%ist_idim_index(1:this%nst_linear, 1:this%ndims)
527 dest%ist(1:this%nst) = this%ist(1:this%nst)
530 assert(np_ == this%np)
531 call this%copy_data_to(min(this%np, np_), dest)
542 type(
type_t)
pure function batch_type(this) result(btype)
543 class(
batch_t),
intent(in) :: this
551 integer pure function batch_type_as_integer(this) result(itype)
552 class(
batch_t),
intent(in) :: this
554 type(type_t) :: btype
558 if (btype == type_float) itype = 1
559 if (btype == type_cmplx) itype = 2
568 integer pure function batch_status(this) result(bstatus)
569 class(
batch_t),
intent(in) :: this
571 bstatus = this%status_of
576 logical pure function batch_is_packed(this) result(in_buffer)
577 class(
batch_t),
intent(in) :: this
579 in_buffer = (this%device_buffer_count > 0) .or. (this%host_buffer_count > 0)
585 class(
batch_t),
intent(inout) :: this
588 if (accel_is_enabled())
size = accel_padded_size(size)
589 size = size*pad_pow2(this%nst_linear)*types_get_size(this%type())
601 class(
batch_t),
intent(inout) :: this
602 logical,
optional,
intent(in) :: copy
603 logical,
optional,
intent(in) :: async
606 integer :: source, target
611 source = this%status()
614 if (accel_is_enabled())
then
623 call this%do_pack(
target, copy, async)
632 class(
batch_t),
intent(inout) :: this
633 integer,
intent(in) ::
target
634 logical,
optional,
intent(in) :: copy
635 logical,
optional,
intent(in) :: async
637 logical,
optional,
intent(in) :: cpu_only
645 call profiling_in(
"BATCH_DO_PACK")
647 copy_ = optional_default(copy, .
true.)
649 async_ = optional_default(async, .false.)
652 source = this%status()
655 if (source /=
target)
then
658 call this%allocate_packed_device()
672 call this%allocate_packed_host()
677 if (this%type() == type_float)
then
679 else if (this%type() == type_cmplx)
then
683 if (this%own_memory)
call this%deallocate_unpacked_host()
685 call messages_not_implemented(
"Error: batch_do_pack called with BATCH_NOT_PACKED as target.")
691 this%device_buffer_count = this%device_buffer_count + 1
693 this%host_buffer_count = this%host_buffer_count + 1
696 call profiling_out(
"BATCH_DO_PACK")
706 class(
batch_t),
intent(inout) :: this
707 logical,
optional,
intent(in) :: copy
708 logical,
optional,
intent(in) :: force
709 logical,
optional,
intent(in) :: async
712 logical :: copy_, force_, async_
713 integer :: source, target
717 call profiling_in(
"BATCH_DO_UNPACK")
719 copy_ = optional_default(copy, .
true.)
721 force_ = optional_default(force, .false.)
723 async_ = optional_default(async, .false.)
726 source = this%status()
733 target = this%status_host
737 if (source /=
target)
then
740 if (this%host_buffer_count == 1 .or. force_)
then
741 if (this%own_memory)
call this%allocate_unpacked_host()
743 if (copy_ .or. this%own_memory)
then
744 if (this%type() == type_float)
then
746 else if (this%type() == type_cmplx)
then
750 call this%deallocate_packed_host()
751 this%status_host =
target
752 this%status_of =
target
753 this%host_buffer_count = 1
755 this%host_buffer_count = this%host_buffer_count - 1
757 if (this%device_buffer_count == 1 .or. force_)
then
769 this%needs_finish_unpack = .
true.
771 call this%deallocate_packed_device()
773 this%status_of =
target
774 this%device_buffer_count = 1
776 this%device_buffer_count = this%device_buffer_count - 1
780 call profiling_out(
"BATCH_DO_UNPACK")
788 class(
batch_t),
intent(inout) :: this
791 if (this%needs_finish_unpack)
then
793 call this%deallocate_packed_device()
794 this%needs_finish_unpack = .false.
802 class(
batch_t),
intent(inout) :: this
805 integer(int64) :: unroll, bsize, gsize
806 type(accel_mem_t) :: tmp
807 type(accel_kernel_t),
pointer :: kernel
811 call profiling_in(
"BATCH_WRT_UNPACK_ACCEL")
812 if (this%nst_linear == 1)
then
814 if (this%type() == type_float)
then
815 call accel_write_buffer(this%ff_device, ubound(this%dff_linear, dim=1), this%dff_linear(:, 1))
816 else if (this%type() == type_cmplx)
then
817 call accel_write_buffer(this%ff_device, ubound(this%zff_linear, dim=1), this%zff_linear(:, 1))
825 if (this%type() == type_float)
then
833 call accel_create_buffer(tmp, accel_mem_read_only, this%type(), unroll*this%pack_size(2))
835 do ist = 1, this%nst_linear, int(unroll, int32)
838 do ist2 = ist, min(ist + int(unroll, int32) - 1, this%nst_linear)
840 if (this%type() == type_float)
then
841 call accel_write_buffer(tmp, ubound(this%dff_linear, dim=1, kind=int64), this%dff_linear(:, ist2), &
842 offset = (ist2 - ist)*this%pack_size(2))
844 call accel_write_buffer(tmp, ubound(this%zff_linear, dim=1, kind=int64), this%zff_linear(:, ist2), &
845 offset = (ist2 - ist)*this%pack_size(2))
850 call accel_set_kernel_arg(kernel, 0, int(this%pack_size(1), int32))
851 call accel_set_kernel_arg(kernel, 1, this%np)
852 call accel_set_kernel_arg(kernel, 2, this%nst_linear)
853 call accel_set_kernel_arg(kernel, 3, ist - 1)
854 call accel_set_kernel_arg(kernel, 4, tmp)
855 call accel_set_kernel_arg(kernel, 5, this%ff_device)
857 call profiling_in(
"GPU_PACK")
860 bsize = accel_max_block_size()/unroll
861 call accel_grid_size(this%pack_size(2), bsize, gsize)
863 call accel_kernel_run(kernel, (/gsize, 1_int64/), (/bsize, unroll/))
865 if (this%type() == type_float)
then
866 call profiling_count_transfers(unroll*this%pack_size(2), m_one)
868 call profiling_count_transfers(unroll*this%pack_size(2), m_zi)
872 call profiling_out(
"GPU_PACK")
876 call accel_free_buffer(tmp)
880 call profiling_out(
"BATCH_WRT_UNPACK_ACCEL")
887 class(
batch_t),
intent(inout) :: this
890 integer(int64) :: unroll, bsize, gsize
891 type(accel_mem_t) :: tmp
892 type(accel_kernel_t),
pointer :: kernel
895 call profiling_in(
"BATCH_READ_UNPACKED_ACCEL")
897 if (this%nst_linear == 1)
then
899 if (this%type() == type_float)
then
900 call accel_read_buffer(this%ff_device, ubound(this%dff_linear, dim=1), this%dff_linear(:, 1))
902 call accel_read_buffer(this%ff_device, ubound(this%zff_linear, dim=1), this%zff_linear(:, 1))
909 call accel_create_buffer(tmp, accel_mem_write_only, this%type(), unroll*this%pack_size(2))
911 if (this%type() == type_float)
then
917 do ist = 1, this%nst_linear, int(unroll, int32)
918 call accel_set_kernel_arg(kernel, 0, int(this%pack_size(1), int32))
919 call accel_set_kernel_arg(kernel, 1, this%np)
920 call accel_set_kernel_arg(kernel, 2, this%nst_linear)
921 call accel_set_kernel_arg(kernel, 3, ist - 1)
922 call accel_set_kernel_arg(kernel, 4, this%ff_device)
923 call accel_set_kernel_arg(kernel, 5, tmp)
925 call profiling_in(
"GPU_UNPACK")
928 bsize = accel_max_block_size()/unroll
929 call accel_grid_size(this%pack_size(2), bsize, gsize)
931 call accel_kernel_run(kernel, (/1_int64, gsize/), (/unroll, bsize/))
933 if (this%type() == type_float)
then
934 call profiling_count_transfers(unroll*this%pack_size(2), m_one)
936 call profiling_count_transfers(unroll*this%pack_size(2), m_zi)
940 call profiling_out(
"GPU_UNPACK")
943 do ist2 = ist, min(ist + int(unroll, int32) - 1, this%nst_linear)
945 if (this%type() == type_float)
then
946 call accel_read_buffer(tmp, ubound(this%dff_linear, dim=1, kind=int64), this%dff_linear(:, ist2), &
947 offset = (ist2 - ist)*this%pack_size(2))
949 call accel_read_buffer(tmp, ubound(this%zff_linear, dim=1, kind=int64), this%zff_linear(:, ist2), &
950 offset = (ist2 - ist)*this%pack_size(2))
956 call accel_free_buffer(tmp)
959 call profiling_out(
"BATCH_READ_UNPACKED_ACCEL")
965 class(
batch_t),
intent(inout) :: this
966 logical,
optional,
intent(in) :: async
971 call profiling_in(
"BATCH_WRITE_PACKED_ACCEL")
972 if (this%type() == type_float)
then
973 call accel_write_buffer(this%ff_device, this%pack_size(1), this%pack_size(2), this%dff_pack, async=async)
975 call accel_write_buffer(this%ff_device, this%pack_size(1), this%pack_size(2), this%zff_pack, async=async)
977 call profiling_out(
"BATCH_WRITE_PACKED_ACCEL")
984 class(
batch_t),
intent(inout) :: this
985 logical,
optional,
intent(in) :: async
990 call profiling_in(
"BATCH_READ_PACKED_ACCEL")
991 if (this%type() == type_float)
then
992 call accel_read_buffer(this%ff_device, this%pack_size(1), this%pack_size(2), this%dff_pack, async=async)
994 call accel_read_buffer(this%ff_device, this%pack_size(1), this%pack_size(2), this%zff_pack, async=async)
996 call profiling_out(
"BATCH_READ_PACKED_ACCEL")
1007 class(
batch_t),
intent(in) :: this
1008 integer,
intent(in) :: cind(:)
1010 do index = 1, this%nst_linear
1011 if (all(cind(1:this%ndims) == this%ist_idim_index(index, 1:this%ndims)))
exit
1014 assert(index <= this%nst_linear)
1023 integer pure function batch_ist_idim_to_linear(this, cind) result(index)
1024 class(
batch_t),
intent(in) :: this
1025 integer,
intent(in) :: cind(:)
1027 if (ubound(cind, dim = 1) == 1)
then
1030 index = (cind(1) - 1)*this%dim + cind(2)
1041 integer pure function batch_linear_to_ist(this, linear_index) result(ist)
1042 class(
batch_t),
intent(in) :: this
1043 integer,
intent(in) :: linear_index
1045 ist = this%ist_idim_index(linear_index, 1)
1052 integer pure function batch_linear_to_idim(this, linear_index) result(idim)
1053 class(
batch_t),
intent(in) :: this
1054 integer,
intent(in) :: linear_index
1056 idim = this%ist_idim_index(linear_index, 2)
1071 class(
batch_t),
intent(inout) :: this
1072 type(mpi_grp_t),
intent(in) :: mpi_grp
1073 type(mpi_win),
intent(out) :: rma_win
1077 if (mpi_grp%size > 1)
then
1079 assert(.not. accel_is_enabled())
1083 assert(int(product(this%pack_size)*types_get_size(this%type())) > 0)
1084 if (this%type() == type_cmplx)
then
1086 call mpi_win_create(this%zff_pack(1, 1), int(product(this%pack_size)*types_get_size(this%type()), mpi_address_kind), &
1087 types_get_size(this%type()), mpi_info_null, mpi_grp%comm, rma_win)
1089 else if (this%type() == type_float)
then
1091 call mpi_win_create(this%dff_pack(1, 1), int(product(this%pack_size)*types_get_size(this%type()), mpi_address_kind), &
1092 types_get_size(this%type()), mpi_info_null, mpi_grp%comm, rma_win)
1095 message(1) =
"Internal error: unknown batch type in batch_remote_access_start."
1096 call messages_fatal(1)
1100 rma_win = mpi_win_null
1114 class(
batch_t),
intent(inout) :: this
1115 type(mpi_win),
intent(inout) :: rma_win
1119 if (rma_win /= mpi_win_null)
then
1121 call mpi_win_free(rma_win)
1123 call this%do_unpack()
1133 class(
batch_t),
intent(in) :: this
1134 integer,
intent(in) :: np
1135 class(
batch_t),
intent(inout) :: dest
1136 logical,
optional,
intent(in) :: async
1138 integer(int64),
dimension(3) :: gsizes, bsizes
1142 call profiling_in(
"BATCH_COPY_DATA_TO")
1145 call this%check_compatibility_with(dest, type_check=.false.)
1147 if (this%type() == dest%type())
then
1148 select case (this%status())
1150 call accel_set_kernel_arg(kernel_copy, 0, np)
1151 call accel_set_kernel_arg(kernel_copy, 1, this%ff_device)
1152 call accel_set_kernel_arg(kernel_copy, 2,
log2(int(this%pack_size_real(1), int32)))
1153 call accel_set_kernel_arg(kernel_copy, 3, dest%ff_device)
1154 call accel_set_kernel_arg(kernel_copy, 4,
log2(int(dest%pack_size_real(1), int32)))
1157 call accel_grid_size_extend_dim(int(np, int64), dest%pack_size_real(1), gsizes, bsizes, kernel_copy)
1159 call accel_kernel_run(kernel_copy, gsizes, bsizes)
1161 if(.not. optional_default(async, .false.))
call accel_finish()
1164 if (np*this%pack_size(1) > huge(0_int32))
then
1167 if (dest%type() == type_float)
then
1168 call blas_copy(int(this%pack_size(1), int32), this%dff_pack(1, ip), 1, dest%dff_pack(1, ip), 1)
1170 call blas_copy(int(this%pack_size(1), int32), this%zff_pack(1, ip), 1, dest%zff_pack(1, ip), 1)
1174 if (dest%type() == type_float)
then
1175 call blas_copy(int(this%pack_size(1)*np, int32), this%dff_pack(1, 1), 1, dest%dff_pack(1, 1), 1)
1177 call blas_copy(int(this%pack_size(1)*np, int32), this%zff_pack(1, 1), 1, dest%zff_pack(1, 1), 1)
1182 do ist = 1, dest%nst_linear
1183 if (dest%type() == type_cmplx)
then
1184 call blas_copy(np, this%zff_linear(1, ist), 1, dest%zff_linear(1, ist), 1)
1186 call blas_copy(np, this%dff_linear(1, ist), 1, dest%dff_linear(1, ist), 1)
1191 else if (this%type() == type_cmplx)
then
1193 select case (this%status())
1195 call accel_set_kernel_arg(kernel_copy_complex_to_real, 0, np)
1196 call accel_set_kernel_arg(kernel_copy_complex_to_real, 1, this%ff_device)
1197 call accel_set_kernel_arg(kernel_copy_complex_to_real, 2,
log2(int(this%pack_size_real(1), int32)))
1198 call accel_set_kernel_arg(kernel_copy_complex_to_real, 3, dest%ff_device)
1199 call accel_set_kernel_arg(kernel_copy_complex_to_real, 4,
log2(int(dest%pack_size_real(1), int32)))
1202 call accel_grid_size_extend_dim(int(np, int64), dest%pack_size_real(1), gsizes, bsizes, kernel_copy_complex_to_real)
1204 call accel_kernel_run(kernel_copy_complex_to_real, gsizes, bsizes)
1206 if(.not. optional_default(async, .false.))
call accel_finish()
1212 do ist = 1, dest%nst_linear
1213 dest%dff_pack(ist, ip) = real(this%zff_pack(ist, ip), real64)
1219 do ist = 1, dest%nst_linear
1222 dest%dff_linear(ip, ist) = real(this%zff_linear(ip, ist), real64)
1228 else if (this%type() == type_float)
then
1230 select case (this%status())
1232 call accel_set_kernel_arg(kernel_copy_real_to_complex, 0, np)
1233 call accel_set_kernel_arg(kernel_copy_real_to_complex, 1, this%ff_device)
1234 call accel_set_kernel_arg(kernel_copy_real_to_complex, 2,
log2(int(this%pack_size_real(1), int32)))
1235 call accel_set_kernel_arg(kernel_copy_real_to_complex, 3, dest%ff_device)
1236 call accel_set_kernel_arg(kernel_copy_real_to_complex, 4,
log2(int(dest%pack_size_real(1), int32)))
1239 call accel_grid_size_extend_dim(int(np, int64), this%pack_size_real(1), gsizes, bsizes, kernel_copy_real_to_complex)
1241 call accel_kernel_run(kernel_copy_real_to_complex, gsizes, bsizes)
1243 if(.not. optional_default(async, .false.))
call accel_finish()
1249 do ist = 1, dest%nst_linear
1250 dest%zff_pack(ist, ip) = cmplx(this%dff_pack(ist, ip), m_zero, real64)
1256 do ist = 1, dest%nst_linear
1259 dest%zff_linear(ip, ist) = cmplx(this%dff_linear(ip, ist), m_zero, real64)
1266 message(1) =
"Error! This should not happen."
1267 call messages_fatal(1)
1270 call profiling_out(
"BATCH_COPY_DATA_TO")
1278 class(
batch_t),
intent(in) :: this
1279 class(
batch_t),
intent(in) :: target
1280 logical,
optional,
intent(in) :: only_check_dim
1281 logical,
optional,
intent(in) :: type_check
1285 if (optional_default(type_check, .
true.))
then
1286 assert(this%type() ==
target%type())
1288 if (.not. optional_default(only_check_dim, .false.))
then
1289 assert(this%nst_linear ==
target%nst_linear)
1291 assert(this%status() ==
target%status())
1292 assert(this%dim ==
target%dim)
1302 class(
batch_t),
intent(inout) :: this
1303 integer,
intent(in) :: st_start
1304 integer,
intent(in) :: st_end
1306 integer :: idim, ii, ist
1310 do ist = st_start, st_end
1312 do idim = 1, this%dim
1313 ii = this%dim*(ist - st_start) + idim
1314 this%ist_idim_index(ii, 1) = ist
1315 this%ist_idim_index(ii, 2) = idim
1317 this%ist(ist - st_start + 1) = ist
1321 this%pack_size(1) = pad_pow2(this%nst_linear)
1322 this%pack_size(2) = this%np
1323 if (accel_is_enabled()) this%pack_size(2) = accel_padded_size(this%pack_size(2))
1325 this%pack_size_real = this%pack_size
1326 if (type_is_complex(this%type())) this%pack_size_real(1) = 2*this%pack_size_real(1)
1333#include "batch_inc.F90"
1336#include "complex.F90"
1337#include "batch_inc.F90"
initialize a batch with existing memory
double log2(double __x) __attribute__((__nothrow__
subroutine, public accel_free_buffer(this, async)
integer, parameter, public accel_mem_read_write
This module contains interfaces for routines in allocate_hardware_aware.c.
subroutine, public deallocate_hardware_aware(array, size)
This module implements batches of mesh functions.
type(type_t) pure function batch_type(this)
return the type of a batch
subroutine zbatch_pack_copy(this)
copy data from the unpacked to the packed arrays
subroutine, public batch_write_packed_to_device(this, async)
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
subroutine zbatch_init_with_memory_3(this, dim, st_start, st_end, psi)
initialize a batch with an rank-3 array of TYPE_CMPLX valued mesh functions psi.
subroutine batch_check_compatibility_with(this, target, only_check_dim, type_check)
check whether two batches have compatible dimensions (and type)
logical pure function batch_is_packed(this)
subroutine dbatch_unpack_copy(this)
copy data from the packed to the unpacked arrays
subroutine dbatch_init_with_memory_1(this, psi)
initialize a batch with an rank-1 array of TYPE_FLOAT valued mesh functions psi.
subroutine batch_write_unpacked_to_device(this)
subroutine batch_do_unpack(this, copy, force, async)
unpack a batch
subroutine batch_finish_unpack(this)
finish the unpacking if do_unpack() was called with async=.true.
subroutine zbatch_allocate_unpacked_host(this)
allocate host (CPU) memory for unpacked data of type TYPE_CMPLX
subroutine batch_deallocate_packed_device(this)
release packed device memory
integer pure function batch_type_as_integer(this)
For debuging purpose only.
subroutine batch_do_pack_generic(this, copy, async)
pack the data in a batch
integer function batch_inv_index(this, cind)
inverse index lookup
subroutine dbatch_init_with_memory_2(this, dim, st_start, st_end, psi)
initialize a batch with an rank-2 array of TYPE_FLOAT valued mesh functions psi.
subroutine batch_allocate_packed_host(this)
allocate host (CPU) memory for packed data
subroutine, public zbatch_init(this, dim, st_start, st_end, np, special, packed)
initialize a TYPE_CMPLX valued batch to given size without providing external memory
subroutine zbatch_allocate_packed_host(this)
allocate host (CPU) memory for packed data of type TYPE_CMPLX
subroutine batch_clone_to(this, dest, pack, copy_data, new_np, special, dest_type)
clone a batch to a new batch
subroutine batch_remote_access_stop(this, rma_win)
stop the remote access to the batch
subroutine batch_read_device_to_unpacked(this)
subroutine zbatch_init_with_memory_1(this, psi)
initialize a batch with an rank-1 array of TYPE_CMPLX valued mesh functions psi.
subroutine dbatch_allocate_packed_host(this)
allocate host (CPU) memory for packed data of type TYPE_FLOAT
subroutine batch_clone_to_array(this, dest, n_batches, pack, copy_data, new_np, special, dest_type)
subroutine batch_allocate_packed_device(this)
allocate device (GPU) memory for packed data
subroutine batch_build_indices(this, st_start, st_end)
build the index ist(:) and ist_idim_index(:,:) and set pack_size
integer pure function batch_ist_idim_to_linear(this, cind)
direct index lookup
integer, parameter gpu_pack_max_buffer_size
this value controls the size (in number of wave-functions) of the buffer used to copy states to the G...
subroutine batch_do_pack_target(this, target, copy, async, cpu_only)
pack the data in a batch
integer pure function batch_linear_to_ist(this, linear_index)
get state index ist from linear (combined dim and nst) index
subroutine batch_copy_to(this, dest, pack, copy_data, new_np, special, dest_type)
make a copy of a batch
subroutine, public batch_read_device_to_packed(this, async)
subroutine dbatch_init_with_memory_3(this, dim, st_start, st_end, psi)
initialize a batch with an rank-3 array of TYPE_FLOAT valued mesh functions psi.
subroutine batch_allocate_unpacked_host(this)
allocate host (CPU) memory for unpacked data
subroutine batch_init_empty(this, dim, nst, np)
initialize an empty batch
subroutine, public dbatch_init(this, dim, st_start, st_end, np, special, packed)
initialize a TYPE_FLOAT valued batch to given size without providing external memory
subroutine zbatch_init_with_memory_2(this, dim, st_start, st_end, psi)
initialize a batch with an rank-2 array of TYPE_CMPLX valued mesh functions psi.
integer pure function batch_linear_to_idim(this, linear_index)
extract idim from linear index
subroutine batch_remote_access_start(this, mpi_grp, rma_win)
start remote access to a batch on another node
subroutine batch_copy_data_to(this, np, dest, async)
copy data to another batch.
subroutine dbatch_allocate_unpacked_host(this)
allocate host (CPU) memory for unpacked data of type TYPE_FLOAT
subroutine dbatch_pack_copy(this)
copy data from the unpacked to the packed arrays
integer pure function batch_status(this)
return the status of a batch
subroutine batch_deallocate_unpacked_host(this)
release unpacked host memory
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
subroutine batch_deallocate_packed_host(this)
release packed host memory
integer(int64) function batch_pack_total_size(this)
subroutine batch_end(this, copy)
finalize a batch and release allocated memory, if necessary
subroutine zbatch_unpack_copy(this)
copy data from the packed to the unpacked arrays
This module contains interfaces for BLAS routines You should not use these routines directly....
This module is intended to contain "only mathematical" functions and procedures.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
type(type_t), parameter, public type_cmplx
type(type_t), parameter, public type_float
type(type_t), parameter, public type_none
Class defining batches of mesh functions.