瀏覽代碼

mpi testcases: Avoid negation

Nathalie Furmento 14 年之前
父節點
當前提交
dd2cd2988a
共有 3 個文件被更改,包括 30 次插入33 次删除
  1. 9 11
      mpi/tests/ring.c
  2. 12 14
      mpi/tests/ring_async.c
  3. 9 8
      mpi/tests/ring_async_implicit.c

+ 9 - 11
mpi/tests/ring.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -88,29 +88,27 @@ int main(int argc, char **argv)
 	{
 		int tag = loop*size + rank;
 
-		if (!((loop == 0) && (rank == 0)))
+		if (loop == 0 && rank == 0)
 		{
 			token = 0;
-			MPI_Status status;
-			starpu_mpi_recv(token_handle, (rank+size-1)%size, tag, MPI_COMM_WORLD, &status);
+			fprintf(stdout, "Start with token value %d\n", token);
 		}
 		else {
-			token = 0;
-			fprintf(stdout, "Start with token value %d\n", token);
+			MPI_Status status;
+			starpu_mpi_recv(token_handle, (rank+size-1)%size, tag, MPI_COMM_WORLD, &status);
 		}
 
 		increment_token();
 		
-		if (!((loop == last_loop) && (rank == last_rank)))
+		if (loop == last_loop && rank == last_rank)
 		{
-			starpu_mpi_send(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD);
-		}
-		else {
-
 			starpu_data_acquire(token_handle, STARPU_R);
 			fprintf(stdout, "Finished : token value %d\n", token);
 			starpu_data_release(token_handle);
 		}
+		else {
+			starpu_mpi_send(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD);
+		}
 	}
 
 	starpu_mpi_shutdown();

+ 12 - 14
mpi/tests/ring_async.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -88,34 +88,32 @@ int main(int argc, char **argv)
 	{
 		int tag = loop*size + rank;
 
-		if (!((loop == 0) && (rank == 0)))
+		if (loop == 0 && rank == 0)
 		{
 			token = 0;
+			fprintf(stdout, "Start with token value %d\n", token);
+		}
+		else {
 			MPI_Status status;
 			starpu_mpi_req req;
 			starpu_mpi_irecv(token_handle, &req, (rank+size-1)%size, tag, MPI_COMM_WORLD);
 			starpu_mpi_wait(&req, &status);
 		}
-		else {
-			token = 0;
-			fprintf(stdout, "Start with token value %d\n", token);
-		}
 
 		increment_token();
-		
-		if (!((loop == last_loop) && (rank == last_rank)))
+
+		if (loop == last_loop && rank == last_rank)
 		{
+			starpu_data_acquire(token_handle, STARPU_R);
+			fprintf(stdout, "Finished : token value %d\n", token);
+			starpu_data_release(token_handle);
+		}
+		else {
 			starpu_mpi_req req;
 			MPI_Status status;
 			starpu_mpi_isend(token_handle, &req, (rank+1)%size, tag+1, MPI_COMM_WORLD);
 			starpu_mpi_wait(&req, &status);
 		}
-		else {
-
-			starpu_data_acquire(token_handle, STARPU_R);
-			fprintf(stdout, "Finished : token value %d\n", token);
-			starpu_data_release(token_handle);
-		}
 	}
 
 	starpu_mpi_shutdown();

+ 9 - 8
mpi/tests/ring_async_implicit.c

@@ -87,26 +87,27 @@ int main(int argc, char **argv)
 	{
 		int tag = loop*size + rank;
 
-		if (!((loop == 0) && (rank == 0)))
+		if (loop == 0 && rank == 0)
 		{
-			starpu_mpi_irecv_detached(token_handle, (rank+size-1)%size, tag, MPI_COMM_WORLD, NULL, NULL);
-		}
-		else {
 			token = 0;
 			fprintf(stdout, "Start with token value %d\n", token);
 		}
+		else
+		{
+			starpu_mpi_irecv_detached(token_handle, (rank+size-1)%size, tag, MPI_COMM_WORLD, NULL, NULL);
+		}
 
 		increment_token();
 
-		if (!((loop == last_loop) && (rank == last_rank)))
+		if (loop == last_loop && rank == last_rank)
 		{
-			starpu_mpi_isend_detached(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD, NULL, NULL);
-		}
-		else {
 			starpu_data_acquire(token_handle, STARPU_R);
 			fprintf(stdout, "Finished : token value %d\n", token);
 			starpu_data_release(token_handle);
 		}
+		else {
+			starpu_mpi_isend_detached(token_handle, (rank+1)%size, tag+1, MPI_COMM_WORLD, NULL, NULL);
+		}
 	}
 
 	starpu_task_wait_for_all();