// perform a heatbath int hb_update( struct site *lat , const struct hb_info HBINFO , const char *traj_name , const GLU_output storage , const char *output_details , const GLU_bool continuation ) { // counters size_t i ; // seed the parallel RNG char str[ 256 ] ; // strip the number in the infile if it has one char *pch = strtok( (char*)traj_name , "." ) ; sprintf( str , "%s.%zu.rand" , pch , Latt.flow ) ; if( continuation == GLU_FALSE ) { fprintf( stdout , "[UPDATE] initialising par_rng from pool\n" ) ; if( initialise_par_rng( NULL ) == GLU_FAILURE ) { return GLU_FAILURE ; } } else { fprintf( stdout , "[UPDATE] restarting from a previous trajectory\n" ) ; if( initialise_par_rng( str ) == GLU_FAILURE ) { return GLU_FAILURE ; } } // initialise the draughtboard struct draughtboard db ; if( init_cb( &db , LVOLUME , ND ) == GLU_FAILURE ) { return GLU_FAILURE ; } // this guy appears throughout the HB algorithm const double inverse_beta = NC/(HBINFO.beta) ; // give us some information fprintf( stdout , "[UPDATE] Performing %zu HB-OR iterations\n" , HBINFO.iterations ) ; fprintf( stdout , "[UPDATE] Themalising for %zu iterations\n" , HBINFO.therm ) ; fprintf( stdout , "[UPDATE] %zu over-relaxations per heatbath\n" , HBINFO.Nor ) ; fprintf( stdout , "[UPDATE] Saving every %zu iteration(s)\n" , HBINFO.Nsave ) ; fprintf( stdout , "[UPDATE] Using beta = %1.12f \n" , HBINFO.beta ) ; // thermalise start_timer( ) ; for( i = 0 ; i < HBINFO.therm ; i++ ) { update_lattice( lat , inverse_beta , db , HBINFO.Nor ) ; if( !(i&15) ) { fprintf( stdout , "\n[UPDATE] config %zu done \n" , i ) ; print_time() ; } } print_time( ) ; // iterate the number of runs const size_t start = Latt.flow ; for( i = Latt.flow ; i < HBINFO.iterations ; i++ ) { // perform a hb-OR step update_lattice( lat , inverse_beta , db , HBINFO.Nor ) ; // set the lattice flow // if we are saving the data print out the plaquette and write a file if( i%HBINFO.Nmeasure == 0 ) { // write out the plaquette fprintf( stdout , "[UPDATE] %zu :: {P} %1.12f \n" , i , av_plaquette( lat ) ) ; // write the temporal polyakov loop, (re,im) |L| const double complex L = poly( lat , ND-1 ) / ( LCU * NC ) ; fprintf( stdout , "[UPDATE] {L} ( %f , %f ) %f \n" , creal( L ) , cimag( L ) , cabs( L ) ) ; } // if we hit a save point we write out the configuration if( i%HBINFO.Nsave == 0 && i != start ) { // write a configuration sprintf( str , "%s.%zu" , traj_name , i ) ; write_configuration( lat , str , storage , output_details ) ; // write out the rng state sprintf( str , "%s.rand" , str ) ; write_par_rng_state( str ) ; } Latt.flow = i + 1 ; } // free the draughtboard free_cb( &db ) ; // tell us how long this generation took print_time() ; // free the rng free_par_rng( ) ; return GLU_SUCCESS ; }
// main int main( void ) { // inits attach_GLU( ) ; // 4^ND periodic lattice size_t mu ; for( mu = 0 ; mu < ND ; mu++ ) { Latt.dims[ mu ] = 4 ; } // initialise geometry so that we can use LVOLUME and stuff init_latt( ) ; // set the seed to something I know answers for Latt.Seed[0] = 1 ; // initialise rng initialise_par_rng( NULL ) ; // a counter for all the tests we have done int full_tests_run = 0 ; // test rng char *test_results ; if( ( test_results = rng_tests( ) ) != 0 ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // first one is simple linear algebra tests if( UNOPS_test() == GLU_FAILURE ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // matrix multiply tests if( MMUL_test() == GLU_FAILURE ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // log-exponentiate tests if( ( test_results = logexp_tests( ) ) != 0 ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // matrix inversion/determinant tests if( ( test_results = inversion_tests( ) ) != 0 ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // geometry tests if( geometry_test() == GLU_FAILURE ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // general lattice configuration tests if( ( test_results = config_tests( ) ) != 0 ) { goto TEST_FAILURE ; } full_tests_run += tests_run ; // if we are successful we go there goto TEST_SUCCESS ; TEST_FAILURE : unstick_GLU( ) ; fprintf( stderr , "[GLUnit] Test failure \n%s \n" , test_results ) ; return GLU_FAILURE ; TEST_SUCCESS : unstick_GLU( ) ; fprintf( stderr , "[GLUnit] All %d tests passed \n" , full_tests_run ) ; return GLU_SUCCESS ; }