X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0e9c0448c6566825b170b98ecff716b098bda10e..e709643ef0c5b61c6c878016c418bffa2b1b20cd:/teshsuite/smpi/mpich3-test/pt2pt/greq1.c diff --git a/teshsuite/smpi/mpich3-test/pt2pt/greq1.c b/teshsuite/smpi/mpich3-test/pt2pt/greq1.c index 675f072db8..48ee44bb52 100644 --- a/teshsuite/smpi/mpich3-test/pt2pt/greq1.c +++ b/teshsuite/smpi/mpich3-test/pt2pt/greq1.c @@ -13,27 +13,30 @@ static char MTEST_Descrip[] = "Simple test of generalized requests"; */ -int query_fn( void *extra_state, MPI_Status *status ); -int query_fn( void *extra_state, MPI_Status *status ) +int query_fn(void *extra_state, MPI_Status * status); +int query_fn(void *extra_state, MPI_Status * status) { /* Set a default status */ status->MPI_SOURCE = MPI_UNDEFINED; - status->MPI_TAG = MPI_UNDEFINED; - MPI_Status_set_cancelled( status, 0 ); - MPI_Status_set_elements( status, MPI_BYTE, 0 ); + status->MPI_TAG = MPI_UNDEFINED; + MPI_Status_set_cancelled(status, 0); + MPI_Status_set_elements(status, MPI_BYTE, 0); return 0; } -int free_fn( void *extra_state ); -int free_fn( void *extra_state ) + +int free_fn(void *extra_state); +int free_fn(void *extra_state) { - int *b = (int *)extra_state; - if (b) *b = *b - 1; + int *b = (int *) extra_state; + if (b) + *b = *b - 1; /* The value returned by the free function is the error code - returned by the wait/test function */ + * returned by the wait/test function */ return 0; } -int cancel_fn( void *extra_state, int complete ); -int cancel_fn( void *extra_state, int complete ) + +int cancel_fn(void *extra_state, int complete); +int cancel_fn(void *extra_state, int complete) { return 0; } @@ -43,44 +46,44 @@ int cancel_fn( void *extra_state, int complete ) * MPI_Grequest_complete function would be called from another routine, * often running in a separate thread. This simple code allows us to * check that requests can be created, tested, and waited on in the - * case where the request is complete before the wait is called. + * case where the request is complete before the wait is called. * * Note that MPI did *not* define a routine that can be called within - * test or wait to advance the state of a generalized request. + * test or wait to advance the state of a generalized request. * Most uses of generalized requests will need to use a separate thread. */ -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int counter, flag; - MPI_Status status; - MPI_Request request; + MPI_Status status; + MPI_Request request; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Grequest_start( query_fn, free_fn, cancel_fn, NULL, &request ); - - MPI_Test( &request, &flag, &status ); + MPI_Grequest_start(query_fn, free_fn, cancel_fn, NULL, &request); + + MPI_Test(&request, &flag, &status); if (flag) { - errs++; - fprintf( stderr, "Generalized request marked as complete\n" ); + errs++; + fprintf(stderr, "Generalized request marked as complete\n"); } - MPI_Grequest_complete( request ); + MPI_Grequest_complete(request); - MPI_Wait( &request, &status ); + MPI_Wait(&request, &status); counter = 1; - MPI_Grequest_start( query_fn, free_fn, cancel_fn, &counter, &request ); - MPI_Grequest_complete( request ); - MPI_Wait( &request, MPI_STATUS_IGNORE ); - + MPI_Grequest_start(query_fn, free_fn, cancel_fn, &counter, &request); + MPI_Grequest_complete(request); + MPI_Wait(&request, MPI_STATUS_IGNORE); + if (counter) { - errs++; - fprintf( stderr, "Free routine not called, or not called with extra_data" ); + errs++; + fprintf(stderr, "Free routine not called, or not called with extra_data"); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; }