void initAtoD(void) // initialize A/D { ADCON1 = 0b00000100 // RA0, RA1, RA3 analog inputs ADCON0 = 0b01000001 // select 8* oscillator, analog input 0, turn on SetupDelay(); // small delay ADGO = 1; // Start A/D }
int main( int argc, char *argv[] ) { double usecPerCall = 100; double t, t1, tsum; int i, nLoop = 100; int rank; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); /* Process arguments. We allow the delay count to be set from the command line to ensure reproducibility*/ for (i=1; i<argc; i++) { if (strcmp( argv[i], "-delaycount" ) == 0) { i++; lCount = atoi( argv[i] ); } else if (strcmp( argv[i], "-v" ) == 0) { verbose = 1; } else { fprintf( stderr, "Unrecognized argument %s\n", argv[i] ); exit(1); } } if (lCount == 0) { SetupDelay( usecPerCall ); } MPI_Barrier( MPI_COMM_WORLD ); t = MPI_Wtime(); for (i=0; i<nLoop; i++) { MPI_Allreduce( &t1, &tsum, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD ); Delay( lCount ); } t = MPI_Wtime() - t; MPI_Barrier( MPI_COMM_WORLD ); if (rank == 0) { printf( "For delay count %d, time is %e\n", lCount, t ); } MPI_Barrier( MPI_COMM_WORLD ); MPI_Finalize(); return 0; }