put latency test
authorPritish Jetley <pjetley2@illinois.edu>
Mon, 28 Apr 2008 22:03:49 +0000 (22:03 +0000)
committerPritish Jetley <pjetley2@illinois.edu>
Mon, 28 Apr 2008 22:03:49 +0000 (22:03 +0000)
examples/armci/putTest/Makefile [new file with mode: 0644]
examples/armci/putTest/put.c [new file with mode: 0644]

diff --git a/examples/armci/putTest/Makefile b/examples/armci/putTest/Makefile
new file mode 100644 (file)
index 0000000..9ede95b
--- /dev/null
@@ -0,0 +1,12 @@
+CHARMBIN = ../../../bin
+
+all: put
+
+put: put.c
+       $(CHARMBIN)/charmc -o put put.c -language armci -memory os
+
+run: put
+       ./charmrun +p2 ./put
+
+clean:
+       rm -f put charmrun
diff --git a/examples/armci/putTest/put.c b/examples/armci/putTest/put.c
new file mode 100644 (file)
index 0000000..b1fba45
--- /dev/null
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <armci.h>
+#include <charm.h>
+
+#define MAX_PROCESSORS 2
+#define MAX_BUF_SIZE 1048576
+
+int main(int argc, char * argv[]) {
+  void *baseAddress[MAX_PROCESSORS];
+  char *local;
+  int thisImage;
+
+  int iter = 1000, size;
+  double startTime, endTime;
+  int i;
+
+  // initialize
+  ARMCI_Init();
+  ARMCI_Myid(&thisImage);
+
+  // allocate data (collective operation)
+  ARMCI_Malloc(baseAddress, MAX_BUF_SIZE*sizeof(char));
+  local = (char *)ARMCI_Malloc_local(MAX_BUF_SIZE*sizeof(char));
+
+  ARMCI_Barrier();
+   
+  if (thisImage == 0) {
+    for(size = 1; size <= MAX_BUF_SIZE; size = size<<1){
+      startTime = CkWallTimer();
+      for(i = 0; i < iter; i++){
+        ARMCI_Put(local, baseAddress[1], size, 1);
+      }
+      ARMCI_Fence(1);
+      endTime = CkWallTimer();
+      printf("%d: %f us\n", size, (endTime-startTime)*1000);
+    }
+    ARMCI_Barrier();
+  } else if (thisImage == 1) {
+    ARMCI_Barrier();
+  }
+
+
+  ARMCI_Free(baseAddress[thisImage]);
+  ARMCI_Free_local(local);
+  // finalize
+  ARMCI_Finalize();
+  return 0;
+}