Octopus
batch_oct_m::batch_t Type Reference

Class defining batches of mesh functions. More...

Detailed Description

Class defining batches of mesh functions.

Definition at line 159 of file batch.F90.

Inheritance diagram for batch_oct_m::batch_t:
Inheritance graph

Public Attributes

integer, public nst
 number of functions in the batch More...
 
integer, public dim
 Spinor dimension of the state (one, or two for spinors) More...
 
integer, dimension(:), allocatable, public ist
 map from an global to local index More...
 
integer, public nst_linear
 nst_linear = nst * stddim More...
 
real(real64), dimension(:, :, :), pointer, public, contiguous dff
 pointer to real mesh functions: indices are (1:np, 1:dim, 1:nst) More...
 
complex(real64), dimension(:, :, :), pointer, public, contiguous zff
 pointer to complex mesh functions: indices are (1:np, 1:dim, 1:nst) More...
 
real(real64), dimension(:, :), pointer, public, contiguous dff_linear
 pointer to real mesh functions: indices are (1:np, 1:nst_linear) More...
 
complex(real64), dimension(:, :), pointer, public, contiguous zff_linear
 pointer to complex mesh functions: indices are (1:np, 1:nst_linear) More...
 
real(real64), dimension(:, :), pointer, public, contiguous dff_pack
 pointer to real mesh functions: indices are (1:nst_linear, 1:np) More...
 
complex(real64), dimension(:, :), pointer, public, contiguous zff_pack
 pointer to complex mesh functions: indices are (1:nst_linear, 1:np) More...
 
integer(int64), dimension(1:2), public pack_size
 pack_size = [pad_pow2(nst_linear), np] (see math_oct_m::pad_pow2) More...
 
integer(int64), dimension(1:2), public pack_size_real
 pack_size_real = pack_size; if batch type is complex, then pack_size_real(1) = 2*pack_size(1) More...
 
type(accel_mem_t), public ff_device
 pointer to device memory More...
 

Private Member Functions

procedure check_compatibility_with => batch_check_compatibility_with
 check whether two batches have compatible dimensions (and type) More...
 
procedure clone_to => batch_clone_to
 clone a batch to a new batch More...
 
procedure clone_to_array => batch_clone_to_array
 
procedure copy_to => batch_copy_to
 make a copy of a batch More...
 
procedure copy_data_to => batch_copy_data_to
 copy data to another batch. More...
 
procedure do_pack => batch_do_pack
 pack the data in a batch More...
 
procedure do_unpack => batch_do_unpack
 unpack a batch More...
 
procedure finish_unpack => batch_finish_unpack
 finish the unpacking if do_unpack() was called with async=.true. More...
 
procedure end => batch_end
 finalize a batch and release allocated memory, if necessary More...
 
procedure inv_index => batch_inv_index
 inverse index lookup More...
 
procedure is_packed => batch_is_packed
 
procedure ist_idim_to_linear => batch_ist_idim_to_linear
 direct index lookup More...
 
procedure linear_to_idim => batch_linear_to_idim
 extract idim from linear index More...
 
procedure linear_to_ist => batch_linear_to_ist
 get state index ist from linear (combined dim and nst) index More...
 
procedure pack_total_size => batch_pack_total_size
 
procedure remote_access_start => batch_remote_access_start
 start remote access to a batch on another node More...
 
procedure remote_access_stop => batch_remote_access_stop
 stop the remote access to the batch More...
 
procedure status => batch_status
 return the status of a batch More...
 
procedure type => batch_type
 return the type of a batch More...
 
procedure type_as_int => batch_type_as_integer
 For debuging purpose only. More...
 
procedure, private dallocate_unpacked_host => dbatch_allocate_unpacked_host
 allocate host (CPU) memory for unpacked data of type TYPE_FLOAT More...
 
procedure, private zallocate_unpacked_host => zbatch_allocate_unpacked_host
 allocate host (CPU) memory for unpacked data of type TYPE_CMPLX More...
 
procedure, private allocate_unpacked_host => batch_allocate_unpacked_host
 allocate host (CPU) memory for unpacked data More...
 
procedure, private dallocate_packed_host => dbatch_allocate_packed_host
 allocate host (CPU) memory for packed data of type TYPE_FLOAT More...
 
procedure, private zallocate_packed_host => zbatch_allocate_packed_host
 allocate host (CPU) memory for packed data of type TYPE_CMPLX More...
 
procedure, private allocate_packed_host => batch_allocate_packed_host
 allocate host (CPU) memory for packed data More...
 
procedure, private allocate_packed_device => batch_allocate_packed_device
 allocate device (GPU) memory for packed data More...
 
procedure, private deallocate_unpacked_host => batch_deallocate_unpacked_host
 release unpacked host memory More...
 
procedure, private deallocate_packed_host => batch_deallocate_packed_host
 release packed host memory More...
 
procedure, private deallocate_packed_device => batch_deallocate_packed_device
 release packed device memory More...
 

Private Attributes

integer np
 number of points in each function (this can be np or np_part) More...
 
integer ndims
 The second dimension of ist_idim_index(:,:). Currently always set to 2. More...
 
integer, dimension(:, :), allocatable ist_idim_index
 index mapping fom global (ist,idim) to local ist. More...
 
logical is_allocated
 indicate allocation status More...
 
logical own_memory
 does the batch own the memory or is it foreign memory? More...
 
integer status_of
 packing status of the batch More...
 
integer status_host
 packing status in CPU memory More...
 
type(type_ttype_of
 either TYPE_FLOAT or TYPE_CMPLX More...
 
integer device_buffer_count
 keep track of pack operations performed on the device More...
 
integer host_buffer_count
 keep track of pack operations performed on the host More...
 
logical special_memory
 are we using hardware-aware memory? More...
 
logical needs_finish_unpack
 if .true., async unpacking has started and needs be finished More...
 

Member Function/Subroutine Documentation

◆ check_compatibility_with()

procedure batch_oct_m::batch_t::check_compatibility_with
private

check whether two batches have compatible dimensions (and type)

Definition at line 221 of file batch.F90.

◆ clone_to()

procedure batch_oct_m::batch_t::clone_to
private

clone a batch to a new batch

This routine clones the metadata of a batch and, if requested copies the data.

Parameters
[in]thissource batch
[out]destdestination batch
[in]packIf .false. the new batch will not be packed. Default: batch_is_packed(this)
[in]copy_dataIf .true. the batch data will be copied to the destination batch. Default: .false.
[in]new_npIf present, this replaces thisnp in the initialization

Definition at line 222 of file batch.F90.

◆ clone_to_array()

procedure batch_oct_m::batch_t::clone_to_array
private

Parameters
[in]packIf .false. the new batch will not be packed. Default: batch_is_packed(this)
[in]copy_dataIf .true. the batch data will be copied to the destination batch. Default: .false.

Definition at line 223 of file batch.F90.

◆ copy_to()

procedure batch_oct_m::batch_t::copy_to
private

make a copy of a batch

This routine can perform a deep or a shallow copy of a batch

Parameters
[in]thisThe source batch
[out]destThe destination batch
[in]packIf .false. the new batch will not be packed. Default: batch_is_packed(this)
[in]copy_dataIf .true. the batch data will be copied to the destination batch. Default: .false.
[in]new_npIf present, this replaces thisnp in the initialization
[in]specialIf present, this replace special in the locic below, i.e., we try to allocate on the GPU

Definition at line 224 of file batch.F90.

◆ copy_data_to()

procedure batch_oct_m::batch_t::copy_data_to
private

copy data to another batch.

Parameters
[in]thissource batch
[in]npnumber of points to copy for each mesh function
[in,out]destdestination batch
[in]asyncasynchronous GPU operations or not

Definition at line 225 of file batch.F90.

◆ do_pack()

procedure batch_oct_m::batch_t::do_pack
private

pack the data in a batch

If accelerators are enabled, the packed data is moved to the device memory. If the batch is already packed, a counter is increased to keep track when to unpack.

Parameters
[in,out]thisThe current batch
[in]copyDo we copy the data to the packed memory? (default .true.)
[in]asyncWe can do an asynchronous operation. (default .false.) The program flow can continue while data is being transferred to the device.

Definition at line 226 of file batch.F90.

◆ do_unpack()

procedure batch_oct_m::batch_t::do_unpack
private

unpack a batch

We unpack the batch if the 'packing counter' is one, or the force flag is given.

Parameters
[in]copyindicate whether to copy the data (default .true.)
[in]forceif force = .true., unpack independently of the counter (default .false.)
[in]asyncindicate whether the operation can by asynchronous (default .false.). In this case the operation has to be completed by calling batch_finish_unpack()

Definition at line 227 of file batch.F90.

◆ finish_unpack()

procedure batch_oct_m::batch_t::finish_unpack
private

finish the unpacking if do_unpack() was called with async=.true.

Definition at line 228 of file batch.F90.

◆ end()

procedure batch_oct_m::batch_t::end
private

finalize a batch and release allocated memory, if necessary

If the batch was initialized with 'external' memory, this routine ensures that this memory is up-to-date, when the batch is finalized. This means, that the data is copied from the device (If requested) and unpacked.

Parameters
[in]copydo we need to copy data from the device? Default = .true. (from batch_oct_m::batch_do_uppack)

Definition at line 229 of file batch.F90.

◆ inv_index()

procedure batch_oct_m::batch_t::inv_index
private

inverse index lookup

This function returns the linear index for (ist, idim), where ist ranges from 1 to stnst.

Parameters
[in]thisthe batch
[in]cindcombined index (ist, idim)

Definition at line 230 of file batch.F90.

◆ is_packed()

procedure batch_oct_m::batch_t::is_packed
private

Definition at line 231 of file batch.F90.

◆ ist_idim_to_linear()

procedure batch_oct_m::batch_t::ist_idim_to_linear
private

direct index lookup

This function returns the linear index for (ist, idim), where ist ranges from 1 to thisnst.

Parameters
[in]thisthe batch
[in]cindcombined index (ist, idim)

Definition at line 232 of file batch.F90.

◆ linear_to_idim()

procedure batch_oct_m::batch_t::linear_to_idim
private

extract idim from linear index

Definition at line 233 of file batch.F90.

◆ linear_to_ist()

procedure batch_oct_m::batch_t::linear_to_ist
private

get state index ist from linear (combined dim and nst) index

The linear index interleaves the state index with the dimension, resulting in a one-dimensional ordering of states.

Definition at line 234 of file batch.F90.

◆ pack_total_size()

procedure batch_oct_m::batch_t::pack_total_size
private

Definition at line 235 of file batch.F90.

◆ remote_access_start()

procedure batch_oct_m::batch_t::remote_access_start
private

start remote access to a batch on another node

This routine creates a remote access window for a given batch and returns a handle to that window. A handle of -1 indicates that no window was created.

Note
this is currently not allowed when using GPUs
side effect: the packing of the batch is increased by one
Parameters
[in,out]thisthe current batch
[in]mpi_grpthe MPI group
[out]rma_winhandle of rma window

Definition at line 236 of file batch.F90.

◆ remote_access_stop()

procedure batch_oct_m::batch_t::remote_access_stop
private

stop the remote access to the batch

If the rma window handle is valid, the window is freed.

Note
side effect the batch pack level is decreased by one.

Definition at line 237 of file batch.F90.

◆ status()

procedure batch_oct_m::batch_t::status
private

return the status of a batch

This function is THREADSAFE

Definition at line 238 of file batch.F90.

◆ type()

procedure batch_oct_m::batch_t::type
private

return the type of a batch

This function is THREADSAFE

Definition at line 239 of file batch.F90.

◆ type_as_int()

procedure batch_oct_m::batch_t::type_as_int
private

For debuging purpose only.

Definition at line 240 of file batch.F90.

◆ dallocate_unpacked_host()

procedure, private batch_oct_m::batch_t::dallocate_unpacked_host
private

allocate host (CPU) memory for unpacked data of type TYPE_FLOAT

This routine takes care of the allocating the memory on the host. If requested (special_memory), pinned memory can be allocated, which optimizes the transfer to GPUs under certain conditions.

Definition at line 241 of file batch.F90.

◆ zallocate_unpacked_host()

procedure, private batch_oct_m::batch_t::zallocate_unpacked_host
private

allocate host (CPU) memory for unpacked data of type TYPE_CMPLX

This routine takes care of the allocating the memory on the host. If requested (special_memory), pinned memory can be allocated, which optimizes the transfer to GPUs under certain conditions.

Definition at line 243 of file batch.F90.

◆ allocate_unpacked_host()

procedure, private batch_oct_m::batch_t::allocate_unpacked_host
private

allocate host (CPU) memory for unpacked data

This routine is a wrapper to the tyupe specific versions

Definition at line 245 of file batch.F90.

◆ dallocate_packed_host()

procedure, private batch_oct_m::batch_t::dallocate_packed_host
private

allocate host (CPU) memory for packed data of type TYPE_FLOAT

This routine takes care of the allocating the memory on the host. If requested (special_memory), pinned memory can be allocated, which optimizes the transfer to GPUs under certain conditions.

Definition at line 247 of file batch.F90.

◆ zallocate_packed_host()

procedure, private batch_oct_m::batch_t::zallocate_packed_host
private

allocate host (CPU) memory for packed data of type TYPE_CMPLX

This routine takes care of the allocating the memory on the host. If requested (special_memory), pinned memory can be allocated, which optimizes the transfer to GPUs under certain conditions.

Definition at line 249 of file batch.F90.

◆ allocate_packed_host()

procedure, private batch_oct_m::batch_t::allocate_packed_host
private

allocate host (CPU) memory for packed data

This routine is a wrapper to the tyupe specific versions

Definition at line 251 of file batch.F90.

◆ allocate_packed_device()

procedure, private batch_oct_m::batch_t::allocate_packed_device
private

allocate device (GPU) memory for packed data

This routine is a wrapper to the tyupe specific versions

Definition at line 253 of file batch.F90.

◆ deallocate_unpacked_host()

procedure, private batch_oct_m::batch_t::deallocate_unpacked_host
private

release unpacked host memory

This routine takes care of special (i.e. pinned memory)

Definition at line 255 of file batch.F90.

◆ deallocate_packed_host()

procedure, private batch_oct_m::batch_t::deallocate_packed_host
private

release packed host memory

This routine takes care of special (i.e. pinned memory)

Definition at line 257 of file batch.F90.

◆ deallocate_packed_device()

procedure, private batch_oct_m::batch_t::deallocate_packed_device
private

release packed device memory

Definition at line 259 of file batch.F90.

Member Data Documentation

◆ nst

integer, public batch_oct_m::batch_t::nst

number of functions in the batch

Definition at line 161 of file batch.F90.

◆ dim

integer, public batch_oct_m::batch_t::dim

Spinor dimension of the state (one, or two for spinors)

Definition at line 162 of file batch.F90.

◆ np

integer batch_oct_m::batch_t::np
private

number of points in each function (this can be np or np_part)

Definition at line 163 of file batch.F90.

◆ ndims

integer batch_oct_m::batch_t::ndims
private

The second dimension of ist_idim_index(:,:). Currently always set to 2.

Definition at line 164 of file batch.F90.

◆ ist_idim_index

integer, dimension(:, :), allocatable batch_oct_m::batch_t::ist_idim_index
private

index mapping fom global (ist,idim) to local ist.

This maps ist and idim into one linear array. This index is constructed in batch_oct_m::batch_build_indices

Definition at line 165 of file batch.F90.

◆ ist

integer, dimension(:), allocatable, public batch_oct_m::batch_t::ist

map from an global to local index

The global index does not need to start at 1, while the local index is always in the range 1:nst.

This index is constructed in batch_oct_m::batch_build_indices

Definition at line 170 of file batch.F90.

◆ is_allocated

logical batch_oct_m::batch_t::is_allocated
private

indicate allocation status

Definition at line 177 of file batch.F90.

◆ own_memory

logical batch_oct_m::batch_t::own_memory
private

does the batch own the memory or is it foreign memory?

Definition at line 178 of file batch.F90.

◆ nst_linear

integer, public batch_oct_m::batch_t::nst_linear

nst_linear = nst * stddim

Definition at line 180 of file batch.F90.

◆ status_of

integer batch_oct_m::batch_t::status_of
private

packing status of the batch

possible values are: BATCH_NOT_PACKED, BATCH_PACKED, BATCH_DEVICE_PACKED

Definition at line 182 of file batch.F90.

◆ status_host

integer batch_oct_m::batch_t::status_host
private

packing status in CPU memory

If Octopus runs on GPU, this indicates the status on the CPU. It can only be BATCH_NOT_PACKED and BATCH_PACKED. This makes transfers more efficient: usually we allocate a batch as packed on the CPU, then call do_pack to copy it to the GPU. In this case, it is really a copy. If the batch is unpacked on the CPU, we need to transpose in addition which makes it much slower.

Definition at line 186 of file batch.F90.

◆ type_of

type(type_t) batch_oct_m::batch_t::type_of
private

either TYPE_FLOAT or TYPE_CMPLX

Definition at line 195 of file batch.F90.

◆ device_buffer_count

integer batch_oct_m::batch_t::device_buffer_count
private

keep track of pack operations performed on the device

Definition at line 196 of file batch.F90.

◆ host_buffer_count

integer batch_oct_m::batch_t::host_buffer_count
private

keep track of pack operations performed on the host

Definition at line 197 of file batch.F90.

◆ special_memory

logical batch_oct_m::batch_t::special_memory
private

are we using hardware-aware memory?

Definition at line 198 of file batch.F90.

◆ needs_finish_unpack

logical batch_oct_m::batch_t::needs_finish_unpack
private

if .true., async unpacking has started and needs be finished

Definition at line 199 of file batch.F90.

◆ dff

real(real64), dimension(:, :, :), pointer, public, contiguous batch_oct_m::batch_t::dff

pointer to real mesh functions: indices are (1:np, 1:dim, 1:nst)

Definition at line 203 of file batch.F90.

◆ zff

complex(real64), dimension(:, :, :), pointer, public, contiguous batch_oct_m::batch_t::zff

pointer to complex mesh functions: indices are (1:np, 1:dim, 1:nst)

Definition at line 204 of file batch.F90.

◆ dff_linear

real(real64), dimension(:, :), pointer, public, contiguous batch_oct_m::batch_t::dff_linear

pointer to real mesh functions: indices are (1:np, 1:nst_linear)

Definition at line 205 of file batch.F90.

◆ zff_linear

complex(real64), dimension(:, :), pointer, public, contiguous batch_oct_m::batch_t::zff_linear

pointer to complex mesh functions: indices are (1:np, 1:nst_linear)

Definition at line 206 of file batch.F90.

◆ dff_pack

real(real64), dimension(:, :), pointer, public, contiguous batch_oct_m::batch_t::dff_pack

pointer to real mesh functions: indices are (1:nst_linear, 1:np)

Definition at line 209 of file batch.F90.

◆ zff_pack

complex(real64), dimension(:, :), pointer, public, contiguous batch_oct_m::batch_t::zff_pack

pointer to complex mesh functions: indices are (1:nst_linear, 1:np)

Definition at line 210 of file batch.F90.

◆ pack_size

integer(int64), dimension(1:2), public batch_oct_m::batch_t::pack_size

pack_size = [pad_pow2(nst_linear), np] (see math_oct_m::pad_pow2)

Definition at line 212 of file batch.F90.

◆ pack_size_real

integer(int64), dimension(1:2), public batch_oct_m::batch_t::pack_size_real

pack_size_real = pack_size; if batch type is complex, then pack_size_real(1) = 2*pack_size(1)

Definition at line 214 of file batch.F90.

◆ ff_device

type(accel_mem_t), public batch_oct_m::batch_t::ff_device

pointer to device memory

Definition at line 218 of file batch.F90.


The documentation for this type was generated from the following file: