Changed the hello example to use the new callback interface.
authorLukasz Wesolowski <wesolwsk@illinois.edu>
Wed, 23 Jul 2008 20:48:20 +0000 (20:48 +0000)
committerLukasz Wesolowski <wesolwsk@illinois.edu>
Wed, 23 Jul 2008 20:48:20 +0000 (20:48 +0000)
examples/charm++/cuda/hello/Makefile
examples/charm++/cuda/hello/hello.C
examples/charm++/cuda/hello/helloCUDA.cu

index 5f440147583adf9390b2948bf84ab9c386c748b6..071e8dd0d476c35b6c5c8440b29af50a23cf0749 100644 (file)
@@ -2,11 +2,11 @@ CHARMC=../../../../bin/charmc $(OPTS)
 
 OBJS = hello.o helloCUDA.o
 
-NVCC = /usr/local/cuda/bin/nvcc
+NVCC = /usr/local/cuda/bin/nvcc 
 NVCC_FLAGS = -c -use_fast_math #-device-debug -deviceemu 
 NVCC_INC = -I/usr/local/cuda/include -I../../../../../NVIDIA_CUDA_SDK/common/inc
 
-LDLIBS += -lcuda -lcudart -lGL -lGLU -lcutil
+LD_LIBS += -lcuda -lcudart -lGL -lGLU -lcutil
 
 export LD_RUN_PATH = /usr/local/cuda/lib
 
index 60552ceb0586b013ec9eb446525cdd35a35855f5..0e044eea235cd9022b3deecd9ed508aaada97de8 100644 (file)
@@ -5,15 +5,7 @@
 /*readonly*/ int nElements;
 /*readonly*/ CProxy_Hello arr; 
 
-int currentIndex; 
-
-extern void kernelSetup(); 
-
-void kernelReturn() {
-  printf("Kernel returned\n"); 
-  arr[currentIndex].SendHi(); 
-  //  sendHi(); 
-}
+extern void kernelSetup(void *cb); 
 
 /*mainchare*/
 class Main : public CBase_Main
@@ -33,8 +25,6 @@ public:
 
     arr = CProxy_Hello::ckNew(nElements);
 
-    currentIndex = 0; 
-
     arr[0].SayHi();
   };
 
@@ -58,10 +48,13 @@ public:
 
   void SayHi()
   {
-    currentIndex = thisIndex; 
+    CkArrayIndex1D myIndex = CkArrayIndex1D(thisIndex); 
+    CkCallback *cb; 
+    cb = new CkCallback(CkIndex_Hello::SendHi(), myIndex, thisArrayID); 
+
     CkPrintf("Hi from element %d\n", thisIndex);
     if (thisIndex < nElements-1)
-      kernelSetup(); 
+      kernelSetup((void *) cb); 
     else 
       //We've been around once-- we're done.
       mainProxy.done();
@@ -69,7 +62,7 @@ public:
 
   void SendHi() {
     //Pass the hello on:
-    CkPrintf("Executing sendHi\n"); 
+    CkPrintf("Sending a Hi Message\n"); 
     thisProxy[thisIndex+1].SayHi();
   }
 
index 895d90f9937d193e652312a5fbf3a5561d435f27..69a15784366f1740ab7d522618c2b6a75d8cea7b 100644 (file)
@@ -3,13 +3,12 @@
 #include "wr.h"
 
 extern workRequestQueue* wrQueue; 
-extern void kernelReturn(); 
 
 __global__ void helloKernel() { 
 
 }
 
-void kernelSetup() {
+void kernelSetup(void *cb) {
   workRequest *wr; 
   wr = (workRequest*) malloc(sizeof(workRequest)); 
 
@@ -29,7 +28,7 @@ void kernelSetup() {
   wr->writeOnlyHostPtr = NULL;
   wr->writeOnlyLen = 0; 
 
-  wr->callbackFn = kernelReturn
+  wr->callbackFn = cb
 
   wr->id = 0;