Skip to content

Commit cbb0461

Browse files
committed
Merge branch 'uniformize_kernel_code' into 'master'
Use a better scheme for naming variables in kernels and other code cleaning See merge request npneq/inq!1297
2 parents 518d2ad + 35ede77 commit cbb0461

9 files changed

Lines changed: 182 additions & 185 deletions

File tree

src/hamiltonian/ks_hamiltonian.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class ks_hamiltonian {
6060
CALI_CXX_MARK_FUNCTION;
6161

6262
assert(occupations.size() == array.size());
63-
return gpu::run(gpu::reduce(array.size()), 0.0, [occ = begin(occupations), arr = begin(array)] GPU_LAMBDA (auto ip) {
64-
return occ[ip]*real(arr[ip]);
63+
return gpu::run(gpu::reduce(array.size()), 0.0, [_occupations = occupations.cbegin(), _array = array.cbegin()] GPU_LAMBDA (auto ip) {
64+
return _occupations[ip]*real(_array[ip]);
6565
});
6666
}
6767

@@ -372,13 +372,13 @@ TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG){
372372
auto hphi_f = operations::transform::to_real(ham(operations::transform::to_fourier(phi)));
373373

374374
auto diff = gpu::run(gpu::reduce(rs.local_sizes()[2]), gpu::reduce(rs.local_sizes()[1]), gpu::reduce(rs.local_sizes()[0]), complex{0.0, 0.0},
375-
[nst, hph_r = begin(hphi_r.hypercubic()), hph_f = begin(hphi_f.hypercubic())] GPU_LAMBDA (auto iz, auto iy, auto ix) {
375+
[nst, _hphi_r = begin(hphi_r.hypercubic()), _hphi_f = begin(hphi_f.hypercubic())] GPU_LAMBDA (auto iz, auto iy, auto ix) {
376376

377377
auto acc_r = 0.0;
378378
auto acc_f = 0.0;
379379
for(int ist = 0; ist < nst; ist++) {
380-
acc_r += fabs(hph_r[ix][iy][iz][ist] - 0.0);
381-
acc_f += fabs(hph_f[ix][iy][iz][ist] - 0.0);
380+
acc_r += fabs(_hphi_r[ix][iy][iz][ist] - 0.0);
381+
acc_f += fabs(_hphi_f[ix][iy][iz][ist] - 0.0);
382382
}
383383
return complex{acc_r, acc_f};
384384
});
@@ -397,7 +397,7 @@ TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG){
397397
double kk = 2.0*M_PI/rs.rlength()[0];
398398

399399
gpu::run(rs.local_sizes()[2], rs.local_sizes()[1], rs.local_sizes()[0],
400-
[kk, nst, pot = begin(ham.scalar_potential().hypercubic()), ph = begin(phi.hypercubic()), point_op = rs.point_op(),
400+
[kk, nst, pot = begin(ham.scalar_potential().hypercubic()), _phi = begin(phi.hypercubic()), point_op = rs.point_op(),
401401
part0 = rs.cubic_part(0), part1 = rs.cubic_part(1), part2 = rs.cubic_part(2), set_part = phi.set_part()] GPU_LAMBDA (auto iz, auto iy, auto ix) {
402402
pot[ix][iy][iz][0] = 0.0;
403403

@@ -409,22 +409,22 @@ TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG){
409409

410410
auto istg = set_part.local_to_global(ist);
411411
double xx = point_op.rvector_cartesian(ixg, iyg, izg)[0];
412-
ph[ix][iy][iz][ist] = complex(cos(istg.value()*kk*xx), sin(istg.value()*kk*xx));
412+
_phi[ix][iy][iz][ist] = complex(cos(istg.value()*kk*xx), sin(istg.value()*kk*xx));
413413
}
414414
});
415415

416416
auto hphi_r = ham(phi);
417417
auto hphi_f = operations::transform::to_real(ham(operations::transform::to_fourier(phi)));
418418

419419
auto diff = gpu::run(gpu::reduce(rs.local_sizes()[2]), gpu::reduce(rs.local_sizes()[1]), gpu::reduce(rs.local_sizes()[0]), complex{0.0, 0.0},
420-
[kk, nst, ph = begin(phi.hypercubic()), hph_r = begin(hphi_r.hypercubic()), hph_f = begin(hphi_f.hypercubic()), set_part = phi.set_part()] GPU_LAMBDA (auto iz, auto iy, auto ix) {
420+
[kk, nst, _phi = begin(phi.hypercubic()), _hphi_r = begin(hphi_r.hypercubic()), _hphi_f = begin(hphi_f.hypercubic()), set_part = phi.set_part()] GPU_LAMBDA (auto iz, auto iy, auto ix) {
421421

422422
auto acc_r = 0.0;
423423
auto acc_f = 0.0;
424424
for(int ist = 0; ist < nst; ist++){
425425
auto istg = set_part.local_to_global(ist);
426-
acc_r += fabs(hph_r[ix][iy][iz][ist] - 0.5*istg.value()*kk*istg.value()*kk*ph[ix][iy][iz][ist]);
427-
acc_f += fabs(hph_f[ix][iy][iz][ist] - 0.5*istg.value()*kk*istg.value()*kk*ph[ix][iy][iz][ist]);
426+
acc_r += fabs(_hphi_r[ix][iy][iz][ist] - 0.5*istg.value()*kk*istg.value()*kk*_phi[ix][iy][iz][ist]);
427+
acc_f += fabs(_hphi_f[ix][iy][iz][ist] - 0.5*istg.value()*kk*istg.value()*kk*_phi[ix][iy][iz][ist]);
428428
}
429429
return complex{acc_r, acc_f};
430430
});
@@ -442,7 +442,7 @@ TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG){
442442
double ww = 2.0;
443443

444444
gpu::run(rs.local_sizes()[2], rs.local_sizes()[1], rs.local_sizes()[0],
445-
[ww, nst, pot = begin(ham.scalar_potential().hypercubic()), ph = begin(phi.hypercubic()), point_op = rs.point_op(),
445+
[ww, nst, pot = begin(ham.scalar_potential().hypercubic()), _phi = begin(phi.hypercubic()), point_op = rs.point_op(),
446446
part0 = rs.cubic_part(0), part1 = rs.cubic_part(1), part2 = rs.cubic_part(2), set_part = phi.set_part()] GPU_LAMBDA (auto iz, auto iy, auto ix) {
447447

448448
auto ixg = part0.local_to_global(ix);
@@ -452,19 +452,19 @@ TEST_CASE(INQ_TEST_FILE, INQ_TEST_TAG){
452452
double r2 = point_op.r2(ixg, iyg, izg);
453453
pot[ix][iy][iz][0] = 0.5*ww*ww*r2;
454454

455-
for(int ist = 0; ist < nst; ist++) ph[ix][iy][iz][ist] = exp(-ww*r2);
455+
for(int ist = 0; ist < nst; ist++) _phi[ix][iy][iz][ist] = exp(-ww*r2);
456456
});
457457

458458
auto hphi_r = ham(phi);
459459
auto hphi_f = operations::transform::to_real(ham(operations::transform::to_fourier(phi)));
460460

461461
auto diff = gpu::run(gpu::reduce(rs.local_sizes()[2]), gpu::reduce(rs.local_sizes()[1]), gpu::reduce(rs.local_sizes()[0]), complex{0.0, 0.0},
462-
[ww, nst, ph = begin(phi.hypercubic()), hph_r = begin(hphi_r.hypercubic()), hph_f = begin(hphi_f.hypercubic())] GPU_LAMBDA (auto iz, auto iy, auto ix) {
462+
[ww, nst, _phi = begin(phi.hypercubic()), _hphi_r = begin(hphi_r.hypercubic()), _hphi_f = begin(hphi_f.hypercubic())] GPU_LAMBDA (auto iz, auto iy, auto ix) {
463463
auto acc_r = 0.0;
464464
auto acc_f = 0.0;
465465
for(int ist = 0; ist < nst; ist++) {
466-
acc_r += fabs(hph_r[ix][iy][iz][ist] - 1.5*ww*ph[ix][iy][iz][ist]);
467-
acc_f += fabs(hph_f[ix][iy][iz][ist] - 1.5*ww*ph[ix][iy][iz][ist]);
466+
acc_r += fabs(_hphi_r[ix][iy][iz][ist] - 1.5*ww*_phi[ix][iy][iz][ist]);
467+
acc_f += fabs(_hphi_f[ix][iy][iz][ist] - 1.5*ww*_phi[ix][iy][iz][ist]);
468468
}
469469
return complex{acc_r, acc_f};
470470
});

0 commit comments

Comments
 (0)