X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b0ab0c5a91c78404c76b02acf058c7a762934c74..79affec61e2c9af35fc9d5c5f34c977dde041283:/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c diff --git a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c index 62afcde78a..dcaf7e6131 100644 --- a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c +++ b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c @@ -1,6 +1,6 @@ -/* A simple example pingpong pogram to test MPI_Send and MPI_Recv */ +/* A simple example ping-pong program to test MPI_Send and MPI_Recv */ -/* Copyright (c) 2009-2010, 2012-2014. The SimGrid Team. +/* Copyright (c) 2009-2019. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -9,16 +9,32 @@ #include #include +static void test_opts(int* argc, char **argv[]){ + int found = 0; + int ret; + while ((ret = getopt(*argc, *argv, "s")) >= 0) + { + if (ret == 's') + found = 1; + } + if (found!=1){ + printf("(smpi_)getopt failed ! \n"); + } +} + int main(int argc, char *argv[]) { - const int tag1 = 42, tag2 = 43; /* Message tag */ - int rank, size; + const int tag1 = 42; + const int tag2 = 43; /* Message tag */ + int size; + int rank; int msg = 99; - int err; - int pivot; MPI_Status status; + int err = MPI_Init(&argc, &argv); /* Initialize MPI */ + + /* test getopt function */ + test_opts(&argc, &argv); - err = MPI_Init(&argc, &argv); /* Initialize MPI */ if (err != MPI_SUCCESS) { printf("MPI initialization failed!\n"); exit(1); @@ -34,8 +50,8 @@ int main(int argc, char *argv[]) printf("\n *** Ping-pong test (MPI_Send/MPI_Recv) ***\n\n"); } - /* start pingpong tests between several pairs */ - for (pivot = 0; pivot < size - 1; pivot++) { + /* start ping-pong tests between several pairs */ + for (int pivot = 0; pivot < size - 1; pivot++) { if (pivot == rank) { printf("\n== pivot=%d : pingpong [%d] <--> [%d]\n", pivot, pivot, pivot + 1);