147 class(batch_t),
intent(inout) :: this
148 integer,
optional,
intent(in) :: np
150 logical,
optional,
intent(in) :: async
152 integer :: ist_linear, ist, ip, np_
160 select case (this%status())
163 assert(np_ <= int(this%pack_size(2), int32))
168 assert(np_ <= int(this%pack_size(2), int32))
173 do ist = 1, int(this%pack_size(1), int32)
174 this%dff_pack(ist, ip) =
m_zero
181 do ist = 1, int(this%pack_size(1), int32)
182 this%zff_pack(ist, ip) =
m_z0
190 assert(np_ <= ubound(this%dff_linear, dim=1))
191 do ist_linear = 1, this%nst_linear
194 this%dff_linear(ip, ist_linear) =
m_zero
199 assert(np_ <= ubound(this%zff_linear, dim=1))
200 do ist_linear = 1, this%nst_linear
203 this%zff_linear(ip, ist_linear) =
m_z0
209 message(1) =
"batch_set_zero: unknown batch status."
223 class(batch_t),
intent(in) :: this
224 integer,
intent(in) :: sp
225 integer,
intent(in) :: ep
226 type(accel_mem_t),
intent(inout) :: psi
227 integer,
intent(in) :: ldpsi1
228 integer,
intent(in) :: ldpsi2
230 integer :: tsize, ii, it
231 type(accel_kernel_t),
save :: kernel
232 integer,
allocatable :: linear_to_ist(:), linear_to_idim(:)
233 type(accel_mem_t) :: buff_linear_to_ist, buff_linear_to_idim
238 select case (this%status())
245 safe_allocate(linear_to_ist(1:this%nst_linear*tsize))
246 safe_allocate(linear_to_idim(1:this%nst_linear*tsize))
247 do ii = 1, this%nst_linear
249 linear_to_ist(tsize*(ii-1)+it) = tsize*(this%linear_to_ist(ii) - 1) + it - 1
250 linear_to_idim(tsize*(ii-1)+it) = this%linear_to_idim(ii) - 1
272 call accel_kernel_run(kernel, (/this%pack_size_real(1), int(ep - sp + 1, int64)/), (/this%pack_size_real(1), 1_int64/))
276 safe_deallocate_a(linear_to_ist)
277 safe_deallocate_a(linear_to_idim)
290 class(
batch_t),
intent(inout) :: this
291 integer,
intent(in) :: sp
292 integer,
intent(in) :: ep
294 integer,
intent(in) :: ldpsi1
295 integer,
intent(in) :: ldpsi2
297 integer :: tsize, ii, it
299 integer,
allocatable :: linear_to_ist(:), linear_to_idim(:)
300 type(
accel_mem_t) :: buff_linear_to_ist, buff_linear_to_idim
305 select case (this%status())
312 safe_allocate(linear_to_ist(1:this%nst_linear*tsize))
313 safe_allocate(linear_to_idim(1:this%nst_linear*tsize))
314 do ii = 1, this%nst_linear
316 linear_to_ist(tsize*(ii-1)+it) = tsize*(this%linear_to_ist(ii) - 1) + it - 1
317 linear_to_idim(tsize*(ii-1)+it) = this%linear_to_idim(ii) - 1
339 call accel_kernel_run(kernel, (/this%pack_size_real(1), int(ep - sp + 1, int64)/), (/this%pack_size_real(1), 1_int64/))
343 safe_deallocate_a(linear_to_ist)
344 safe_deallocate_a(linear_to_idim)
358 integer pure function batch_points_block_size() result(block_size)
366 integer,
intent(in) :: np
367 integer,
intent(in) :: map(:)
368 class(batch_t),
intent(in) :: xx
369 class(batch_t),
intent(in) :: yy
370 class(batch_t),
intent(inout) :: zz
371 type(accel_mem_t) :: buff_map
375 if (xx%status() /= batch_device_packed)
then
376 if (xx%type() == type_float)
then
383 call accel_create_buffer(buff_map, accel_mem_read_only, type_integer, np)
384 call accel_write_buffer(buff_map, np, map)
386 call accel_release_buffer(buff_map)
394 integer,
intent(in) :: np
395 class(accel_mem_t),
intent(in) :: map
396 class(batch_t),
intent(in) :: xx
397 class(batch_t),
intent(in) :: yy
398 class(batch_t),
intent(inout) :: zz
400 type(accel_kernel_t),
save :: kernel
401 integer(int64) :: localsize, dim3, dim2
405 call accel_kernel_start_call(kernel,
'copy.cl',
'add_with_map')
407 call accel_set_kernel_arg(kernel, 0, np)
408 call accel_set_kernel_arg(kernel, 1, map)
409 call accel_set_kernel_arg(kernel, 2, xx%ff_device)
410 call accel_set_kernel_arg(kernel, 3,
log2(int(xx%pack_size_real(1), int32)))
411 call accel_set_kernel_arg(kernel, 4, yy%ff_device)
412 call accel_set_kernel_arg(kernel, 5,
log2(int(yy%pack_size_real(1), int32)))
413 call accel_set_kernel_arg(kernel, 6, zz%ff_device)
414 call accel_set_kernel_arg(kernel, 7,
log2(int(zz%pack_size_real(1), int32)))
416 localsize = accel_kernel_workgroup_size(kernel)/xx%pack_size_real(1)
418 dim3 = np/(accel_max_size_per_dim(2)*localsize) + 1
419 dim2 = min(accel_max_size_per_dim(2)*localsize, pad(np, localsize))
421 call accel_kernel_run(kernel, (/xx%pack_size_real(1), dim2, dim3/), (/xx%pack_size_real(1), localsize, 1_int64/))
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_release_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) :: localsize, dim3, dim2
465 call accel_kernel_start_call(kernel,
'copy.cl',
'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)))
476 localsize = accel_kernel_workgroup_size(kernel)/xx%pack_size_real(1)
478 dim3 = np/(accel_max_size_per_dim(2)*localsize) + 1
479 dim2 = min(accel_max_size_per_dim(2)*localsize, pad(np, localsize))
481 call accel_kernel_run(kernel, (/xx%pack_size_real(1), dim2, dim3/), (/xx%pack_size_real(1), localsize, 1_int64/))
493 integer,
intent(in) :: np
494 class(batch_t),
intent(in) :: xx
495 class(batch_t),
intent(inout) :: yy
496 class(batch_t),
intent(inout) :: zz
498 integer :: ist_linear, ip
499 type(accel_kernel_t),
save :: kernel
500 integer(int64) :: localsize, dim3, dim2
504 assert(xx%type() == type_cmplx)
505 assert(yy%type() == type_float)
506 assert(zz%type() == type_float)
507 assert(xx%status() == yy%status())
508 assert(xx%status() == zz%status())
510 select case (xx%status())
511 case (batch_not_packed)
512 do ist_linear = 1, xx%nst_linear
515 yy%dff_linear(ip, ist_linear) = real(xx%zff_linear(ip, ist_linear), real64)
516 zz%dff_linear(ip, ist_linear) = aimag(xx%zff_linear(ip, ist_linear))
522 do ist_linear = 1, xx%nst_linear
523 yy%dff_pack(ist_linear, ip) = real(xx%zff_pack(ist_linear, ip), real64)
524 zz%dff_pack(ist_linear, ip) = aimag(xx%zff_pack(ist_linear, ip))
527 case (batch_device_packed)
528 call accel_kernel_start_call(kernel,
'split.cl',
'split_complex')
530 call accel_set_kernel_arg(kernel, 0, int(xx%pack_size(2), int32))
531 call accel_set_kernel_arg(kernel, 1, xx%ff_device)
532 call accel_set_kernel_arg(kernel, 2,
log2(int(xx%pack_size(1), int32)))
533 call accel_set_kernel_arg(kernel, 3, yy%ff_device)
534 call accel_set_kernel_arg(kernel, 4,
log2(int(yy%pack_size(1), int32)))
535 call accel_set_kernel_arg(kernel, 5, zz%ff_device)
536 call accel_set_kernel_arg(kernel, 6,
log2(int(zz%pack_size(1), int32)))
538 localsize = accel_kernel_workgroup_size(kernel)/xx%pack_size(1)
540 dim3 = np/(accel_max_size_per_dim(2)*localsize) + 1
541 dim2 = min(accel_max_size_per_dim(2)*localsize, pad(np, localsize))
543 call accel_kernel_run(kernel, (/xx%pack_size(1), dim2, dim3/), (/xx%pack_size(1), localsize, 1_int64/))
550#include "batch_ops_inc.F90"
553#include "complex.F90"
554#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 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 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.