Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simple example of smpi tracing with platform utilization (with three categories)
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 15 Sep 2010 15:58:29 +0000 (15:58 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 15 Sep 2010 15:58:29 +0000 (15:58 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8193 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/smpi/CMakeLists.txt
examples/smpi/ttest01.c [new file with mode: 0644]

index cd2fa0d..1cac773 100644 (file)
@@ -26,6 +26,7 @@ add_executable(split split.c)
 add_executable(mvmul mvmul.c)
 add_executable(smpi_sendrecv sendrecv.c)
 add_executable(smpi_traced smpi_traced.c)
+add_executable(ttest01 ttest01.c)
 
 target_link_libraries(alltoall2 m simgrid smpi )
 target_link_libraries(alltoall_basic m simgrid smpi )
@@ -45,6 +46,7 @@ target_link_libraries(split m simgrid smpi )
 target_link_libraries(mvmul m simgrid smpi )
 target_link_libraries(smpi_sendrecv m simgrid smpi )
 target_link_libraries(smpi_traced m simgrid smpi )
+target_link_libraries(ttest01 m simgrid smpi )
 
 add_custom_command(TARGET smpi_sendrecv
   POST_BUILD
diff --git a/examples/smpi/ttest01.c b/examples/smpi/ttest01.c
new file mode 100644 (file)
index 0000000..848cfe8
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (c) 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "mpi.h"
+#include <stdio.h>
+#include "instr/instr.h"
+
+#define DATATOSENT 100000000
+
+int main(int argc, char *argv[])
+{
+  MPI_Status status;
+  int rank, numprocs, tag = 0;
+  int *r = malloc(sizeof(int) * DATATOSENT);
+
+  MPI_Init(&argc,&argv);
+  MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+  TRACE_smpi_set_category ("A"); 
+  if (rank == 0){
+    MPI_Send(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD);
+  }else if (rank == 1){
+    MPI_Recv(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
+  }else{ 
+    //do nothing
+  }
+  TRACE_smpi_set_category ("B"); 
+  if (rank == 0){
+    MPI_Recv(r, DATATOSENT, MPI_INT, 1, tag, MPI_COMM_WORLD, &status);
+  }else if (rank == 1){
+    MPI_Send(r, DATATOSENT, MPI_INT, 0, tag, MPI_COMM_WORLD);
+  }else{ 
+    //do nothing
+  }
+  TRACE_smpi_set_category ("C"); 
+  MPI_Barrier (MPI_COMM_WORLD);
+  MPI_Finalize();
+  return 0;
+}