Octopus
mesh_batch.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
24 use accel_oct_m
26 use batch_oct_m
28 use blas_oct_m
29 use iso_c_binding
30 use debug_oct_m
31 use global_oct_m
34 use math_oct_m
35 use mesh_oct_m
38 use mpi_oct_m
41#if defined(HAVE_OPENMP)
42 use omp_lib
43#endif
47 use types_oct_m
48
49 implicit none
50
51 private
52 public :: &
53 batch_p_t, &
74
75 type batch_p_t
76 class(batch_t), allocatable :: p
77 end type batch_p_t
78
79
80contains
81
82 ! -----------------------------------------------------
84 !
85 subroutine mesh_batch_nrm2(mesh, aa, nrm2, reduce)
86 class(mesh_t), intent(in) :: mesh
87 class(batch_t), intent(in) :: aa
88 real(real64), contiguous, intent(out) :: nrm2(:)
89 logical, optional, intent(in) :: reduce
90
91 push_sub(mesh_batch_nrm2)
92
93 if (aa%type() == type_float) then
94 call dpriv_mesh_batch_nrm2(mesh, aa, nrm2)
95 else
96 call zpriv_mesh_batch_nrm2(mesh, aa, nrm2)
97 end if
98
99 if (mesh%parallel_in_domains .and. optional_default(reduce, .true.)) then
100 nrm2(1:aa%nst) = nrm2(1:aa%nst)**2
101 call mesh%allreduce(nrm2, dim = aa%nst)
102 nrm2(1:aa%nst) = sqrt(nrm2(1:aa%nst))
103 end if
104
105 pop_sub(mesh_batch_nrm2)
106 end subroutine mesh_batch_nrm2
107
108 ! -----------------------------------------------------
112 subroutine mesh_batch_weight_device(mesh, aa, tmp, sqrt_weights)
113 class(mesh_t), intent(in) :: mesh
114 class(batch_t), intent(in) :: aa
115 class(batch_t), allocatable, intent(out) :: tmp
116 logical, optional, intent(in) :: sqrt_weights
117
118 type(accel_kernel_t), save :: kernel_scale
119 integer(int64), dimension(3) :: gsizes, bsizes
120
122
123 assert(mesh%use_vol_pp)
124 assert(aa%status() == batch_device_packed)
125
126 call aa%clone_to(tmp)
127 assert(tmp%status() == batch_device_packed)
128
129 call accel_kernel_start_call(kernel_scale, 'mesh_batch_single.cu', 'scale_points')
130
131 call accel_set_kernel_arg(kernel_scale, 0, mesh%np)
132 call accel_set_kernel_arg(kernel_scale, 1, int(aa%pack_size_real(1), int32))
133 call accel_set_kernel_arg(kernel_scale, 2, int(aa%pack_size_real(1), int32))
134 call accel_set_kernel_arg(kernel_scale, 3, int(tmp%pack_size_real(1), int32))
135 call accel_set_kernel_arg(kernel_scale, 4, 0)
136 if (optional_default(sqrt_weights, .false.)) then
137 call accel_set_kernel_arg(kernel_scale, 5, mesh%sqrt_vol_pp_buffer)
138 else
139 call accel_set_kernel_arg(kernel_scale, 5, mesh%vol_pp_buffer)
140 end if
141 call accel_set_kernel_arg(kernel_scale, 6, aa%ff_device)
142 call accel_set_kernel_arg(kernel_scale, 7, tmp%ff_device)
143
144 call accel_grid_size_extend_dim(int(mesh%np, int64), aa%pack_size_real(1), gsizes, bsizes, kernel_scale)
145
146 call accel_kernel_run(kernel_scale, gsizes, bsizes)
147
149 end subroutine mesh_batch_weight_device
150
151#undef SPECIALIZED
152#include "undef.F90"
153#include "real.F90"
154#include "mesh_batch_inc.F90"
155
156#include "undef.F90"
157#include "complex.F90"
158#include "mesh_batch_inc.F90"
159
160! Specialized kernels for nst_linear=2
161#define SPECIALIZED 2
162#include "undef.F90"
163#include "real.F90"
164#include "mesh_batch_inc.F90"
165
166#include "undef.F90"
167#include "complex.F90"
168#include "mesh_batch_inc.F90"
169#undef SPECIALIZED
171! Specialized kernels for nst_linear=3
172#define SPECIALIZED 3
173#include "undef.F90"
174#include "real.F90"
175#include "mesh_batch_inc.F90"
176
177#include "undef.F90"
178#include "complex.F90"
179#include "mesh_batch_inc.F90"
180#undef SPECIALIZED
181
182! Specialized kernels for nst_linear=4
183#define SPECIALIZED 4
184#include "undef.F90"
185#include "real.F90"
186#include "mesh_batch_inc.F90"
187
188#include "undef.F90"
189#include "complex.F90"
190#include "mesh_batch_inc.F90"
191#undef SPECIALIZED
192
193! Specialized kernels for nst_linear=6
194#define SPECIALIZED 6
195#include "undef.F90"
196#include "real.F90"
197#include "mesh_batch_inc.F90"
198
199#include "undef.F90"
200#include "complex.F90"
201#include "mesh_batch_inc.F90"
202#undef SPECIALIZED
203
204! Specialized kernels for nst_linear=8
205#define SPECIALIZED 8
206#include "undef.F90"
207#include "real.F90"
208#include "mesh_batch_inc.F90"
209
210#include "undef.F90"
211#include "complex.F90"
212#include "mesh_batch_inc.F90"
213#undef SPECIALIZED
214
215! Co-density kernel, instantiated for all precisions (d, z, s, c)
216#include "undef.F90"
217#include "real.F90"
218#include "mesh_batch_codensity_inc.F90"
219
220#include "undef.F90"
221#include "complex.F90"
222#include "mesh_batch_codensity_inc.F90"
223
224#include "undef.F90"
225#include "real32.F90"
226#include "mesh_batch_codensity_inc.F90"
227
228#include "undef.F90"
229#include "complex32.F90"
230#include "mesh_batch_codensity_inc.F90"
231
232end module mesh_batch_oct_m
233
234!! Local Variables:
235!! mode: f90
236!! coding: utf-8
237!! End:
double sqrt(double __x) __attribute__((__nothrow__
subroutine, public accel_kernel_start_call(this, file_name, kernel_name, flags)
Definition: accel.F90:1865
This module implements batches of mesh functions.
Definition: batch.F90:135
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
Definition: batch.F90:311
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:118
This module contains interfaces for BLAS routines You should not use these routines directly....
Definition: blas.F90:120
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:118
subroutine, public zmesh_batch_codensity(mesh, aa, bra, ist_bra, rho, rho_buffer)
calculate the co-densities
subroutine, public smesh_batch_codensity(mesh, aa, bra, ist_bra, rho, rho_buffer)
calculate the co-densities
subroutine, public cmesh_batch_codensity(mesh, aa, bra, ist_bra, rho, rho_buffer)
calculate the co-densities
subroutine, public dmesh_batch_dotp_matrix(mesh, aa, bb, dot, reduce)
Calculate the overlap matrix of two batches.
Definition: mesh_batch.F90:321
subroutine, public dmesh_batch_dotp_self(mesh, aa, dot, reduce)
calculate the overlap matrix of a batch with itself
Definition: mesh_batch.F90:601
subroutine, public mesh_batch_nrm2(mesh, aa, nrm2, reduce)
Calculate the norms (norm2, not the square!) of a batch of mesh functions.
Definition: mesh_batch.F90:181
subroutine, public mesh_batch_weight_device(mesh, aa, tmp, sqrt_weights)
Weighted copy of a device batch: tmp := vol_pp .* aa (per mesh point), used to compute vol_pp-weighte...
Definition: mesh_batch.F90:208
subroutine, public zmesh_batch_exchange_points(mesh, aa, forward_map, backward_map)
This functions exchanges points of a mesh according to a certain map. Two possible maps can be given....
subroutine, public zmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
A simple switch between specialized kernels and generic kernels.
subroutine zpriv_mesh_batch_nrm2(mesh, aa, nrm2)
This function should not be called directly, but through mesh_batch_nrm2.
subroutine, public zmesh_batch_dotp_matrix(mesh, aa, bb, dot, reduce)
Calculate the overlap matrix of two batches.
subroutine, public zmesh_batch_normalize(mesh, psib, norm)
Normalize a batch.
subroutine, public dmesh_batch_orthogonalization(mesh, nst, psib, phib, normalize, overlap, norm, gs_scheme, full_batch)
Orthonormalizes states of phib to the orbitals of nst batches of psi.
subroutine, public zmesh_batch_orthogonalization(mesh, nst, psib, phib, normalize, overlap, norm, gs_scheme, full_batch)
Orthonormalizes states of phib to the orbitals of nst batches of psi.
subroutine, public dmesh_batch_exchange_points(mesh, aa, forward_map, backward_map)
This functions exchanges points of a mesh according to a certain map. Two possible maps can be given....
subroutine, public zmesh_batch_mf_dotp(mesh, aa, psi, dot, reduce, nst)
calculate the dot products between a batch and a vector of mesh functions
subroutine, public dmesh_batch_mf_dotp(mesh, aa, psi, dot, reduce, nst)
calculate the dot products between a batch and a vector of mesh functions
Definition: mesh_batch.F90:961
subroutine, public dmesh_batch_codensity(mesh, aa, bra, ist_bra, rho, rho_buffer)
calculate the co-densities
subroutine dpriv_mesh_batch_nrm2(mesh, aa, nrm2)
This function should not be called directly, but through mesh_batch_nrm2.
subroutine, public zmesh_batch_dotp_self(mesh, aa, dot, reduce)
calculate the overlap matrix of a batch with itself
subroutine, public dmesh_batch_normalize(mesh, psib, norm)
Normalize a batch.
subroutine, public dmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
A simple switch between specialized kernels and generic kernels.
Definition: mesh_batch.F90:717
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
Some general things and nomenclature:
Definition: par_vec.F90:173
type(type_t), parameter, public type_float
Definition: types.F90:136
int true(void)