diff --git a/examples/Makefile.am b/examples/Makefile.am index 361de521c051eea0613e524505648f68ef03021c..ab653f6d9a7b13c44b3e4686eb67e740c5deb01d 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,6 +1,7 @@ # This file is part of GadgetSMP. -# Coypright (c) 2012 pedro.gonnet@durham.ac.uk. +# Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk), +# Matthieu Schaller (matthieu.schaller@durham.ac.uk). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,7 +22,7 @@ AUTOMAKE_OPTIONS=gnu # Add the source directory and debug to CFLAGS AM_CFLAGS = -g -Wall -Werror -I../src $(OPENMP_CFLAGS) -DCPU_TPS=2.67e9 -AM_LDFLAGS = $(HDF5_LDFLAGS) +AM_LDFLAGS = # Set-up the library bin_PROGRAMS = test @@ -29,5 +30,5 @@ bin_PROGRAMS = test # Sources for test test_SOURCES = test.c test_CFLAGS = -DCOUNTER -DTIMER $(AM_CFLAGS) -test_LDADD = ../src/.libs/libgadgetsmp.a +test_LDADD = ../src/.libs/libgadgetsmp.a $(HDF5_LDFLAGS) diff --git a/examples/test.c b/examples/test.c index 5bcec2a09b20d51a9d3497f98c8592a67d03f5c5..ea8fa10fd9a240a86ada40255dea6cb25c9b4f9c 100644 --- a/examples/test.c +++ b/examples/test.c @@ -1,6 +1,7 @@ /******************************************************************************* * This file is part of GadgetSMP. - * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk) + * Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk), + * Matthieu Schaller (matthieu.schaller@durham.ac.uk) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -352,7 +353,7 @@ void read_id ( char *fname , struct part *parts , int N ) { for ( k = 0 ; k < N ; k++ ) { if ( gzgets( fd , buff , 1024 ) == NULL ) error( "Error reading id file." ); - if ( sscanf( buff , "%li" , &parts[k].id ) != 1 ) { + if ( sscanf( buff , "%lli" , &parts[k].id ) != 1 ) { printf( "read_id: failed to parse %ith entry.\n" , k ); error( "Error parsing id file." ); } @@ -406,7 +407,7 @@ void read_dt ( char *fname , struct part *parts , int N ) { for ( k = 0 ; k < N ; k++ ) { if ( gzgets( fd , buff , 1024 ) == NULL ) error( "Error reading id file." ); - if ( sscanf( buff , "%i" , &parts[k].dt ) != 1 ) + if ( sscanf( buff , "%f" , &parts[k].dt ) != 1 ) error( "Error parsing dt file." ); } @@ -532,7 +533,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in r2 = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; if ( r2 < p->h*p->h ) { runner_iact_density( r2 , NULL , p->h , parts[k].h , p , &parts[k] ); - printf( "runner_dopair: interacting particles %i [%i,%i,%i] and %li [%i,%i,%i].\n" , + printf( "runner_dopair: interacting particles %i [%i,%i,%i] and %lli [%i,%i,%i].\n" , pid , (int)(parts[pid].x[0]*ih) , (int)(parts[pid].x[1]*ih) , (int)(parts[pid].x[2]*ih) , parts[k].id , (int)(parts[k].x[0]*ih) , (int)(parts[k].x[1]*ih) , (int)(parts[k].x[2]*ih) ); parts[k].rho = 0.0; @@ -542,7 +543,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in } /* Dump the result. */ - printf( "pairs_single: wcount of part %li (h=%e) is %.3f (nr. pairs %i).\n" , p->id , p->h , p->wcount + 32.0/3 , p->icount ); + printf( "pairs_single: wcount of part %lli (h=%e) is %.3f (nr. pairs %i).\n" , p->id , p->h , p->wcount + 32.0/3 , p->icount ); fflush(stdout); p->rho = 0.0; @@ -590,7 +591,7 @@ void pairs_single_old ( double *dim , struct part *__restrict__ parts , int N , } r = sqrt( dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2] ); if ( r < th ) - printf( "pairs_single: %i %li [%e,%e,%e] %e\n" , + printf( "pairs_single: %i %lli [%e,%e,%e] %e\n" , tid , parts[k].id , dx[0] , dx[1] , dx[2] , r ); } @@ -633,25 +634,31 @@ int main ( int argc , char *argv[] ) { struct space s; struct engine e; char ICfileName[200]; + float dt = 1.0f; ticks tic; /* Init the space. */ bzero( &s , sizeof(struct space) ); /* Parse the options */ - while ( ( c = getopt( argc , argv , "f:a:m:s:t:q:r:z:" ) ) != -1 ) + while ( ( c = getopt( argc , argv , "a:d:f:m:s:t:q:r:z:" ) ) != -1 ) switch( c ) { - case 'f': - if( !strcpy(ICfileName, optarg)) - error("Error parsing IC file name."); - printf("main: IC to be read from file '%s'\n", ICfileName); - break; case 'a': if ( sscanf( optarg , "%lf" , &scaling ) != 1 ) error( "Error parsing cutoff scaling." ); printf( "main: scaling cutoff by %.3f.\n" , scaling ); fflush(stdout); break; + case 'd': + if ( sscanf( optarg , "%f" , &dt ) != 1 ) + error( "Error parsing timestep." ); + printf( "main: dt set to %.3f.\n" , dt ); fflush(stdout); + break; + case 'f': + if( !strcpy(ICfileName, optarg)) + error("Error parsing IC file name."); + printf("main: IC to be read from file '%s'\n", ICfileName); + break; case 'm': if ( sscanf( optarg , "%lf" , &h_max ) != 1 ) error( "Error parsing h_max." ); @@ -816,6 +823,10 @@ int main ( int argc , char *argv[] ) { space_init( &s , dim , parts , N , periodic , h_max ); printf( "main: space_init took %.3f ms.\n" , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout); + /* Set the default time step to 1.0f. */ + s.dt = dt; + printf( "main: space dt is %f.\n" , s.dt ); + /* Say a few nice things about the space we just created. */ printf( "main: space dimensions are [ %.3f %.3f %.3f ].\n" , s.dim[0] , s.dim[1] , s.dim[2] ); printf( "main: space %s periodic.\n" , s.periodic ? "is" : "isn't" ); @@ -856,7 +867,6 @@ int main ( int argc , char *argv[] ) { /* Let loose a runner on the space. */ for ( j = 0 ; j < runs ; j++ ) { printf( "main: starting run %i/%i with %i threads and %i queues...\n" , j+1 , runs , e.nr_threads , e.nr_queues ); fflush(stdout); - tic = getticks(); #ifdef TIMER for ( k = 0 ; k < runner_timer_count ; k++ ) runner_timer[k] = 0; @@ -869,6 +879,10 @@ int main ( int argc , char *argv[] ) { for ( k = 0 ; k < runner_counter_count ; k++ ) runner_counter[k] = 0; #endif + tic = getticks(); + engine_prepare( &e , 0 ); + printf( "main: engine_prepare took %.3f ms.\n" , ((double)(getticks() - tic)) / CPU_TPS * 1000 ); fflush(stdout); + tic = getticks(); engine_run( &e , 0 ); #ifdef TIMER printf( "main: runner timers are [ %.3f" , runner_timer[0]/CPU_TPS*1000 ); @@ -921,7 +935,7 @@ int main ( int argc , char *argv[] ) { /* Get the particle with the lowest wcount. */ p = &s.parts[0]; space_map_parts( &s , &map_wcount_min , &p ); - printf( "main: particle %li/%i at [ %e %e %e ] (h=%e) has minimum wcount %.3f (icount=%i).\n" , + printf( "main: particle %lli/%i at [ %e %e %e ] (h=%e) has minimum wcount %.3f (icount=%i).\n" , p->id , (int)(p - s.parts) , p->x[0] , p->x[1] , p->x[2] , p->h , p->wcount + 32.0/3 , p->icount ); /* Loop over all the tasks and dump the ones containing p. */ @@ -960,7 +974,7 @@ int main ( int argc , char *argv[] ) { /* Get the particle with the highest wcount. */ p = &s.parts[0]; space_map_parts( &s , &map_wcount_max , &p ); - printf( "main: particle %li/%i at [ %e %e %e ] (h=%e) has maximum wcount %.3f (icount=%i).\n" , + printf( "main: particle %lli/%i at [ %e %e %e ] (h=%e) has maximum wcount %.3f (icount=%i).\n" , p->id , (int)(p - s.parts) , p->x[0] , p->x[1] , p->x[2] , p->h , p->wcount + 32.0/3 , p->icount ); /* Get the average interactions per particle. */ @@ -969,7 +983,7 @@ int main ( int argc , char *argv[] ) { printf( "main: average neighbours per particle is %.3f.\n" , (double)icount / s.nr_parts ); /* Dump the acceleration of the first particle. */ - printf( "main: parts[%li].a is [ %.16e %.16e %.16e ].\n" , s.parts[6178].id , s.parts[6178].a[0] , s.parts[6178].a[1] , s.parts[6178].a[2] ); + printf( "main: parts[%lli].a is [ %.16e %.16e %.16e ].\n" , s.parts[6178].id , s.parts[6178].a[0] , s.parts[6178].a[1] , s.parts[6178].a[2] ); /* Get all the cells of a certain depth. */ // icount = 1; diff --git a/examples/test_mc.sh b/examples/test_mc.sh index 4c44f77808c109325a1538c87297dc2493cc5cfc..c59b33af70e5dbfe7c53fa39dc9772fcb9ac9da9 100755 --- a/examples/test_mc.sh +++ b/examples/test_mc.sh @@ -23,10 +23,10 @@ do export OMP_THREAD_LIMIT=$cpu export OMP_PROC_BIND=TRUE - ./test -r 1000 -t $cpu -b "1400 1400 1400" -N 74240 -c small/Coordinates.txt.gz -s "700 700 700" -p 0 -h small/SmoothingLength.txt.gz -m 470 -z 200 > small_${cpu}.dump + # ./test -r 1000 -t $cpu -b "1400 1400 1400" -N 74240 -c small/Coordinates.txt.gz -s "700 700 700" -p 0 -h small/SmoothingLength.txt.gz -m 470 -z 200 > small_${cpu}.dump - ./test -r 100 -t $cpu -b "100 100 100" -N 3558892 -c snap_C09/Coordinates.txt.gz -s "50 50 50" -p 0 -h snap_C09/SmoothingLength.txt.gz -m 6.138 > snap_C09_${cpu}.dump + # ./test -r 100 -t $cpu -b "100 100 100" -N 3558892 -c snap_C09/Coordinates.txt.gz -s "50 50 50" -p 0 -h snap_C09/SmoothingLength.txt.gz -m 6.138 > snap_C09_${cpu}.dump - ./test -r 100 -t $cpu -b "6.25 6.25 6.25" -N 1841127 -c scaling/Coordinates.txt.gz -p 1 -h scaling/SmoothingLength.txt.gz -m 0.5 -z 200 > scaling_${cpu}.dump + ./test -r 100 -t $cpu -f scaling/snap_023_z000p503.hdf5 -m 0.5 -z 200 > scaling_${cpu}.dump done