commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9235 - gnuradio/branches/developers/nldudok1/gpgpu-wi


From: nldudok1
Subject: [Commit-gnuradio] r9235 - gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime
Date: Sun, 10 Aug 2008 21:20:39 -0600 (MDT)

Author: nldudok1
Date: 2008-08-10 21:20:39 -0600 (Sun, 10 Aug 2008)
New Revision: 9235

Modified:
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.cc
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc
Log:
made gr_vmcircbuf_cuda come through make check

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
===================================================================
--- 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
       2008-08-11 03:19:12 UTC (rev 9234)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
       2008-08-11 03:20:39 UTC (rev 9235)
@@ -212,13 +212,14 @@
 {
   std::vector<gr_vmcircbuf_factory *> result;
 
+  result.push_back (gr_vmcircbuf_cuda_factory::singleton ());
   result.push_back (gr_vmcircbuf_createfilemapping_factory::singleton ());
   result.push_back (gr_vmcircbuf_sysv_shm_factory::singleton ());
   result.push_back (gr_vmcircbuf_mmap_shm_open_factory::singleton ());
   result.push_back (gr_vmcircbuf_mmap_tmpfile_factory::singleton ());
   result.push_back (gr_vmcircbuf_noncircular_factory::singleton ());
-  result.push_back (gr_vmcircbuf_cuda_factory::singleton ());
 
+
   return result;
 }
 
@@ -237,18 +238,24 @@
 static void
 init_buffer (gr_vmcircbuf *c, int counter, int size)
 {
-  unsigned int *p = (unsigned int *) c->pointer_to_first_copy ();
+  unsigned int *p;
+  if(c->has_no_direct_pointer_access())
+    p = (unsigned int *) malloc(size);
+  else
+    p = (unsigned int *) c->pointer_to_first_copy ();
+
   for (unsigned int i = 0; i < size / sizeof (int); i++)
-  {
-    int value=counter + i;
-    if(c->has_no_direct_pointer_access())
-      c->copy_mem_to_indexed_buf(i*sizeof(int), &value,sizeof(int));
-    else
-      p[i] = value;
-   }
+    p[i] = counter + i;
+
+  if(c->has_no_direct_pointer_access())
+    c->copy_mem_to_indexed_buf(0, p,size);
+
   //If this is a non-circular buffer implementation, emulate a circular buffer 
by copying.
   //If this is a mmapped circular buffer implementation, do nothing.
   c->update_circular(0,size);
+
+  if(c->has_no_direct_pointer_access())
+    free(p);
 }
 
 static bool
@@ -259,35 +266,40 @@
   if (verbose)
     fprintf (stderr, "... %s", msg);
 
-  unsigned int *p1 = (unsigned int *) c->pointer_to_first_copy ();
-  unsigned int *p2 = (unsigned int *) c->pointer_to_second_copy ();
-
+  unsigned int *p1 ;
+  unsigned int *p2 ;
+  if(c->has_no_direct_pointer_access())
+  {
+    p1=(unsigned int *)malloc(size);
+    p2=(unsigned int *)malloc(size);
+    c->copy_indexed_buf_to_mem(p1,        0,size);//first copy
+    c->copy_indexed_buf_to_mem(p2,c->size(),size);//second copy
+  } else
+  {
+    p1 = (unsigned int *) c->pointer_to_first_copy ();
+    p2 = (unsigned int *) c->pointer_to_second_copy ();
+  }
   // fprintf (stderr, "p1 = %p, p2 = %p\n", p1, p2);
 
   for (unsigned int i = 0; i < size / sizeof (int); i++){
-    int value;
-    if(c->has_no_direct_pointer_access())
-      c->copy_indexed_buf_to_mem(&value,i*sizeof(int),sizeof(int));
-    else
-      value=p1[i];
-
-    if (value != counter + i){
+    if (p1[i] != counter + i){
       ok = false;
       if (verbose)
        fprintf (stderr, "  p1[%d] == %u, expected %u\n", i, p1[i], counter + 
i);
       break;
     }
-    if(c->has_no_direct_pointer_access())
-      c->copy_indexed_buf_to_mem(&value,i*sizeof(int)+c->size(),sizeof(int));
-    else
-      value=p2[i];
-    if (value != counter + i){
+    if (p2[i] != counter + i){
       if (verbose)
        fprintf (stderr, "  p2[%d] == %u, expected %u\n", i, p2[i], counter + 
i);
       ok = false;
       break;
     }
   }
+  if(c->has_no_direct_pointer_access())
+  {
+    free(p1);
+    free(p2);
+  }  
 
   if (ok && verbose){
     fprintf (stderr, "  OK\n");

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.cc
===================================================================
--- 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.cc
  2008-08-11 03:19:12 UTC (rev 9234)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.cc
  2008-08-11 03:20:39 UTC (rev 9235)
@@ -111,8 +111,10 @@
 #if defined(HAVE_CUDA_RUNTIME_H)  
   cudaError_t res=cudaFree(d_base);
   if (res !=cudaSuccess){
+    fprintf(stderr,"ERROR: gr_vmcircbuf_cuda: cudaFree didn't return 
cudaSuccess\n");
     perror ("gr_vmcircbuf_cuda: cudaFree");
-  }
+  }// else
+  //fprintf(stderr,"OK: gr_vmcircbuf_cuda: cudaFree returned cudaSuccess\n");
 #endif /*HAVE_CUDA_RUNTIME_H*/
 }
 

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc
===================================================================
--- 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc
    2008-08-11 03:19:12 UTC (rev 9234)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/qa_gr_flowgraph.cc
    2008-08-11 03:20:39 UTC (rev 9235)
@@ -237,7 +237,6 @@
   fg->connect(nop31, 0, nop32, 0);
 
   std::vector<gr_basic_block_vector_t> graphs = fg->partition();
-
   CPPUNIT_ASSERT(graphs.size() == 3);
   CPPUNIT_ASSERT(graphs[0].size() == 4);
   CPPUNIT_ASSERT(graphs[1].size() == 3);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]