Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pool_util.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @brief
12 /// @author
13 
14 #include <basic/prof.hh>
15 #include <ObjexxFCL/FArray2D.hh>
16 #include <utility/vector1.hh>
17 #include <core/types.hh>
19 #include <basic/Tracer.hh>
20 
21 
22 static basic::Tracer TR("HPool_util");
23 
24 #ifdef USEMPI
25 #include <mpi.h>
26 #endif
27 
28 namespace protocols{
29 namespace canonical_sampling{
30 namespace mc_convergence_checks {
31 
32  typedef ObjexxFCL::FArray2D<double> FArray2D_double;
34  using namespace core;
35 
37  neighbor_addresses_(0),
38  coords_transfer_buffer_(0),
39  coords_receiving_buffer_(0),
40  coords_(),
41  temp_coords_(),
42  num_new_neighbors_(0),
43  memory_offset_(0),
44  int_buf1_(0),
45  winning_ranks_(0),
46  candidate_nbr_index_(0),
47  candidate_best_rmsd_(0.0),
48  candidate_best_rmsds_(0),
49  candidate_address_(),
50  winning_tag_(""),
51  winning_address_(),
52  new_level_begins_(0),
53  best_candidate_rmsds_(),
54  is_a_neighbor_(),
55  finished_(0)
56  {}
57 
58  void
59  DataBuffer::setup( int num_slave_nodes, int nresidues, int nlevels ){
60  TR.Debug << "setting up pool-util: num-slave-nodes: " << num_slave_nodes <<
61  " num-residues: " << nresidues <<
62  " nlevels: " << nlevels << std::endl;
63 
64  neighbor_addresses_ = new int[ num_slave_nodes * nlevels ];
65  coords_transfer_buffer_ = new double[ (nresidues * 3) ];
66  coords_receiving_buffer_ = new double[ (nresidues * 3 * num_slave_nodes ) ];
67  coords_ = FArray2D_double( 3, nresidues, 0.0 );
68  temp_coords_ = FArray2D_double( 3, nresidues, 0.0 );
70  memory_offset_ = new int[ num_slave_nodes ];
71  int_buf1_ = new int[ num_slave_nodes * nlevels ];
72  winning_ranks_ = new int[ num_slave_nodes * ( nlevels + 1 ) ];
73  candidate_best_rmsds_ = new double[ num_slave_nodes ];
74  candidate_address_.resize( nlevels, 0 );
75  winning_address_.resize( nlevels, 0 );
76  candidate_coords_ = FArray2D_double( 3, nresidues, 0.0);
77  is_a_neighbor_ = utility::vector1<bool>( num_slave_nodes, false );
78  finished_ = new int[ num_slave_nodes ];
79  }
80 
82  delete [] neighbor_addresses_;
83  delete [] coords_transfer_buffer_;
84  delete [] coords_receiving_buffer_;
85  delete [] memory_offset_;
86  delete [] int_buf1_;
87  delete [] winning_ranks_;
88  delete [] candidate_best_rmsds_;
89  delete [] finished_;
90  }
91 
92  void
93  DataBuffer::address_to_buf( Address & address, int* buf, core::Size start_index ) {
94  for( core::Size ii = 1; ii <= address.size(); ii++ ) {
95  buf[ ii - 1 + start_index ] = address[ ii ];
96  }
97  }
98 
99  void
100  DataBuffer::buf_to_address( Address & address, int* buf, core::Size start_index ){
101  for( core::Size ii = 1; ii <= address.size(); ii++ ) {
102  address[ ii ] = buf[ ii - 1 + start_index ];
103  }
104  }
105 
106 
107  void
109  core::Size /*num_to_add*/,
110  FArray2D_double const& coords,
111  double* coord_buf ){
112  PROF_START( basic::FARRAY_MANIPULATION );
113  for (int ii = 1; ii <= coords.u1(); ii++ ) {
114  for (int jj = 1; jj <= coords.u2(); jj++ ) {
115  coord_buf[index++] = coords( ii, jj );
116  }
117  }
118  PROF_STOP( basic::FARRAY_MANIPULATION );
119  }
120 
121  void
123  FArray2D_double const& coords,
124  double* coord_buf ){
125  farray_to_array( index, 1, coords, coord_buf );
126  }
127 
128  void
130  core::Size /*num_to_add*/,
131  FArray2D_double & coords,
132  double* coord_buf){
133  PROF_START( basic::FARRAY_MANIPULATION );
134  for ( int ii = 1; ii <= coords.u1(); ii++ ) {
135  for( int jj = 1; jj <= coords.u2(); jj++ ) {
136  coords( ii, jj ) = coord_buf[index++];
137  }
138  }
139  PROF_STOP( basic::FARRAY_MANIPULATION );
140  }
141 
142  void
144  FArray2D_double & coords,
145  double* coord_buf){
146  array_to_farray( index, 1, coords, coord_buf );
147  }
148 
149 
150 }
151 }
152 }
153 
154