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)
184 this%zff_pack(ist, ip) =
m_z0
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, (/this%pack_size_real(1), 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, (/this%pack_size_real(1), 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_release_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) :: localsize, dim3, dim2
407 call accel_kernel_start_call(kernel,
'copy.cl',
'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)))
418 localsize = accel_kernel_workgroup_size(kernel)/xx%pack_size_real(1)
420 dim3 = np/(accel_max_size_per_dim(2)*localsize) + 1
421 dim2 = min(accel_max_size_per_dim(2)*localsize, pad(np, localsize))
423 call accel_kernel_run(kernel, (/xx%pack_size_real(1), dim2, dim3/), (/xx%pack_size_real(1), localsize, 1_int64/))
430 integer,
intent(in) :: np
431 integer,
intent(in) :: map(:)
432 class(batch_t),
intent(in) :: xx
433 class(batch_t),
intent(inout) :: yy
434 type(accel_mem_t) :: buff_map
438 if (xx%status() /= batch_device_packed)
then
439 if (xx%type() == type_float)
then
446 call accel_create_buffer(buff_map, accel_mem_read_only, type_integer, np)
447 call accel_write_buffer(buff_map, np, map)
449 call accel_release_buffer(buff_map)
457 integer,
intent(in) :: np
458 class(accel_mem_t),
intent(in) :: map
459 class(batch_t),
intent(in) :: xx
460 class(batch_t),
intent(inout) :: yy
462 type(accel_kernel_t),
save :: kernel
463 integer(int64) :: localsize, dim3, dim2
467 call accel_kernel_start_call(kernel,
'copy.cl',
'copy_with_map')
471 call accel_set_kernel_arg(kernel, 0, np)
472 call accel_set_kernel_arg(kernel, 1, map)
473 call accel_set_kernel_arg(kernel, 2, xx%ff_device)
474 call accel_set_kernel_arg(kernel, 3,
log2(int(xx%pack_size_real(1), int32)))
475 call accel_set_kernel_arg(kernel, 4, yy%ff_device)
476 call accel_set_kernel_arg(kernel, 5,
log2(int(yy%pack_size_real(1), int32)))
478 localsize = accel_kernel_workgroup_size(kernel)/xx%pack_size_real(1)
480 dim3 = np/(accel_max_size_per_dim(2)*localsize) + 1
481 dim2 = min(accel_max_size_per_dim(2)*localsize, pad(np, localsize))
483 call accel_kernel_run(kernel, (/xx%pack_size_real(1), dim2, dim3/), (/xx%pack_size_real(1), localsize, 1_int64/))
495 integer,
intent(in) :: np
496 class(batch_t),
intent(in) :: xx
497 class(batch_t),
intent(inout) :: yy
498 class(batch_t),
intent(inout) :: zz
500 integer :: ist_linear, ip
501 type(accel_kernel_t),
save :: kernel
502 integer(int64) :: localsize, dim3, dim2
506 assert(xx%type() == type_cmplx)
507 assert(yy%type() == type_float)
508 assert(zz%type() == type_float)
509 assert(xx%status() == yy%status())
510 assert(xx%status() == zz%status())
512 select case (xx%status())
513 case (batch_not_packed)
514 do ist_linear = 1, xx%nst_linear
517 yy%dff_linear(ip, ist_linear) = real(xx%zff_linear(ip, ist_linear), real64)
518 zz%dff_linear(ip, ist_linear) = aimag(xx%zff_linear(ip, ist_linear))
524 do ist_linear = 1, xx%nst_linear
525 yy%dff_pack(ist_linear, ip) = real(xx%zff_pack(ist_linear, ip), real64)
526 zz%dff_pack(ist_linear, ip) = aimag(xx%zff_pack(ist_linear, ip))
529 case (batch_device_packed)
530 call accel_kernel_start_call(kernel,
'split.cl',
'split_complex')
532 call accel_set_kernel_arg(kernel, 0, int(xx%pack_size(2), int32))
533 call accel_set_kernel_arg(kernel, 1, xx%ff_device)
534 call accel_set_kernel_arg(kernel, 2,
log2(int(xx%pack_size(1), int32)))
535 call accel_set_kernel_arg(kernel, 3, yy%ff_device)
536 call accel_set_kernel_arg(kernel, 4,
log2(int(yy%pack_size(1), int32)))
537 call accel_set_kernel_arg(kernel, 5, zz%ff_device)
538 call accel_set_kernel_arg(kernel, 6,
log2(int(zz%pack_size(1), int32)))
540 localsize = accel_kernel_workgroup_size(kernel)/xx%pack_size(1)
542 dim3 = np/(accel_max_size_per_dim(2)*localsize) + 1
543 dim2 = min(accel_max_size_per_dim(2)*localsize, pad(np, localsize))
545 call accel_kernel_run(kernel, (/xx%pack_size(1), dim2, dim3/), (/xx%pack_size(1), localsize, 1_int64/))
552#include "batch_ops_inc.F90"
555#include "complex.F90"
556#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_kernel_start_call(this, file_name, kernel_name, flags)
subroutine, public accel_release_buffer(this)
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 batch_copy_with_map_accel(np, map, xx, yy)
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_get_state3(this, ii, np, psi)
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_state2(this, index, np, psi)
subroutine zbatch_get_points(this, sp, ep, psi)
copy a set of points into a mesh function
subroutine dbatch_get_state2(this, index, np, psi)
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_state1(this, ist, np, psi)
Write a get of state with np points from a batch.
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_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 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_get_state1(this, ist, np, psi)
Write a get of state with np points from 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 zbatch_get_state3(this, ii, np, psi)
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.