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
76
77contains
78
79 ! -----------------------------------------------------
81 !
82 subroutine mesh_batch_nrm2(mesh, aa, nrm2, reduce)
83 class(mesh_t), intent(in) :: mesh
84 class(batch_t), intent(in) :: aa
85 real(real64), contiguous, intent(out) :: nrm2(:)
86 logical, optional, intent(in) :: reduce
87
88 push_sub(mesh_batch_nrm2)
89
90 if (aa%type() == type_float) then
91 call dpriv_mesh_batch_nrm2(mesh, aa, nrm2)
92 else
93 call zpriv_mesh_batch_nrm2(mesh, aa, nrm2)
94 end if
96 if (mesh%parallel_in_domains .and. optional_default(reduce, .true.)) then
97 nrm2(1:aa%nst) = nrm2(1:aa%nst)**2
98 call mesh%allreduce(nrm2, dim = aa%nst)
99 nrm2(1:aa%nst) = sqrt(nrm2(1:aa%nst))
100 end if
101
102 pop_sub(mesh_batch_nrm2)
103 end subroutine mesh_batch_nrm2
104
105 ! -----------------------------------------------------
109 subroutine mesh_batch_weight_device(mesh, aa, tmp, sqrt_weights)
110 class(mesh_t), intent(in) :: mesh
111 class(batch_t), intent(in) :: aa
112 class(batch_t), allocatable, intent(out) :: tmp
113 logical, optional, intent(in) :: sqrt_weights
114
115 type(accel_kernel_t), save :: kernel_scale
116 integer(int64), dimension(3) :: gsizes, bsizes
117
119
120 assert(mesh%use_vol_pp)
121 assert(aa%status() == batch_device_packed)
122
123 call aa%clone_to(tmp)
124 assert(tmp%status() == batch_device_packed)
125
126 call accel_kernel_start_call(kernel_scale, 'mesh_batch_single.cu', 'scale_points')
127
128 call accel_set_kernel_arg(kernel_scale, 0, mesh%np)
129 call accel_set_kernel_arg(kernel_scale, 1, int(aa%pack_size_real(1), int32))
130 call accel_set_kernel_arg(kernel_scale, 2, int(aa%pack_size_real(1), int32))
131 call accel_set_kernel_arg(kernel_scale, 3, int(tmp%pack_size_real(1), int32))
132 call accel_set_kernel_arg(kernel_scale, 4, 0)
133 if (optional_default(sqrt_weights, .false.)) then
134 call accel_set_kernel_arg(kernel_scale, 5, mesh%sqrt_vol_pp_buffer)
135 else
136 call accel_set_kernel_arg(kernel_scale, 5, mesh%vol_pp_buffer)
137 end if
138 call accel_set_kernel_arg(kernel_scale, 6, aa%ff_device)
139 call accel_set_kernel_arg(kernel_scale, 7, tmp%ff_device)
140
141 call accel_grid_size_extend_dim(int(mesh%np, int64), aa%pack_size_real(1), gsizes, bsizes, kernel_scale)
142
143 call accel_kernel_run(kernel_scale, gsizes, bsizes)
144
146 end subroutine mesh_batch_weight_device
147
148#undef SPECIALIZED
149#include "undef.F90"
150#include "real.F90"
151#include "mesh_batch_inc.F90"
152
153#include "undef.F90"
154#include "complex.F90"
155#include "mesh_batch_inc.F90"
156
157! Specialized kernels for nst_linear=2
158#define SPECIALIZED 2
159#include "undef.F90"
160#include "real.F90"
161#include "mesh_batch_inc.F90"
162
163#include "undef.F90"
164#include "complex.F90"
165#include "mesh_batch_inc.F90"
166#undef SPECIALIZED
167
168! Specialized kernels for nst_linear=3
169#define SPECIALIZED 3
170#include "undef.F90"
171#include "real.F90"
172#include "mesh_batch_inc.F90"
173
174#include "undef.F90"
175#include "complex.F90"
176#include "mesh_batch_inc.F90"
177#undef SPECIALIZED
178
179! Specialized kernels for nst_linear=4
180#define SPECIALIZED 4
181#include "undef.F90"
182#include "real.F90"
183#include "mesh_batch_inc.F90"
184
185#include "undef.F90"
186#include "complex.F90"
187#include "mesh_batch_inc.F90"
188#undef SPECIALIZED
189
190! Specialized kernels for nst_linear=6
191#define SPECIALIZED 6
192#include "undef.F90"
193#include "real.F90"
194#include "mesh_batch_inc.F90"
195
196#include "undef.F90"
197#include "complex.F90"
198#include "mesh_batch_inc.F90"
199#undef SPECIALIZED
200
201! Specialized kernels for nst_linear=8
202#define SPECIALIZED 8
203#include "undef.F90"
204#include "real.F90"
205#include "mesh_batch_inc.F90"
206
207#include "undef.F90"
208#include "complex.F90"
209#include "mesh_batch_inc.F90"
210#undef SPECIALIZED
211
212! Co-density kernel, instantiated for all precisions (d, z, s, c)
213#include "undef.F90"
214#include "real.F90"
215#include "mesh_batch_codensity_inc.F90"
216
217#include "undef.F90"
218#include "complex.F90"
219#include "mesh_batch_codensity_inc.F90"
220
221#include "undef.F90"
222#include "real32.F90"
223#include "mesh_batch_codensity_inc.F90"
224
225#include "undef.F90"
226#include "complex32.F90"
227#include "mesh_batch_codensity_inc.F90"
228
229end module mesh_batch_oct_m
230
231!! Local Variables:
232!! mode: f90
233!! coding: utf-8
234!! End:
double sqrt(double __x) __attribute__((__nothrow__
subroutine, public accel_kernel_start_call(this, file_name, kernel_name, flags)
Definition: accel.F90:1842
This module implements batches of mesh functions.
Definition: batch.F90:112
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
Definition: batch.F90:293
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:95
This module contains interfaces for BLAS routines You should not use these routines directly....
Definition: blas.F90:97
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:94
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:95
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:295
subroutine, public dmesh_batch_dotp_self(mesh, aa, dot, reduce)
calculate the overlap matrix of a batch with itself
Definition: mesh_batch.F90:575
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:155
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:182
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:939
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:691
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:97
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:124
Some general things and nomenclature:
Definition: par_vec.F90:150
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
Definition: profiling.F90:122
type(type_t), parameter, public type_float
Definition: types.F90:113
int true(void)