Skip to content

Commit ccca772

Browse files
authored
Merge pull request lammps#4719 from akohlmey/collected-small-changes
Collected small changes and fixes
2 parents 0d479ca + a123b6b commit ccca772

File tree

14 files changed

+180
-130
lines changed

14 files changed

+180
-130
lines changed

doc/src/Build_extras.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ necessary for ``hipcc`` and the linker to work correctly.
243243
When compiling for HIP ROCm, GPU sorting with ``-D
244244
HIP_USE_DEVICE_SORT=on`` requires installing the ``hipcub`` library
245245
(https://github.com/ROCmSoftwarePlatform/hipCUB). The HIP CUDA-backend
246-
additionally requires cub (https://nvlabs.github.io/cub). Setting
246+
additionally requires cub (https://nvidia.github.io/cccl/cub/). Setting
247247
``-DDOWNLOAD_CUB=yes`` will download and compile CUB.
248248

249249
The GPU library has some multi-thread support using OpenMP. If LAMMPS

doc/src/Errors_details.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,3 +1068,22 @@ also increase the value for the "page" parameter to maintain the ratio
10681068
between "one" and "page" to reduce waste of memory. For some more
10691069
details, please check out the documentation for the :doc:`neigh_modify
10701070
command <neigh_modify>`.
1071+
1072+
.. _err0037:
1073+
1074+
Variable ...: Compute/Fix ... does not compute requested property
1075+
-----------------------------------------------------------------
1076+
1077+
Compute and fix styles can compute different kinds of properties: for
1078+
example, global scalars, vectors, or arrays, or per-atom vectors or
1079+
arrays. In equal-style or similar variable, only scalar properties can
1080+
be used, so to access a particular element in a vector one has to use
1081+
square brackets with a suitable index to select it. However, not all
1082+
fixes and computes provide all types of properties. So this error
1083+
message will be shown if there is a mismatch, of if there are not
1084+
enough or too many square brackets. To differentiate between
1085+
accessing an element of a global array or a per-atom array element of
1086+
a specific atom, one has to use a reference with a lower case 'c'
1087+
(e.g. 'c_name') for the former and upper case 'C' (e.g. 'C_name') for
1088+
the latter. The same applies to fix styles. The full details are
1089+
in the documentation for the :doc:`variable command <variable>`.

doc/src/Howto_mdi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ the ``examples/QUANTUM`` sub-directories for more details:
138138

139139
There are also at least two quantum codes which have direct MDI
140140
support, `Quantum ESPRESSO (QE) <https://www.quantum-espresso.org/>`_
141-
and `INQ <https://qsg.llnl.gov/node/101.html>`_. There are also
141+
and `INQ <https://gitlab.com/npneq/inq>`_. There are also
142142
several QM codes which have indirect support through QCEngine or i-PI.
143143
The former means they require a wrapper program (QCEngine) with MDI
144144
support which writes/read files to pass data to the quantum code

doc/src/fix_external.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,8 @@ which is typically a 32-bit integer unless LAMMPS is compiled with
7171
<size>` section of the manual. Finally, *fexternal* are the forces
7272
returned by the driver program.
7373

74-
The fix has a set_callback() method which the external driver can call
75-
to pass a pointer to its foo() function. See the
76-
couple/lammps_quest/lmpqst.cpp file in the LAMMPS distribution for an
77-
example of how this is done. This sample application performs
78-
classical MD using quantum forces computed by a density functional
79-
code `Quest <quest_>`_.
80-
81-
.. _quest: https://www.sandia.gov/quest/
74+
The best way to set up the callback function is to use the C-language
75+
library interface function :cpp:func:`lammps_set_fix_external_callback`.
8276

8377
----------
8478

doc/src/fix_phonon.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ for other systems, *nasr* = 10 is typically sufficient.
134134
The *map_file* contains the mapping information between the lattice
135135
indices and the atom IDs, which tells the code which atom sits at
136136
which lattice point; the lattice indices start from 0. An auxiliary
137-
code, `latgen <https://code.google.com/p/latgen>`_, can be employed to
137+
code, `latgen <https://code.google.com/archive/p/latgen>`_, can be employed to
138138
generate the compatible map file for various crystals.
139139

140140
In case one simulates a non-periodic system, where the whole simulation

src/EXTRA-DUMP/dump_extxyz.cpp

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static constexpr int DELTA = 1048576;
3333
/* ---------------------------------------------------------------------- */
3434

3535
DumpExtXYZ::DumpExtXYZ(LAMMPS *lmp, int narg, char **arg) :
36-
DumpXYZ(lmp, narg, arg), properties_string(nullptr)
36+
DumpXYZ(lmp, narg, arg), properties_string(nullptr), thermo_string(nullptr)
3737
{
3838
// style specific customizable settings
3939
with_vel = 1;
@@ -65,6 +65,7 @@ DumpExtXYZ::DumpExtXYZ(LAMMPS *lmp, int narg, char **arg) :
6565
DumpExtXYZ::~DumpExtXYZ()
6666
{
6767
delete[] properties_string;
68+
delete[] thermo_string;
6869
}
6970

7071
/* ---------------------------------------------------------------------- */
@@ -135,37 +136,56 @@ int DumpExtXYZ::modify_param(int narg, char **arg)
135136

136137
/* ---------------------------------------------------------------------- */
137138

139+
int DumpExtXYZ::count()
140+
{
141+
// Dump::count() is called for all processes before writing the header.
142+
// We must update the thermodynamic data in the header here, since we are
143+
// calling computes that may perform communication. We only include data
144+
// from computes that were already invoked to avoid XXX not tallied errors.
145+
146+
delete[] thermo_string;
147+
std::string thermo_buf;
148+
149+
if (time_flag) thermo_buf += fmt::format(" Time={:.6f}", compute_time());
150+
thermo_buf += fmt::format(" pbc=\"{} {} {}\"", domain->xperiodic ? "T" : "F",
151+
domain->yperiodic ? "T" : "F", domain->zperiodic ? "T" : "F");
152+
thermo_buf +=
153+
fmt::format(" Lattice=\"{:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g}\"", domain->xprd, 0., 0.,
154+
domain->xy, domain->yprd, 0., domain->xz, domain->yz, domain->zprd);
155+
156+
if (output && output->thermo) {
157+
auto *pe = output->thermo->pe;
158+
if (pe && (pe->invoked_scalar == update->ntimestep))
159+
thermo_buf += fmt::format(" Potential_energy={}", pe->compute_scalar());
160+
161+
auto *temp = output->thermo->temperature;
162+
if (temp && (temp->invoked_scalar == update->ntimestep))
163+
thermo_buf += fmt::format(" Temperature={}", temp->compute_scalar());
164+
165+
auto *press = output->thermo->pressure;
166+
if (press && (press->invoked_vector == update->ntimestep)) {
167+
press->compute_vector();
168+
thermo_buf +=
169+
fmt::format(" Stress=\"{} {} {} {} {} {} {} {} {}\"", press->vector[0], press->vector[3],
170+
press->vector[4], press->vector[3], press->vector[1], press->vector[5],
171+
press->vector[4], press->vector[5], press->vector[2]);
172+
}
173+
}
174+
thermo_string = utils::strdup(thermo_buf);
175+
176+
// perform real count() function in parent
177+
return DumpXYZ::count();
178+
}
179+
180+
/* ---------------------------------------------------------------------- */
181+
138182
void DumpExtXYZ::write_header(bigint n)
139183
{
140184
if (me == 0) {
141185
if (!fp)
142186
error->one(FLERR, Error::NOLASTLINE, "Must not use 'run pre no' after creating a new dump");
143187

144-
std::string header = fmt::format("{}\nTimestep={}", n, update->ntimestep);
145-
if (time_flag) header += fmt::format(" Time={:.6f}", compute_time());
146-
header += fmt::format(" pbc=\"{} {} {}\"", domain->xperiodic ? "T" : "F",
147-
domain->yperiodic ? "T" : "F", domain->zperiodic ? "T" : "F");
148-
header +=
149-
fmt::format(" Lattice=\"{:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g}\"", domain->xprd, 0.,
150-
0., domain->xy, domain->yprd, 0., domain->xz, domain->yz, domain->zprd);
151-
152-
if (output && output->thermo) {
153-
auto *pe = output->thermo->pe;
154-
if (pe) header += fmt::format(" Potential_energy={}", pe->compute_scalar());
155-
156-
auto *temp = output->thermo->temperature;
157-
if (temp) header += fmt::format(" Temperature={}", temp->compute_scalar());
158-
159-
auto *press = output->thermo->pressure;
160-
if (press) {
161-
press->compute_vector();
162-
header +=
163-
fmt::format(" Stress=\"{} {} {} {} {} {} {} {} {}\"", press->vector[0],
164-
press->vector[3], press->vector[4], press->vector[3], press->vector[1],
165-
press->vector[5], press->vector[4], press->vector[5], press->vector[2]);
166-
}
167-
}
168-
188+
auto header = fmt::format("{}\nTimestep={}{}", n, update->ntimestep, thermo_string);
169189
header += fmt::format(" Properties={}", properties_string);
170190
utils::print(fp, header + "\n");
171191
}

src/EXTRA-DUMP/dump_extxyz.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ class DumpExtXYZ : public DumpXYZ {
3636
int with_temp;
3737
int with_press;
3838
char *properties_string;
39+
char *thermo_string;
3940

4041
void update_properties();
4142
void init_style() override;
43+
int count() override;
4244
void write_header(bigint) override;
4345
void pack(tagint *) override;
4446
int convert_string(int, double *) override;

src/KOKKOS/fix_spring_self_kokkos.cpp

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ void FixSpringSelfKokkos<DeviceType>::init()
8080
FixSpringSelf::init();
8181

8282
if (kstyle != CONSTANT)
83-
error->all(FLERR, "Fix spring/self/kk does not support variable spring constants (yet)");
83+
error->all(FLERR, Error::NOLASTLINE,
84+
"Fix spring/self/kk does not support variable spring constants (yet)");
8485

8586
if (utils::strmatch(update->integrate_style,"^respa"))
86-
error->all(FLERR,"Cannot (yet) use respa with Kokkos");
87+
error->all(FLERR, Error::NOLASTLINE, "Cannot (yet) use respa with Kokkos");
8788
}
8889

8990
/* ---------------------------------------------------------------------- */
@@ -107,47 +108,45 @@ void FixSpringSelfKokkos<DeviceType>::post_force(int /*vflag*/)
107108
copymode = 1;
108109

109110
{
110-
// local variables for lambda capture
111-
auto prd = Few<double,3>(domain->prd);
112-
auto h = Few<double,6>(domain->h);
113-
auto triclinic = domain->triclinic;
114-
auto l_k = k;
115-
auto l_xoriginal = d_xoriginal;
116-
117-
auto l_x = x;
118-
auto l_f = f;
119-
auto l_mask = mask;
120-
auto l_image = image;
121-
auto l_groupbit = groupbit;
122-
auto l_xflag = xflag;
123-
auto l_yflag = yflag;
124-
auto l_zflag = zflag;
125-
126-
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType>(0,nlocal), LAMMPS_LAMBDA(const int& i, double& espring_kk) {
127-
if (l_mask[i] & l_groupbit) {
128-
Few<double,3> x_i;
129-
x_i[0] = l_x(i,0);
130-
x_i[1] = l_x(i,1);
131-
x_i[2] = l_x(i,2);
132-
auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,l_image(i));
133-
auto dx = unwrap[0] - l_xoriginal(i, 0);
134-
auto dy = unwrap[1] - l_xoriginal(i, 1);
135-
auto dz = unwrap[2] - l_xoriginal(i, 2);
136-
if (!l_xflag) dx = 0.0;
137-
if (!l_yflag) dy = 0.0;
138-
if (!l_zflag) dz = 0.0;
139-
l_f(i,0) -= l_k*dx;
140-
l_f(i,1) -= l_k*dy;
141-
l_f(i,2) -= l_k*dz;
142-
espring_kk += l_k * (dx*dx + dy*dy + dz*dz);
143-
}
144-
},espring_kk);
111+
// local variables for lambda capture
112+
auto prd = Few<double,3>(domain->prd);
113+
auto h = Few<double,6>(domain->h);
114+
auto triclinic = domain->triclinic;
115+
auto l_k = k;
116+
auto l_xoriginal = d_xoriginal;
117+
118+
auto l_x = x;
119+
auto l_f = f;
120+
auto l_mask = mask;
121+
auto l_image = image;
122+
auto l_groupbit = groupbit;
123+
auto l_xflag = xflag;
124+
auto l_yflag = yflag;
125+
auto l_zflag = zflag;
126+
127+
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType>(0,nlocal), LAMMPS_LAMBDA(const int& i, double& espring_kk) {
128+
if (l_mask[i] & l_groupbit) {
129+
Few<double,3> x_i;
130+
x_i[0] = l_x(i,0);
131+
x_i[1] = l_x(i,1);
132+
x_i[2] = l_x(i,2);
133+
auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,l_image(i));
134+
auto dx = unwrap[0] - l_xoriginal(i, 0);
135+
auto dy = unwrap[1] - l_xoriginal(i, 1);
136+
auto dz = unwrap[2] - l_xoriginal(i, 2);
137+
if (!l_xflag) dx = 0.0;
138+
if (!l_yflag) dy = 0.0;
139+
if (!l_zflag) dz = 0.0;
140+
l_f(i,0) -= l_k*dx;
141+
l_f(i,1) -= l_k*dy;
142+
l_f(i,2) -= l_k*dz;
143+
espring_kk += l_k * (dx*dx + dy*dy + dz*dz);
144+
}
145+
},espring_kk);
145146
}
146147

147148
copymode = 0;
148-
149149
atomKK->modified(execution_space, F_MASK);
150-
151150
espring = 0.5*espring_kk;
152151
}
153152

src/KSPACE/fft3d.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct fft_plan_3d *fft_3d_create_plan(
251251
int scaled, int permute, int *nbuf, int usecollective)
252252
{
253253
struct fft_plan_3d *plan;
254-
int me,nprocs,nthreads;
254+
int me,nprocs;
255255
int flag,remapflag;
256256
int first_ilo,first_ihi,first_jlo,first_jhi,first_klo,first_khi;
257257
int second_ilo,second_ihi,second_jlo,second_jhi,second_klo,second_khi;
@@ -264,12 +264,14 @@ struct fft_plan_3d *fft_3d_create_plan(
264264
MPI_Comm_rank(comm,&me);
265265
MPI_Comm_size(comm,&nprocs);
266266

267+
#if defined(FFT_MKL_THREADS) || defined(FFT_FFTW_THREADS)
267268
#if defined(_OPENMP)
268269
// query OpenMP info.
269270
// should have been initialized systemwide in Comm class constructor
270-
nthreads = omp_get_max_threads();
271+
int nthreads = omp_get_max_threads();
271272
#else
272-
nthreads = 1;
273+
int nthreads = 1;
274+
#endif
273275
#endif
274276

275277
// compute division of procs in 2 dimensions not on-processor

src/KSPACE/kissfft.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void kiss_fft(kiss_fft_cfg, const FFT_DATA *, FFT_DATA *);
158158
(x)->im = KISS_FFT_SIN(phase); \
159159
} while (0)
160160

161-
static void kf_bfly2(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st, int m)
161+
static void kf_bfly2(FFT_DATA *Fout, const size_t fstride, kiss_fft_cfg st, int m)
162162
{
163163
FFT_DATA *Fout2;
164164
FFT_DATA *tw1 = st->twiddles;
@@ -178,7 +178,7 @@ static void kf_bfly2(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st
178178
} while (--m);
179179
}
180180

181-
static void kf_bfly4(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st, const size_t m)
181+
static void kf_bfly4(FFT_DATA *Fout, const size_t fstride, kiss_fft_cfg st, const size_t m)
182182
{
183183
FFT_DATA *tw1, *tw2, *tw3;
184184
FFT_DATA scratch[6];
@@ -223,7 +223,7 @@ static void kf_bfly4(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st
223223
} while (--k);
224224
}
225225

226-
static void kf_bfly3(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st, size_t m)
226+
static void kf_bfly3(FFT_DATA *Fout, const size_t fstride, kiss_fft_cfg st, size_t m)
227227
{
228228
size_t k = m;
229229
const size_t m2 = 2 * m;
@@ -264,7 +264,7 @@ static void kf_bfly3(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st
264264
} while (--k);
265265
}
266266

267-
static void kf_bfly5(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st, int m)
267+
static void kf_bfly5(FFT_DATA *Fout, const size_t fstride, kiss_fft_cfg st, int m)
268268
{
269269
FFT_DATA *Fout0, *Fout1, *Fout2, *Fout3, *Fout4;
270270
int u;
@@ -329,15 +329,15 @@ static void kf_bfly5(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st
329329
}
330330

331331
/* perform the butterfly for one stage of a mixed radix FFT */
332-
static void kf_bfly_generic(FFT_DATA *Fout, const size_t fstride, const kiss_fft_cfg st, int m,
332+
static void kf_bfly_generic(FFT_DATA *Fout, const size_t fstride, kiss_fft_cfg st, int m,
333333
int p)
334334
{
335335
int u, k, q1, q;
336336
FFT_DATA *twiddles = st->twiddles;
337337
FFT_DATA t;
338338
int Norig = st->nfft;
339339

340-
FFT_DATA *scratch = (FFT_DATA *) KISS_FFT_TMP_ALLOC(sizeof(FFT_DATA) * p);
340+
auto *scratch = (FFT_DATA *) KISS_FFT_TMP_ALLOC(sizeof(FFT_DATA) * p);
341341
for (u = 0; u < m; ++u) {
342342
k = u;
343343
for (q1 = 0; q1 < p; ++q1) {
@@ -363,7 +363,7 @@ static void kf_bfly_generic(FFT_DATA *Fout, const size_t fstride, const kiss_fft
363363
}
364364

365365
static void kf_work(FFT_DATA *Fout, const FFT_DATA *f, const size_t fstride, int in_stride,
366-
int *factors, const kiss_fft_cfg st)
366+
int *factors, kiss_fft_cfg st)
367367
{
368368
FFT_DATA *Fout_beg = Fout;
369369
const int p = *factors++; /* the radix */
@@ -482,7 +482,7 @@ static void kiss_fft_stride(kiss_fft_cfg st, const FFT_DATA *fin, FFT_DATA *fout
482482
if (fin == fout) {
483483
// NOTE: this is not really an in-place FFT algorithm.
484484
// It just performs an out-of-place FFT into a temp buffer
485-
FFT_DATA *tmpbuf = (FFT_DATA *) KISS_FFT_TMP_ALLOC(sizeof(FFT_DATA) * st->nfft);
485+
auto *tmpbuf = (FFT_DATA *) KISS_FFT_TMP_ALLOC(sizeof(FFT_DATA) * st->nfft);
486486
kf_work(tmpbuf, fin, 1, in_stride, st->factors, st);
487487
memcpy(fout, tmpbuf, sizeof(FFT_DATA) * st->nfft);
488488
KISS_FFT_TMP_FREE(tmpbuf);

0 commit comments

Comments
 (0)