Skip to content

Commit

Permalink
Set and use max number of threads in refine_direct() in the api
Browse files Browse the repository at this point in the history
  • Loading branch information
pemsley committed Nov 26, 2024
1 parent efe1a1a commit b91133f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/coot-molecule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,7 @@ coot::molecule_t::get_fixed_atoms() const {

int
coot::molecule_t::refine_direct(std::vector<mmdb::Residue *> rv, const std::string &alt_loc, const clipper::Xmap<float> &xmap,
unsigned int max_number_of_threads,
float map_weight, int n_cycles, const coot::protein_geometry &geom,
bool do_rama_plot_restraints, float rama_plot_weight,
bool do_torsion_restraints, float torsion_weight,
Expand Down Expand Up @@ -2447,7 +2448,7 @@ coot::molecule_t::refine_direct(std::vector<mmdb::Residue *> rv, const std::stri
if (do_torsion_restraints) flags = TYPICAL_RESTRAINTS_WITH_TORSIONS;
pseudo_restraint_bond_type pseudos = NO_PSEUDO_BONDS;

int n_threads = 4; // coot::get_max_number_of_threads();
int n_threads = max_number_of_threads;
ctpl::thread_pool thread_pool(n_threads);
restraints.thread_pool(&thread_pool, n_threads);

Expand Down
1 change: 1 addition & 0 deletions api/coot-molecule.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ namespace coot {

//! real space refinement
int refine_direct(std::vector<mmdb::Residue *> rv, const std::string &alt_loc, const clipper::Xmap<float> &xmap,
unsigned int max_number_of_threads,
float map_weight, int n_cycles, const coot::protein_geometry &geom,
bool do_rama_plot_restraints, float rama_plot_weight,
bool do_torsion_restraints, float torsion_weight,
Expand Down
1 change: 1 addition & 0 deletions api/molecules-container-nanobind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ NB_MODULE(chapi, m) {
.def("set_make_backups",&molecules_container_t::set_make_backups)
.def("set_map_sampling_rate",&molecules_container_t::set_map_sampling_rate)
.def("set_map_weight",&molecules_container_t::set_map_weight)
.def("set_max_number_of_threads",&molecules_container_t::set_max_number_of_threads)
.def("set_molecule_name",&molecules_container_t::set_molecule_name)
.def("set_rama_plot_restraints_weight",&molecules_container_t::set_rama_plot_restraints_weight)
.def("set_refinement_is_verbose",&molecules_container_t::set_refinement_is_verbose)
Expand Down
6 changes: 5 additions & 1 deletion api/molecules-container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2891,11 +2891,15 @@ molecules_container_t::refine_direct(int imol, std::vector<mmdb::Residue *> rv,
<< " and imol_refinement_map " << imol_refinement_map
<< std::endl;

// this is not stored in molecules_container!
unsigned int max_number_of_threads = thread_pool.size();

int status = 0;
if (is_valid_model_molecule(imol)) {
if (is_valid_map_molecule(imol_refinement_map)) {
const clipper::Xmap<float> &xmap = molecules[imol_refinement_map].xmap;
status = molecules[imol].refine_direct(rv, alt_loc, xmap, map_weight, n_cycles, geom,
status = molecules[imol].refine_direct(rv, alt_loc, xmap, max_number_of_threads,
map_weight, n_cycles, geom,
use_rama_plot_restraints, rama_plot_restraints_weight,
use_torsion_restraints, torsion_restraints_weight,
refinement_is_quiet);
Expand Down
2 changes: 1 addition & 1 deletion src/c-interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,7 @@ void set_map_radius_em(float radius) {
for (int ii=0; ii<g.n_molecules(); ii++)
g.molecules[ii].update_map(true);
graphics_draw();
std::string cmd = "set-radius-em";
std::string cmd = "set-map-radius-em";
std::vector<coot::command_arg_t> args;
args.push_back(radius);
add_to_history_typed(cmd, args);
Expand Down

0 comments on commit b91133f

Please sign in to comment.