149 class(batch_t),
intent(inout) :: this
150 integer,
optional,
intent(in) :: np
152 logical,
optional,
intent(in) :: async
154 integer :: ist_linear, ist, ip, np_
162 select case (this%status())
165 assert(np_ <= int(this%pack_size(2), int32))
170 assert(np_ <= int(this%pack_size(2), int32))
175 do ist = 1, int(this%pack_size(1), int32)
176 this%dff_pack(ist, ip) =
m_zero
183 do ist = 1, int(this%pack_size(1), int32)
192 assert(np_ <= ubound(this%dff_linear, dim=1))
193 do ist_linear = 1, this%nst_linear
196 this%dff_linear(ip, ist_linear) =
m_zero
201 assert(np_ <= ubound(this%zff_linear, dim=1))
202 do ist_linear = 1, this%nst_linear
205 this%zff_linear(ip, ist_linear) =
m_z0
211 message(1) =
"batch_set_zero: unknown batch status."
225 class(batch_t),
intent(in) :: this
226 integer,
intent(in) :: sp
227 integer,
intent(in) :: ep
228 type(accel_mem_t),
intent(inout) :: psi
229 integer,
intent(in) :: ldpsi1
230 integer,
intent(in) :: ldpsi2
232 integer :: tsize, ii, it
233 type(accel_kernel_t),
save :: kernel
234 integer,
allocatable :: linear_to_ist(:), linear_to_idim(:)
235 type(accel_mem_t) :: buff_linear_to_ist, buff_linear_to_idim
240 select case (this%status())
247 safe_allocate(linear_to_ist(1:this%nst_linear*tsize))
248 safe_allocate(linear_to_idim(1:this%nst_linear*tsize))
249 do ii = 1, this%nst_linear
251 linear_to_ist(tsize*(ii-1)+it) = tsize*(this%linear_to_ist(ii) - 1) + it - 1
252 linear_to_idim(tsize*(ii-1)+it) = this%linear_to_idim(ii) - 1
274 call accel_kernel_run(kernel, (/1_int64, int(ep - sp + 1, int64)/), (/this%pack_size_real(1), 1_int64/))
278 safe_deallocate_a(linear_to_ist)
279 safe_deallocate_a(linear_to_idim)
292 class(
batch_t),
intent(inout) :: this
293 integer,
intent(in) :: sp
294 integer,
intent(in) :: ep
296 integer,
intent(in) :: ldpsi1
297 integer,
intent(in) :: ldpsi2
299 integer :: tsize, ii, it
301 integer,
allocatable :: linear_to_ist(:), linear_to_idim(:)
302 type(
accel_mem_t) :: buff_linear_to_ist, buff_linear_to_idim
307 select case (this%status())
314 safe_allocate(linear_to_ist(1:this%nst_linear*tsize))
315 safe_allocate(linear_to_idim(1:this%nst_linear*tsize))
316 do ii = 1, this%nst_linear
318 linear_to_ist(tsize*(ii-1)+it) = tsize*(this%linear_to_ist(ii) - 1) + it - 1
319 linear_to_idim(tsize*(ii-1)+it) = this%linear_to_idim(ii) - 1
341 call accel_kernel_run(kernel, (/1_int64, int(ep - sp + 1, int64)/), (/this%pack_size_real(1), 1_int64/))
345 safe_deallocate_a(linear_to_ist)
346 safe_deallocate_a(linear_to_idim)
360 integer pure function batch_points_block_size() result(block_size)
368 integer,
intent(in) :: np
369 integer,
intent(in) :: map(:)
370 class(batch_t),
intent(in) :: xx
371 class(batch_t),
intent(in) :: yy
372 class(batch_t),
intent(inout) :: zz
373 type(accel_mem_t) :: buff_map
377 if (xx%status() /= batch_device_packed)
then
378 if (xx%type() == type_float)
then
385 call accel_create_buffer(buff_map, accel_mem_read_only, type_integer, np)
386 call accel_write_buffer(buff_map, np, map)
388 call accel_free_buffer(buff_map)
396 integer,
intent(in) :: np
397 class(accel_mem_t),
intent(in) :: map
398 class(batch_t),
intent(in) :: xx
399 class(batch_t),
intent(in) :: yy
400 class(batch_t),
intent(inout) :: zz
402 type(accel_kernel_t),
save :: kernel
403 integer(int64),
dimension(3) :: gsizes, bsizes
407 call accel_kernel_start_call(kernel,
'copy.cu',
'add_with_map')
409 call accel_set_kernel_arg(kernel, 0, np)
410 call accel_set_kernel_arg(kernel, 1, map)
411 call accel_set_kernel_arg(kernel, 2, xx%ff_device)
412 call accel_set_kernel_arg(kernel, 3,
log2(int(xx%pack_size_real(1), int32)))
413 call accel_set_kernel_arg(kernel, 4, yy%ff_device)
414 call accel_set_kernel_arg(kernel, 5,
log2(int(yy%pack_size_real(1), int32)))
415 call accel_set_kernel_arg(kernel, 6, zz%ff_device)
416 call accel_set_kernel_arg(kernel, 7,
log2(int(zz%pack_size_real(1), int32)))
419 call accel_grid_size_extend_dim(int(np, int64), xx%pack_size_real(1), gsizes, bsizes, kernel)
421 call accel_kernel_run(kernel, gsizes, bsizes)
428 integer,
intent(in) :: np
429 integer,
intent(in) :: map(:)
430 class(batch_t),
intent(in) :: xx
431 class(batch_t),
intent(inout) :: yy
432 type(accel_mem_t) :: buff_map
436 if (xx%status() /= batch_device_packed)
then
437 if (xx%type() == type_float)
then
444 call accel_create_buffer(buff_map, accel_mem_read_only, type_integer, np)
445 call accel_write_buffer(buff_map, np, map)
447 call accel_free_buffer(buff_map)
455 integer,
intent(in) :: np
456 class(accel_mem_t),
intent(in) :: map
457 class(batch_t),
intent(in) :: xx
458 class(batch_t),
intent(inout) :: yy
460 type(accel_kernel_t),
save :: kernel
461 integer(int64),
dimension(3) :: gsizes, bsizes
465 call accel_kernel_start_call(kernel,
'copy.cu',
'copy_with_map')
469 call accel_set_kernel_arg(kernel, 0, np)
470 call accel_set_kernel_arg(kernel, 1, map)
471 call accel_set_kernel_arg(kernel, 2, xx%ff_device)
472 call accel_set_kernel_arg(kernel, 3,
log2(int(xx%pack_size_real(1), int32)))
473 call accel_set_kernel_arg(kernel, 4, yy%ff_device)
474 call accel_set_kernel_arg(kernel, 5,
log2(int(yy%pack_size_real(1), int32)))
477 call accel_grid_size_extend_dim(int(np, int64), xx%pack_size_real(1), gsizes, bsizes, kernel)
479 call accel_kernel_run(kernel, gsizes, bsizes)
491 integer,
intent(in) :: np
492 class(batch_t),
intent(in) :: xx
493 class(batch_t),
intent(inout) :: yy
494 class(batch_t),
intent(inout) :: zz
496 integer :: ist_linear, ip
497 type(accel_kernel_t),
save :: kernel
498 integer(int64),
dimension(3) :: gsizes, bsizes
502 assert(xx%type() == type_cmplx)
503 assert(yy%type() == type_float)
504 assert(zz%type() == type_float)
505 assert(xx%status() == yy%status())
506 assert(xx%status() == zz%status())
508 select case (xx%status())
509 case (batch_not_packed)
510 do ist_linear = 1, xx%nst_linear
513 yy%dff_linear(ip, ist_linear) = real(xx%zff_linear(ip, ist_linear), real64)
514 zz%dff_linear(ip, ist_linear) = aimag(xx%zff_linear(ip, ist_linear))
520 do ist_linear = 1, xx%nst_linear
521 yy%dff_pack(ist_linear, ip) = real(xx%zff_pack(ist_linear, ip), real64)
522 zz%dff_pack(ist_linear, ip) = aimag(xx%zff_pack(ist_linear, ip))
525 case (batch_device_packed)
526 call accel_kernel_start_call(kernel,
'split.cu',
'split_complex')
528 call accel_set_kernel_arg(kernel, 0, int(xx%pack_size(2), int32))
529 call accel_set_kernel_arg(kernel, 1, xx%ff_device)
530 call accel_set_kernel_arg(kernel, 2,
log2(int(xx%pack_size(1), int32)))
531 call accel_set_kernel_arg(kernel, 3, yy%ff_device)
532 call accel_set_kernel_arg(kernel, 4,
log2(int(yy%pack_size(1), int32)))
533 call accel_set_kernel_arg(kernel, 5, zz%ff_device)
534 call accel_set_kernel_arg(kernel, 6,
log2(int(zz%pack_size(1), int32)))
537 call accel_grid_size_extend_dim(int(np, int64), xx%pack_size(1), gsizes, bsizes, kernel)
539 call accel_kernel_run(kernel, gsizes, bsizes)
546#include "batch_ops_inc.F90"
549#include "complex.F90"
550#include "batch_ops_inc.F90"
batchified version of the BLAS axpy routine:
scale a batch by a constant or vector
There are several ways how to call batch_set_state and batch_get_state:
double log2(double __x) __attribute__((__nothrow__
subroutine, public accel_free_buffer(this, async)
subroutine, public accel_kernel_start_call(this, file_name, kernel_name, flags)
integer, parameter, public accel_mem_read_only
This module implements batches of mesh functions.
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
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
This module implements common operations on batches of mesh functions.
subroutine zbatch_get_state3(this, ii, np, psi, async)
subroutine dbatch_get_state3(this, ii, np, psi, async)
subroutine batch_copy_with_map_accel(np, map, xx, yy)
subroutine zbatch_get_state1(this, ist, np, psi, async)
Write a get of state with np points from a batch.
subroutine, public zbatch_copy_with_map_to_array(np, map, xx, array)
Transfer a batch from the mesh to an array on the submesh (defined by a map)
subroutine, public dbatch_ax_function_py(np, aa, psi, yy)
This routine performs a set of axpy operations adding the same function psi to all functions of a bat...
subroutine dbatch_set_state1(this, ist, np, psi)
Write a single state with np points into a batch at position ist.
subroutine dbatch_axpy_const(np, aa, xx, yy)
This routine applies a 'pair-wise' axpy operation to all functions of the batches xx and yy,...
subroutine dbatch_mul(np, ff, xx, yy)
multiply all functions in a batch pointwise by a given mesh function ff
subroutine zbatch_get_points(this, sp, ep, psi)
copy a set of points into a mesh function
subroutine dbatch_xpay_vec(np, xx, aa, yy, a_start, a_full)
calculate yy(ist,:) = xx(ist,:) + aa(ist)*yy(ist,:) for a batch
subroutine dbatch_scal_vec(np, aa, xx, a_start, a_full)
scale all functions in a batch by state dependent constant
subroutine dbatch_set_state2(this, index, np, psi)
Write a single state with np points into a batch at position defined by index.
subroutine dbatch_copy_with_map(np, map, xx, yy)
subroutine, public dbatch_copy_with_map_to_array(np, map, xx, array)
Transfer a batch from the mesh to an array on the submesh (defined by a map)
subroutine dbatch_get_state2(this, index, np, psi, async)
subroutine dbatch_axpy_vec(np, aa, xx, yy, a_start, a_full)
This routine applies an 'pair-wise' axpy operation to all functions of the batches xx and yy,...
subroutine dbatch_set_state3(this, ii, np, psi)
Write a set of state with np points into a batch.
subroutine zbatch_axpy_const(np, aa, xx, yy)
This routine applies a 'pair-wise' axpy operation to all functions of the batches xx and yy,...
subroutine zbatch_scal_const(np, aa, xx)
scale all functions in a batch by constant aa
subroutine zbatch_get_state2(this, index, np, psi, async)
subroutine zbatch_mul(np, ff, xx, yy)
multiply all functions in a batch pointwise by a given mesh function ff
subroutine zbatch_xpay_const(np, xx, aa, yy)
calculate yy(ist) = xx(ist) + aa*yy(ist) for a batch
subroutine, public batch_split_complex(np, xx, yy, zz)
extract the real and imaginary parts of a complex batch
subroutine batch_add_with_map_accel(np, map, xx, yy, zz)
subroutine dbatch_set_points(this, sp, ep, psi)
copy a set of points into a mesh function
subroutine dbatch_get_state1(this, ist, np, psi, async)
Write a get of state with np points from a batch.
subroutine zbatch_copy_with_map(np, map, xx, yy)
subroutine, public batch_set_zero(this, np, async)
fill all mesh functions of the batch with zero
subroutine, public zbatch_ax_function_py(np, aa, psi, yy)
This routine performs a set of axpy operations adding the same function psi to all functions of a bat...
subroutine zbatch_axpy_vec(np, aa, xx, yy, a_start, a_full)
This routine applies an 'pair-wise' axpy operation to all functions of the batches xx and yy,...
subroutine batch_set_points_accel(this, sp, ep, psi, ldpsi1, ldpsi2)
GPU version of batch_set_points.
subroutine dbatch_xpay_const(np, xx, aa, yy)
calculate yy(ist) = xx(ist) + aa*yy(ist) for a batch
subroutine dbatch_get_points(this, sp, ep, psi)
copy a set of points into a mesh function
integer pure function, public batch_points_block_size()
determine the device block size
subroutine dbatch_add_with_map(np, map, xx, yy, zz)
subroutine zbatch_xpay_vec(np, xx, aa, yy, a_start, a_full)
calculate yy(ist,:) = xx(ist,:) + aa(ist)*yy(ist,:) for a batch
subroutine zbatch_set_state1(this, ist, np, psi)
Write a single state with np points into a batch at position ist.
subroutine batch_add_with_map_cpu(np, map, xx, yy, zz)
subroutine zbatch_scal_vec(np, aa, xx, a_start, a_full)
scale all functions in a batch by state dependent constant
subroutine zbatch_set_state2(this, index, np, psi)
Write a single state with np points into a batch at position defined by index.
subroutine, public zbatch_axpy_function(np, aa, xx, psi, nst)
This routine performs a set of axpy operations for each function x of a batch (xx),...
subroutine zbatch_set_points(this, sp, ep, psi)
copy a set of points into a mesh function
subroutine zbatch_add_with_map(np, map, xx, yy, zz)
subroutine, public dbatch_axpy_function(np, aa, xx, psi, nst)
This routine performs a set of axpy operations for each function x of a batch (xx),...
subroutine batch_get_points_accel(this, sp, ep, psi, ldpsi1, ldpsi2)
GPU version of batch_get_points.
subroutine zbatch_set_state3(this, ii, np, psi)
Write a set of state with np points into a batch.
subroutine batch_copy_with_map_cpu(np, map, xx, yy)
subroutine dbatch_scal_const(np, aa, xx)
scale all functions in a batch by constant aa
This module contains interfaces for BLAS routines You should not use these routines directly....
real(real64), parameter, public m_zero
logical pure function, public not_in_openmp()
complex(real64), parameter, public m_z0
This module is intended to contain "only mathematical" functions and procedures.
subroutine, public messages_not_implemented(feature, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
type(type_t), public type_float
type(type_t), public type_integer
integer pure function, public types_get_size(this)
Class defining batches of mesh functions.