AMPI/GPU: simple test code
authorPhil Miller <mille121@illinois.edu>
Mon, 10 May 2010 22:41:31 +0000 (17:41 -0500)
committerPhil Miller <mille121@illinois.edu>
Tue, 11 May 2010 19:18:36 +0000 (14:18 -0500)
examples/ampi/cuda/simple/.gitignore [new file with mode: 0644]
examples/ampi/cuda/simple/Makefile [new file with mode: 0644]
examples/ampi/cuda/simple/simple-cuda.cu [new file with mode: 0644]
examples/ampi/cuda/simple/simple.c [new file with mode: 0644]

diff --git a/examples/ampi/cuda/simple/.gitignore b/examples/ampi/cuda/simple/.gitignore
new file mode 100644 (file)
index 0000000..ab23474
--- /dev/null
@@ -0,0 +1 @@
+simple
diff --git a/examples/ampi/cuda/simple/Makefile b/examples/ampi/cuda/simple/Makefile
new file mode 100644 (file)
index 0000000..6990f14
--- /dev/null
@@ -0,0 +1,26 @@
+# Ensure that CUDA_DIR, NVIDIA_CUDA_SDK, and LD_LIBRARY_PATH are set
+# in your environment. For the tests to work right, those settings
+# need to be in a login script.
+
+NVCC=$(CUDA_DIR)/bin/nvcc
+CHARMDIR=../../../..
+AMPICC=$(CHARMDIR)/bin/ampicc
+
+CC=$(AMPICC)
+LD=$(AMPICC)
+CFLAGS=$(OPTS)
+LDFLAGS=$(OPTS)
+
+simple: simple-cuda.o
+
+simple-cuda.o: simple-cuda.cu
+       $(NVCC) $(OPTS) -I $(CHARMDIR)/include -c simple-cuda.cu
+
+test:
+       ./simple +vp 1
+       ./simple +vp 2
+       ./simple +vp 16
+       ./charmrun +p2 ./simple +vp 16
+
+clean:
+       rm -f charmrun simple *.o
diff --git a/examples/ampi/cuda/simple/simple-cuda.cu b/examples/ampi/cuda/simple/simple-cuda.cu
new file mode 100644 (file)
index 0000000..b29323a
--- /dev/null
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "wr.h"
+
+extern workRequestQueue* wrQueue;
+
+__global__ void helloKernel() {
+
+}
+
+extern "C"
+void *kernelSetup() {
+  workRequest *wr = new workRequest;
+  wr = (workRequest*) malloc(sizeof(workRequest));
+
+  wr->dimGrid.x = 1;
+  wr->dimBlock.x = 1;
+  wr->smemSize = 0;
+  wr->id = 0;
+  wr->nBuffers = 0;
+  wr->bufferInfo = NULL;
+
+  return wr;
+}
+
+void kernelSelect(workRequest *wr) {
+  printf("inside kernelSelect\n");
+  switch (wr->id) {
+  case 0:
+    printf("calling kernel\n");
+    helloKernel<<<wr->dimGrid,wr->dimBlock,wr->smemSize>>>();
+    break;
+  default:
+    printf("error: id %d not valid\n", wr->id);
+    break;
+  }
+}
diff --git a/examples/ampi/cuda/simple/simple.c b/examples/ampi/cuda/simple/simple.c
new file mode 100644 (file)
index 0000000..b37c6c4
--- /dev/null
@@ -0,0 +1,16 @@
+#include "ampi.h"
+
+void *kernelSetup();
+
+int main(int argc, char **argv)
+{
+    MPI_Init(&argc, &argv);
+    MPI_Request req;
+    MPI_Status sts;
+    void *wr = kernelSetup();
+    AMPI_GPU_invoke(wr, &req, MPI_COMM_WORLD);
+    MPI_Wait(&req, &sts);
+
+    MPI_Finalize();
+    return 0;
+}