Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
made some changes to allow more than one DO_ONCE block. also fixed bug in
[simgrid.git] / src / smpi / sample / compute3.c
diff --git a/src/smpi/sample/compute3.c b/src/smpi/sample/compute3.c
new file mode 100644 (file)
index 0000000..e2fe6ba
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+       int i;
+       double d;
+       MPI_Init(&argc, &argv);
+       d = 2.0;
+       DO_ONCE {
+               for (i = 0; i < atoi(argv[1]); i++) {
+                       if (d < 10000) {
+                               d = d*d;
+                       } else {
+                               d = 2;
+                       }
+               }
+               printf("%d %f\n", i, d);
+       }
+       DO_ONCE {
+               for (i = 0; i < 2*atoi(argv[1]); i++) {
+                       if (d < 10000) {
+                               d = d*d;
+                       } else {
+                               d = 2;
+                       }
+               }
+               printf("%d %f\n", i, d);
+       }
+       MPI_Finalize();
+       return 0;
+}