|
33 | 33 | #include <algorithm> |
34 | 34 | #include <cstdlib> |
35 | 35 | #include <cmath> |
| 36 | + |
| 37 | +#if __has_include("mpi.h") |
36 | 38 | #include <mpi.h> |
| 39 | +#endif |
37 | 40 |
|
38 | 41 | #ifdef TIMING |
39 | 42 | #include <iomanip> |
@@ -103,6 +106,7 @@ namespace grb { |
103 | 106 | return rc; |
104 | 107 | } |
105 | 108 |
|
| 109 | +#if __has_include("mpi.h") |
106 | 110 | template< |
107 | 111 | typename TempType, |
108 | 112 | typename EnergyType |
@@ -151,9 +155,6 @@ namespace grb { |
151 | 155 | msg = new struct data< TempType, EnergyType > [2]; |
152 | 156 | pt_tmp = new grb::Vector< StateType, backend >( n ); |
153 | 157 | rc = rc ? rc : grb::set( *pt_tmp, static_cast< StateType >( 0 ) ); |
154 | | - // rc = rc ? rc : grb::rdma<>::register_global( msg[ 0 ] ); |
155 | | - // rc = rc ? rc : grb::rdma<>::register_global( msg[ 1 ] ); |
156 | | - // rc = rc ? rc : grb::rdma<>::register_global( *pt_tmp ); |
157 | 158 | } |
158 | 159 | grb::Vector< StateType, backend > &tmp = *pt_tmp; |
159 | 160 |
|
@@ -182,7 +183,6 @@ namespace grb { |
182 | 183 | rc = rc ? rc : grb::setElement( energies, msg[ 1 ].e, n_replicas - 1 ); |
183 | 184 | } |
184 | 185 | } |
185 | | - // std::cerr << s << " " << "A done." << std::endl; |
186 | 186 |
|
187 | 187 | for( size_t i = n_replicas - 1 ; i > 0 ; --i ){ |
188 | 188 | const EnergyType de = ( energies[ i ] - energies[ i-1 ]) * (betas[ i ] - betas[ i-1 ]); |
@@ -221,6 +221,7 @@ namespace grb { |
221 | 221 | #endif |
222 | 222 | return rc; |
223 | 223 | } |
| 224 | +#endif |
224 | 225 |
|
225 | 226 |
|
226 | 227 | /* |
@@ -406,13 +407,15 @@ namespace grb { |
406 | 407 | // TODO: update best state to match best energy |
407 | 408 | } |
408 | 409 |
|
| 410 | +#if __has_include("mpi.h") |
409 | 411 | if( msg != nullptr ){ |
410 | 412 | // rc = rc ? rc : grb::rdma<>::deregister( msg[ 0 ] ); |
411 | 413 | // rc = rc ? rc : grb::rdma<>::deregister( msg[ 1 ] ); |
412 | 414 | // rc = rc ? rc : grb::rdma<>::deregister( *pt_tmp ); |
413 | 415 | delete msg; msg = nullptr; |
414 | 416 | delete pt_tmp; pt_tmp = nullptr; |
415 | 417 | } |
| 418 | +#endif |
416 | 419 | return rc; |
417 | 420 | } |
418 | 421 |
|
@@ -496,7 +499,7 @@ namespace grb { |
496 | 499 | } |
497 | 500 |
|
498 | 501 | // add new mask |
499 | | - masks.emplace_back( grb::Vector< bool, backend >( n ) ); |
| 502 | + masks.emplace_back( grb::Vector< MaskType, backend >( n ) ); |
500 | 503 | auto &new_mask = masks.at(i); |
501 | 504 | rc = rc ? rc : grb::resize( new_mask, n ); |
502 | 505 | rc = rc ? rc : grb::set< descr >( new_mask, frontier, static_cast< MaskType >(true) ); |
@@ -618,7 +621,7 @@ namespace grb { |
618 | 621 |
|
619 | 622 | #ifdef TIMING |
620 | 623 | if( s == 0 ){ |
621 | | - std::cerr << "Starting simulated_annealing_RE_ising" << "\n"; |
| 624 | + std::cerr << "Starting simulated_annealing_RE_Ising" << "\n"; |
622 | 625 | } |
623 | 626 | auto start = std::chrono::high_resolution_clock::now(); |
624 | 627 | #endif |
@@ -682,7 +685,8 @@ namespace grb { |
682 | 685 | start = std::chrono::high_resolution_clock::now(); |
683 | 686 | #endif |
684 | 687 |
|
685 | | - std::vector< grb::Vector< bool, backend > > masks ; |
| 688 | + using MaskType = bool; |
| 689 | + std::vector< grb::Vector< MaskType, backend > > masks ; |
686 | 690 | rc = rc ? rc : matrix_partition< descr >( masks, couplings, h, rand, seed ); |
687 | 691 | #ifdef TIMING |
688 | 692 | end = std::chrono::high_resolution_clock::now(); |
@@ -896,7 +900,7 @@ namespace grb { |
896 | 900 | EnergyType &best_energy, |
897 | 901 | const size_t &n_sweeps, |
898 | 902 | const EnergyType &goal = 0, |
899 | | - const size_t &pt_time = false, |
| 903 | + const size_t &pt_time = 0, |
900 | 904 | const int seed = 42, |
901 | 905 | const Ring &ring = Ring() |
902 | 906 | ){ |
|
0 commit comments