Skip to content

Commit

Permalink
Merge pull request #217 from phonopy/refactoring
Browse files Browse the repository at this point in the history
Replace openmp_per_bands and openmp_at_bands by !openmp_per_triplets  in C
  • Loading branch information
atztogo authored Apr 18, 2024
2 parents f5ead28 + 44a404a commit 472d564
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 128 deletions.
2 changes: 1 addition & 1 deletion c/_phono3py.c
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ static PyObject *py_get_triplets_integration_weights(PyObject *self,
ph3py_get_integration_weight(
iw, iw_zero, frequency_points, num_band0, relative_grid_address, D_diag,
triplets, num_triplets, bz_grid_addresses, bz_map, bz_grid_type,
frequencies1, num_band1, frequencies2, num_band2, tp_type, 1, 0);
frequencies1, num_band1, frequencies2, num_band2, tp_type, 1);

Py_RETURN_NONE;
}
Expand Down
10 changes: 5 additions & 5 deletions c/gridsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ long gridsys_get_integration_weight(
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets, const long openmp_per_bands) {
const long openmp_per_triplets) {
ConstBZGrid *bzgrid;
long i;

Expand All @@ -282,10 +282,10 @@ long gridsys_get_integration_weight(
bzgrid->D_diag[i] = D_diag[i];
}

tpl_get_integration_weight(
iw, iw_zero, frequency_points, num_band0, relative_grid_address,
triplets, num_triplets, bzgrid, frequencies1, num_band1, frequencies2,
num_band2, tp_type, openmp_per_triplets, openmp_per_bands);
tpl_get_integration_weight(iw, iw_zero, frequency_points, num_band0,
relative_grid_address, triplets, num_triplets,
bzgrid, frequencies1, num_band1, frequencies2,
num_band2, tp_type, openmp_per_triplets);
free(bzgrid);
bzgrid = NULL;

Expand Down
2 changes: 1 addition & 1 deletion c/gridsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ long gridsys_get_integration_weight(
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets, const long openmp_per_bands);
const long openmp_per_triplets);
void gridsys_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
Expand Down
24 changes: 12 additions & 12 deletions c/interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static void real_to_normal(double *fc3_normal_squared, const long (*g_pos)[4],
const double *masses, const long *band_indices,
const long num_band, const double cutoff_frequency,
const long triplet_index, const long num_triplets,
const long openmp_at_bands);
const long openmp_per_triplets);
static void real_to_normal_sym_q(
double *fc3_normal_squared, const long (*g_pos)[4], const long num_g_pos,
double *const freqs[3], lapack_complex_double *const eigvecs[3],
Expand All @@ -67,7 +67,7 @@ static void real_to_normal_sym_q(
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long num_band0, const long num_band,
const double cutoff_frequency, const long triplet_index,
const long num_triplets, const long openmp_at_bands);
const long num_triplets, const long openmp_per_triplets);

/* fc3_normal_squared[num_triplets, num_band0, num_band, num_band] */
void itr_get_interaction(
Expand Down Expand Up @@ -101,7 +101,7 @@ void itr_get_interaction(
g_pos, num_g_pos, frequencies->data, eigenvectors, triplets[i],
bzgrid, fc3, is_compact_fc3, atom_triplets, masses, band_indices,
symmetrize_fc3_q, cutoff_frequency, i, num_triplets,
1 - openmp_per_triplets);
openmp_per_triplets);

free(g_pos);
g_pos = NULL;
Expand All @@ -118,7 +118,7 @@ void itr_get_interaction_at_triplet(
const double cutoff_frequency,
const long triplet_index, /* only for print */
const long num_triplets, /* only for print */
const long openmp_at_bands) {
const long openmp_per_triplets) {
long j, k;
double *freqs[3];
lapack_complex_double *eigvecs[3];
Expand Down Expand Up @@ -149,7 +149,7 @@ void itr_get_interaction_at_triplet(
fc3_normal_squared, g_pos, num_g_pos, freqs, eigvecs, fc3,
is_compact_fc3, q_vecs, /* q0, q1, q2 */
atom_triplets, masses, band_indices, num_band0, num_band,
cutoff_frequency, triplet_index, num_triplets, openmp_at_bands);
cutoff_frequency, triplet_index, num_triplets, openmp_per_triplets);
for (j = 0; j < 3; j++) {
free(freqs[j]);
freqs[j] = NULL;
Expand All @@ -167,7 +167,7 @@ void itr_get_interaction_at_triplet(
is_compact_fc3, q_vecs, /* q0, q1, q2 */
atom_triplets, masses, band_indices, num_band,
cutoff_frequency, triplet_index, num_triplets,
openmp_at_bands);
openmp_per_triplets);
}
}

Expand All @@ -183,7 +183,7 @@ static void real_to_normal(double *fc3_normal_squared, const long (*g_pos)[4],
const double *masses, const long *band_indices,
const long num_band, const double cutoff_frequency,
const long triplet_index, const long num_triplets,
const long openmp_at_bands) {
const long openmp_per_triplets) {
lapack_complex_double *fc3_reciprocal;
lapack_complex_double comp_zero;
long i;
Expand All @@ -195,18 +195,18 @@ static void real_to_normal(double *fc3_normal_squared, const long (*g_pos)[4],
fc3_reciprocal[i] = comp_zero;
}
r2r_real_to_reciprocal(fc3_reciprocal, q_vecs, fc3, is_compact_fc3,
atom_triplets, openmp_at_bands);
atom_triplets, openmp_per_triplets);

#ifdef MEASURE_R2N
if (openmp_at_bands && num_triplets > 0) {
if ((!openmp_per_triplets) && num_triplets > 0) {
printf("At triplet %d/%d (# of bands=%d):\n", triplet_index,
num_triplets, num_band0);
}
#endif
reciprocal_to_normal_squared(
fc3_normal_squared, g_pos, num_g_pos, fc3_reciprocal, freqs0, freqs1,
freqs2, eigvecs0, eigvecs1, eigvecs2, masses, band_indices, num_band,
cutoff_frequency, openmp_at_bands);
cutoff_frequency, openmp_per_triplets);

free(fc3_reciprocal);
fc3_reciprocal = NULL;
Expand All @@ -220,7 +220,7 @@ static void real_to_normal_sym_q(
const AtomTriplets *atom_triplets, const double *masses,
const long *band_indices, const long num_band0, const long num_band,
const double cutoff_frequency, const long triplet_index,
const long num_triplets, const long openmp_at_bands) {
const long num_triplets, const long openmp_per_triplets) {
long i, j, k, l;
long band_ex[3];
double q_vecs_ex[3][3];
Expand All @@ -246,7 +246,7 @@ static void real_to_normal_sym_q(
eigvecs[index_exchange[i][1]], eigvecs[index_exchange[i][2]], fc3,
is_compact_fc3, q_vecs_ex, /* q0, q1, q2 */
atom_triplets, masses, band_indices, num_band, cutoff_frequency,
triplet_index, num_triplets, openmp_at_bands);
triplet_index, num_triplets, openmp_per_triplets);
for (j = 0; j < num_band0; j++) {
for (k = 0; k < num_band; k++) {
for (l = 0; l < num_band; l++) {
Expand Down
2 changes: 1 addition & 1 deletion c/interaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ void itr_get_interaction_at_triplet(
const double cutoff_frequency,
const long triplet_index, /* only for print */
const long num_triplets, /* only for print */
const long openmp_at_bands);
const long openmp_per_triplets);

#endif
10 changes: 5 additions & 5 deletions c/phono3py.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ long ph3py_get_integration_weight(
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets, const long openmp_per_bands) {
const long openmp_per_triplets) {
ConstBZGrid *bzgrid;
long i;

Expand All @@ -451,10 +451,10 @@ long ph3py_get_integration_weight(
bzgrid->D_diag[i] = D_diag[i];
}

tpl_get_integration_weight(
iw, iw_zero, frequency_points, num_band0, relative_grid_address,
triplets, num_triplets, bzgrid, frequencies1, num_band1, frequencies2,
num_band2, tp_type, openmp_per_triplets, openmp_per_bands);
tpl_get_integration_weight(iw, iw_zero, frequency_points, num_band0,
relative_grid_address, triplets, num_triplets,
bzgrid, frequencies1, num_band1, frequencies2,
num_band2, tp_type, openmp_per_triplets);
free(bzgrid);
bzgrid = NULL;

Expand Down
2 changes: 1 addition & 1 deletion c/phono3py.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ long ph3py_get_integration_weight(
const long (*bz_grid_addresses)[3], const long *bz_map,
const long bz_grid_type, const double *frequencies1, const long num_band1,
const double *frequencies2, const long num_band2, const long tp_type,
const long openmp_per_triplets, const long openmp_per_bands);
const long openmp_per_triplets);
void ph3py_get_integration_weight_with_sigma(
double *iw, char *iw_zero, const double sigma, const double sigma_cutoff,
const double *frequency_points, const long num_band0,
Expand Down
4 changes: 2 additions & 2 deletions c/pp_collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void ppc_get_pp_collision(
triplets[i], 1, bzgrid,
frequencies, /* used as f1 */
num_band, frequencies, /* used as f2 */
num_band, 2, 1 - openmp_per_triplets);
num_band, 2, openmp_per_triplets);

get_collision(ise + i * num_temps * num_band0, num_band0, num_band,
num_temps, temperatures->data, g, g_zero, frequencies,
Expand Down Expand Up @@ -179,7 +179,7 @@ void ppc_get_pp_collision_with_sigma(
g_zero = (char *)malloc(sizeof(char) * num_band_prod);
tpi_get_integration_weight_with_sigma(
g, g_zero, sigma, cutoff, freqs_at_gp, num_band0, triplets[i],
const_adrs_shift, frequencies, num_band, 2, 0);
const_adrs_shift, frequencies, num_band, 2, 1);

get_collision(ise + i * num_temps * num_band0, num_band0, num_band,
num_temps, temperatures->data, g, g_zero, frequencies,
Expand Down
Loading

0 comments on commit 472d564

Please sign in to comment.