Skip to content

Commit

Permalink
Merge pull request #528 from electronic-structure/fix-full-potential-…
Browse files Browse the repository at this point in the history
…memory-error

cusolver for lapw expects matrices, eigenvectors already allocated
  • Loading branch information
toxa81 authored Aug 17, 2020
2 parents 332480b + 23fb9ec commit e8abefb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/band/diag_full_potential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ Band::diag_full_potential_first_variation_exact(Hamiltonian_k& Hk__) const
/* setup Hamiltonian and overlap */
Hk__.set_fv_h_o(h, o);

//if (ctx_.gen_evp_solver_type() == ev_solver_t::cusolver || ctx_.processing_unit() == device_t::GPU) {
// //h.allocate(ctx_.mem_pool(memory_t::device));
// //o.allocate(ctx_.mem_pool(memory_t::device));
// h.deallocate(memory_t::device);
// o.deallocate(memory_t::device);
//}
if (ctx_.gen_evp_solver().type() == ev_solver_t::cusolver) {
auto& mpd = ctx_.mem_pool(memory_t::device);
h.allocate(mpd);
o.allocate(mpd);
kp.fv_eigen_vectors().allocate(mpd);
}

ctx_.print_memory_usage(__FILE__, __LINE__);

Expand Down Expand Up @@ -98,6 +98,12 @@ Band::diag_full_potential_first_variation_exact(Hamiltonian_k& Hk__) const
if (solver.solve(kp.gklo_basis_size(), ctx_.num_fv_states(), h, o, eval.data(), kp.fv_eigen_vectors())) {
TERMINATE("error in generalized eigen-value problem");
}

if (ctx_.gen_evp_solver().type() == ev_solver_t::cusolver) {
h.deallocate(memory_t::device);
o.deallocate(memory_t::device);
kp.fv_eigen_vectors().deallocate(memory_t::device);
}
kp.set_fv_eigen_values(&eval[0]);

for (int i = 0; i < ctx_.num_fv_states(); i++) {
Expand Down

0 comments on commit e8abefb

Please sign in to comment.