commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9212 - in gnuradio/branches/developers/nldudok1: . gp


From: nldudok1
Subject: [Commit-gnuradio] r9212 - in gnuradio/branches/developers/nldudok1: . gpgpu-wip/gnuradio-core/src/lib/runtime
Date: Fri, 8 Aug 2008 10:05:24 -0600 (MDT)

Author: nldudok1
Date: 2008-08-08 10:05:23 -0600 (Fri, 08 Aug 2008)
New Revision: 9212

Added:
   gnuradio/branches/developers/nldudok1/gpgpu-wip/
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.cc
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.h
Modified:
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/Makefile.am
   
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_buffer.cc
   
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.h
Log:
creating a private branch of trunk for nldudok1 for gpgpu (CUDA) version 
of gnuradio.


Copied: gnuradio/branches/developers/nldudok1/gpgpu-wip (from rev 8902, 
gnuradio/trunk)

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/Makefile.am
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/Makefile.am    2008-07-16 
05:17:40 UTC (rev 8902)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/Makefile.am
   2008-08-08 16:05:23 UTC (rev 9212)
@@ -63,6 +63,7 @@
        gr_vmcircbuf_mmap_tmpfile.cc            \
        gr_vmcircbuf_createfilemapping.cc       \
        gr_vmcircbuf_sysv_shm.cc                \
+       gr_vmcircbuf_noncircular.cc             \
        gr_select_handler.cc                    
 
 libruntime_qa_la_SOURCES =                     \
@@ -117,6 +118,7 @@
        gr_vmcircbuf_mmap_tmpfile.h             \
        gr_vmcircbuf_sysv_shm.h                 \
        gr_vmcircbuf_createfilemapping.h        \
+       gr_vmcircbuf_noncircular.h              \
        qa_gr_block.h                           \
        qa_gr_flowgraph.h                       \
        qa_gr_hier_block2.h                     \

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_buffer.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_buffer.cc   2008-07-16 
05:17:40 UTC (rev 8902)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_buffer.cc
  2008-08-08 16:05:23 UTC (rev 9212)
@@ -175,6 +175,7 @@
 void
 gr_buffer::update_write_pointer (int nitems)
 {
+  d_vmcircbuf->update_circular(d_write_index,nitems);
   d_write_index = index_add (d_write_index, nitems);
 }
 

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc        
2008-07-16 05:17:40 UTC (rev 8902)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
       2008-08-08 16:05:23 UTC (rev 9212)
@@ -36,13 +36,125 @@
 #include <gr_vmcircbuf_sysv_shm.h>
 #include <gr_vmcircbuf_mmap_shm_open.h>
 #include <gr_vmcircbuf_mmap_tmpfile.h>
+#include <gr_vmcircbuf_noncircular.h>
 
 static const char *FACTORY_PREF_KEY = "gr_vmcircbuf_default_factory";
 
 gr_vmcircbuf::~gr_vmcircbuf ()
 {
 }
+void
+gr_vmcircbuf::copy_indexed_internal(unsigned int dst_index,unsigned int 
src_index,unsigned int len)
+{
+  copy_buf_to_buf((void *) (d_base+dst_index),(void *) (d_base+src_index), 
len);
+}
 
+void
+gr_vmcircbuf::copy_indexed_buf_to_mem(void * dst,unsigned int 
src_index,unsigned int len)
+{
+  copy_buf_to_mem( dst, (void *) (d_base+src_index), len);
+}
+
+void
+gr_vmcircbuf::copy_mem_to_indexed_buf(unsigned int dst_index,void * 
src,unsigned int len)
+{
+  copy_mem_to_buf( (void *) (d_base+dst_index), src, len);
+}
+
+void
+gr_vmcircbuf::copy_buf_to_indexed_buf(unsigned int dst_index,void * 
src,unsigned int len)
+{
+  copy_buf_to_buf( (void *) (d_base+dst_index), src, len);
+}
+
+void
+gr_vmcircbuf::copy_indexed_buf_to_buf(void * dst,unsigned int 
src_index,unsigned int len)
+{
+  copy_buf_to_buf(dst, (void *) (d_base+src_index), len);
+}
+
+void
+gr_vmcircbuf::copy_mem_to_mem(void * dst,void * src,unsigned int len)
+{
+  assert(len<=(unsigned int)d_size);
+  void* res=memcpy(dst, src, len);
+  if (res != dst){
+    perror ("gr_vmcircbuf:copy_mem_to_mem memcpy");
+    throw std::runtime_error ("gr_vmcircbuf");
+  }
+}
+
+void
+gr_vmcircbuf::copy_buf_to_buf(void * dst,void * src,unsigned int len)
+{
+  //Default implementation which assumes the buffer lives in system memory
+  copy_mem_to_mem(dst,src,len);
+}
+
+void
+gr_vmcircbuf::copy_buf_to_mem(void * dst,void * src,unsigned int len)
+{
+  //Default implementation which assumes the buffer lives in system memory
+  copy_mem_to_mem(dst,src,len);
+}
+
+void
+gr_vmcircbuf::copy_mem_to_buf(void * dst,void * src,unsigned int len)
+{
+  //Default implementation which assumes the buffer lives in system memory
+  copy_mem_to_mem(dst,src,len);
+}
+
+void
+gr_vmcircbuf::update_circular(unsigned int write_index, int nitems)
+{
+  if(!is_circular())
+  {
+   /*     first copy              second copy
+   * SxxxxxxxxxxxxxxxxxxxE
+   *                a....bc...d
+   * SxxxxxxxxxxxxxxxxxxxExxxxxxxxxxxxxxxxxxxE
+   * c2...d2        a....bc...d         a2..b2
+   *
+   * SxxxxxxxxxxxxxxxxxxxE
+   *       a.........d
+   * SxxxxxxxxxxxxxxxxxxxExxxxxxxxxxxxxxxxxxxE
+   *       a.........d         a2.........d2
+   *
+   * a =write_index
+   * b =d_size-1
+   * c =d_size
+   * d =write_index+nitems-1
+   *
+   * a2=write_index+d_size;
+   * b2=2*d_size-1
+   * c2=0
+   * d2=write_index+nitems-1-d_size
+   */
+
+    int len;
+
+    if(write_index+nitems-1 < (unsigned int)d_size)
+    {
+      //copy ad to a2d2
+      len=nitems;
+      assert(len>0);
+      copy_indexed_internal(write_index+d_size,write_index,len);
+    } else
+    {
+      //copy ab to a2b2
+      //len=1+b-a=1+d_size-1-write_index=d_size-write_index;
+      len=d_size-write_index;
+      assert(len>0);
+      copy_indexed_internal(write_index+d_size,write_index,len);
+      //copy cd to c2d2
+      
len=write_index+nitems-d_size;//1+d-c=1+write_index+nitems-1-d_size=write_index+nitems-d_size
+      assert((len>0) && (len<=d_size));
+      copy_indexed_internal(0,d_size,len);
+    }
+  }//!is_circular()
+}
+
 gr_vmcircbuf_factory::~gr_vmcircbuf_factory ()
 {
 }
@@ -103,6 +215,7 @@
   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 ());
 
   return result;
 }
@@ -125,6 +238,10 @@
   unsigned int *p = (unsigned int *) c->pointer_to_first_copy ();
   for (unsigned int i = 0; i < size / sizeof (int); i++)
     p[i] = counter + i;
+
+  //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);
 }
 
 static bool

Modified: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h 2008-07-16 
05:17:40 UTC (rev 8902)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h
        2008-08-08 16:05:23 UTC (rev 9212)
@@ -33,9 +33,10 @@
  protected:
   int   d_size;
   char *d_base;
+  bool   d_is_circular;
 
   // CREATORS
-  gr_vmcircbuf (int size) : d_size (size), d_base (0) {};
+  gr_vmcircbuf (int size) : d_size (size), d_base (0), d_is_circular(true) {};
 
  public:
   virtual ~gr_vmcircbuf ();
@@ -43,6 +44,159 @@
   // ACCESSORS
   void *pointer_to_first_copy ()  const { return d_base; }
   void *pointer_to_second_copy () const { return d_base + d_size; }
+
+  /*!
+   * \brief return true if this is an actual (mmapped) circular buffer
+   *        return false if this is a non-circular buffer, but circularity 
should be emulated by copying data
+   */
+  virtual bool is_circular ()  const { return d_is_circular; }
+  // MODIFIERS
+
+  /*!
+   * \brief make sure the buffer is circular again after items have been 
written into this buffer.
+   *
+   * \param write_index      from which index was the new data written 
+   * \param nitems           how many new items were written
+   * Run this method every time new items have been written into the buffer.
+   * If this is a non-circular buffer implementation: emulate circularity by 
copying.
+   * If this is an actual double-mmapped circular buffer implementation: do 
nothing.
+   */
+  virtual void update_circular(unsigned int write_index, int nitems);
+
+  /*!
+   * \brief copy buffer memory from one place in this buffer into another 
place in this buffer
+   *
+   * \param dst_index  index of destination. (Which offfset (in bytes) from 
the start of the buffer is used as destination)
+   * \param src_index  index of source       (Which offfset (in bytes) from 
the start of the buffer is used as source)
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But instead of pointers, indexes into 
this buffer are used.
+   * Indexes are byte-offsets from the start of the buffer.
+   * By using indexes (in stead of pointers) it is possible to make buffers in 
external memory 
+   * (on an add-on card for example) which might not be adressable by pointers 
at all.)
+   */
+  virtual void copy_indexed_internal(unsigned int dst_index,unsigned int 
src_index,unsigned int len);
+  /*!
+   * \brief copy memory from this buffer into system memory.
+   *
+   * \param dst                pointer to destination in system memory
+   * \param src_index  index of source in buffer (Which offfset (in bytes) 
from the start of the buffer is used as source)
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But instead using a pointer, as 
source an index into this buffer is used.
+   * Index is a  byte-offset from the start of the buffer.
+   * The destination is a normal pointer to system memory.
+   * By using indexes (in stead of pointers) it is possible to make buffers in 
external memory 
+   * (on an add-on card for example) which might not be adressable by pointers 
at all.)
+   */
+  virtual void copy_indexed_buf_to_mem(void * dst,unsigned int 
src_index,unsigned int len);
+  /*!
+   * \brief copy memory from system memory into this buffer.
+   *
+   * \param dst_index  index of destination in buffer (Which offfset (in 
bytes) from the start of the buffer is used as destination)
+   * \param src                pointer to source in system memory
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But instead using a pointer, as 
destination an index into this buffer is used.
+   * Index is a  byte-offset from the start of the buffer.
+   * The source is a normal pointer to system memory.
+   * By using indexes (in stead of pointers) it is possible to make buffers in 
external memory 
+   * (on an add-on card for example) which might not be adressable by pointers 
at all.)
+   */
+  virtual void copy_mem_to_indexed_buf(unsigned int dst_index, void * 
src,unsigned int len);
+  /*!
+   * \brief copy memory from a similar buffer into this buffer.
+   *
+   * \param dst_index  index of destination in buffer (Which offfset (in 
bytes) from the start of the buffer is used as destination)
+   * \param src                pointer to source in a similar buffer
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But instead using a pointer, as 
destination an index into this buffer is used.
+   * Index is a  byte-offset from the start of the buffer.
+   * The source is a pointer to a memory address of a similar buffer. (same 
buffer-type living on same device)
+   * NOTE: This API is not stabilized yet and might change in the near future. 
Still looking for a way 
+   * of copying between buffers of the same type without using pointers. 
+   * By using indexes (in stead of pointers) it is possible to make buffers in 
external memory 
+   * (on an add-on card for example) which might not be adressable by pointers 
at all.)
+   */
+  virtual void copy_buf_to_indexed_buf(unsigned int dst_index, void * 
src,unsigned int len);
+  /*!
+   * \brief copy memory from this buffer into a similar buffer.
+   *
+   * \param dst                pointer to destination in similar buffer.
+   * \param src_index  index of source in buffer (Which offfset (in bytes) 
from the start of the buffer is used as source)
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But instead using a pointer, as 
source an index into this buffer is used.
+   * Index is a  byte-offset from the start of the buffer.
+   * The destination is a pointer to a memory address of a similar buffer. 
(same buffer-type living on same device)
+   * NOTE: This API is not stabilized yet and might change in the near future. 
Still looking for a way 
+   * of copying between buffers of the same type without using pointers. 
+   * By using indexes (in stead of pointers) it is possible to make buffers in 
external memory 
+   * (on an add-on card for example) which might not be adressable by pointers 
at all.)
+   */
+  virtual void copy_indexed_buf_to_buf(void * dst,unsigned int 
src_index,unsigned int len);
+  /*!
+   * \brief copy memory from system memory into system memory.
+   *
+   * \param dst                pointer to destination in system memory
+   * \param src                pointer to source in system memory
+   * \param len                number of bytes to copy
+   *
+   * This method just a memcpy. 
+   * The destination and source are normal pointers to system memory.
+   * The method is here for the unlikely case the platform this is running on 
doesn't have memcpy, so it can be overridden.
+   */
+  virtual void copy_mem_to_mem(void * dst,void * src,unsigned int len);
+
+  /* Override the following methods if the buffer implementation cannot use 
memcpy
+   * to copy items internally or to or from system memory.
+   * For example when your buffer lives not in main memory but in some 
external device memory
+   * which is not mmapped. For an example see gr_vmcircbuf_noncircular.
+   */
+  /*!
+   * \brief copy buffer memory into another place in this buffer or from one 
buffer to a similar buffer.
+   *
+   * \param dst                pointer to destination in this (or a similar) 
buffer
+   * \param src                pointer to source in this (or a similar) buffer
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But the copies can only happen within 
this buffer
+   * or between buffers of the same type living on the same device
+   * Override this method if you implement a new non-circular buffer-type.
+   */
+  virtual void copy_buf_to_buf(void * dst, void * src,unsigned int len);
+
+  /*!
+   * \brief copy buffer memory to system memory
+   *
+   * \param dst                pointer to destination in system memory
+   * \param src                pointer to source in this (or a similar) buffer
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But the copies can only happen from 
this buffer
+   * to system memory.
+   * This method is needed when the buffer memory is not directly reachable 
because it is not mmapped
+   * or lives for example on external device memory.
+   * Override this method if you implement a new non-circular or an external 
buffer-type.
+   */
+  virtual void copy_buf_to_mem(void * dst, void * src,unsigned int len);
+  /*!
+   * \brief copy buffer memory to system memory
+   *
+   * \param dst                pointer to destination in in this (or a 
similar) buffer
+   * \param src                pointer to source system memory
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But the copies can only happen from 
system memory
+   * to this buffer.
+   * This method is needed when the buffer memory is not directly reachable 
because it is not mmapped
+   * or lives for example on external device memory.
+   * Override this method if you implement a new non-circular or an external 
buffer-type.
+   */
+  virtual void copy_mem_to_buf(void * dst, void * src,unsigned int len);
+
+
 };
 
 /*!

Added: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.cc
===================================================================
--- 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.cc
                           (rev 0)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.cc
   2008-08-08 16:05:23 UTC (rev 9212)
@@ -0,0 +1,164 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <gr_vmcircbuf_noncircular.h>
+#include <stdexcept>
+#include <assert.h>
+#include <unistd.h>
+#include <fcntl.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#include <errno.h>
+#include <stdio.h>
+#include <gr_pagesize.h>
+
+//for malloc
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+//for memcpy
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+
+gr_vmcircbuf_noncircular::gr_vmcircbuf_noncircular (int size)
+  : gr_vmcircbuf (size)
+{
+#if !defined(HAVE_STDLIB_H)
+  fprintf (stderr, "gr_vmcircbuf_noncircular: stdlib.h is not available, so 
malloc is not available.\n");
+  throw std::runtime_error ("gr_vmcircbuf_noncircular");
+#elif !defined(HAVE_STRING_H)
+  fprintf (stderr, "gr_vmcircbuf_noncircular: string.h is not available, so 
memcpy is not available.\n");
+  throw std::runtime_error ("gr_vmcircbuf_noncircular");
+#else
+  d_is_circular=false;
+  //Note the buffer-size must be at least 2*size
+  d_base = (char *)malloc(size*2);
+  if (NULL==d_base){
+    perror ("gr_vmcircbuf_noncircular: malloc");
+    throw std::runtime_error ("gr_vmcircbuf_noncircular");
+  }
+
+  // Now remember the important stuff
+  d_size = size;
+#endif
+}
+
+/*  The copy functions below are just memcpy.
+ *  The parent class gr_vmcircbuf already has these implemented as memcpy.
+ *  They are reimplemented here, so this class can be used as an example or 
template 
+ *  for new non-circular vmcirbuf types which do not use memcpy.
+ *  All the "if defined (HAVE_SOMETHING)" are also here to show that you MUST 
check if the functionality you use
+ *  is available on this system.
+ */
+
+void
+gr_vmcircbuf_noncircular::copy_buf_to_buf(void * dst,void * src,unsigned int 
len)
+{
+  
+#if defined(HAVE_STRING_H) 
+  assert(len<=(unsigned)d_size);
+  void* res=memcpy(dst, src, len);
+  if (res != dst){
+    perror ("gr_vmcircbuf_noncircular::copy_buf_to_buf memcpy");
+    throw std::runtime_error ("gr_vmcircbuf_noncircular");
+  }
+#endif /*HAVE_CUDA_RUNTIME_H*/
+}
+
+void
+gr_vmcircbuf_noncircular::copy_buf_to_mem(void * dst,void * src,unsigned int 
len)
+{
+#if defined(HAVE_STRING_H)
+  assert(len<=(unsigned)d_size);
+  void* res=memcpy(dst, src, len);
+  if (res != dst){
+    perror ("gr_vmcircbuf_noncircular::copy_buf_to_mem memcpy");
+    throw std::runtime_error ("gr_vmcircbuf_noncircular");
+  }
+#endif /*HAVE_STRING_H*/
+}
+
+void
+gr_vmcircbuf_noncircular::copy_mem_to_buf(void * dst,void * src,unsigned int 
len)
+{
+#if defined(HAVE_STRING_H)
+  assert(len<=(unsigned)d_size);
+  void* res=memcpy(dst, src, len);
+  if (res != dst){
+    perror ("gr_vmcircbuf_noncircular::copy_mem_to_buf memcpy");
+    throw std::runtime_error ("gr_vmcircbuf_noncircular");
+  }
+#endif /*HAVE_STRING_H*/
+}
+
+
+
+gr_vmcircbuf_noncircular::~gr_vmcircbuf_noncircular ()
+{
+#if defined(HAVE_STDLIB_H)
+  free(d_base);
+  d_base=NULL;
+  /*if (any_error_condition){
+    perror ("gr_vmcircbuf_noncircular: free");
+  }*/
+#endif /*HAVE_STDLIB_H*/
+}
+
+// ----------------------------------------------------------------
+//                     The factory interface
+// ----------------------------------------------------------------
+
+
+gr_vmcircbuf_factory *gr_vmcircbuf_noncircular_factory::s_the_factory = 0;
+
+gr_vmcircbuf_factory *
+gr_vmcircbuf_noncircular_factory::singleton ()
+{
+  if (s_the_factory)
+    return s_the_factory;
+
+  s_the_factory = new gr_vmcircbuf_noncircular_factory ();
+  return s_the_factory;
+}
+
+int
+gr_vmcircbuf_noncircular_factory::granularity ()
+{
+  return gr_pagesize ();
+}
+
+gr_vmcircbuf *
+gr_vmcircbuf_noncircular_factory::make (int size)
+{
+  try {
+    return new gr_vmcircbuf_noncircular (size);
+  }
+  catch (...){
+    return 0;
+  }
+}


Property changes on: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.h
===================================================================
--- 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.h
                            (rev 0)
+++ 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.h
    2008-08-08 16:05:23 UTC (rev 9212)
@@ -0,0 +1,110 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _GR_VMCIRCBUF_NONCIRCULAR_H_
+#define _GR_VMCIRCBUF_NONCIRCULAR_H_
+
+#include <gr_vmcircbuf.h>
+
+/*!
+ * \brief concrete class to implement emulated circular buffers with CUDA
+ * \ingroup base
+ */
+class gr_vmcircbuf_noncircular : public gr_vmcircbuf {
+ public:
+
+  // CREATORS
+
+  gr_vmcircbuf_noncircular (int size);
+  virtual ~gr_vmcircbuf_noncircular ();
+  // MODIFIERS
+  /*!
+   * \brief copy buffer memory into another place in this buffer or from one 
buffer to a similar buffer.
+   *
+   * \param dst                pointer to destination in this (or a similar) 
buffer
+   * \param src                pointer to source in this (or a similar) buffer
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But the copies can only happen within 
this buffer
+   * or between buffers of the same type living on the same device
+   * Override this method if you implement a new non-circular buffer-type.
+   */
+  virtual void copy_buf_to_buf(void * dst, void * src,unsigned int len);
+
+  /*!
+   * \brief copy buffer memory to system memory
+   *
+   * \param dst                pointer to destination in system memory
+   * \param src                pointer to source in this (or a similar) buffer
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But the copies can only happen from 
this buffer
+   * to system memory.
+   * This method is needed when the buffer memory is not directly reachable 
because it is not mmapped
+   * or lives for example on external device memory.
+   * Override this method if you implement a new non-circular or an external 
buffer-type.
+   */
+  virtual void copy_buf_to_mem(void * dst, void * src,unsigned int len);
+  /*!
+   * \brief copy buffer memory to system memory
+   *
+   * \param dst                pointer to destination in in this (or a 
similar) buffer
+   * \param src                pointer to source system memory
+   * \param len                number of bytes to copy
+   *
+   * This method is a bit like a memcpy. But the copies can only happen from 
system memory
+   * to this buffer.
+   * This method is needed when the buffer memory is not directly reachable 
because it is not mmapped
+   * or lives for example on external device memory.
+   * Override this method if you implement a new non-circular or an external 
buffer-type.
+   */
+  virtual void copy_mem_to_buf(void * dst, void * src,unsigned int len);
+
+};
+
+/*!
+ * \brief concrete factory for circular buffers built using mmap and shm_open
+ */
+class gr_vmcircbuf_noncircular_factory : public gr_vmcircbuf_factory {
+ private:
+  static gr_vmcircbuf_factory  *s_the_factory;
+
+ public:
+  static gr_vmcircbuf_factory *singleton ();
+
+  virtual const char *name () const { return 
"gr_vmcircbuf_noncircular_factory"; }
+
+  /*!
+   * \brief return granularity of mapping, typically equal to page size
+   */
+  virtual int granularity ();
+
+  /*!
+   * \brief return a gr_vmcircbuf, or 0 if unable.
+   *
+   * Call this to create a doubly mapped circular buffer.
+   */
+  virtual gr_vmcircbuf *make (int size);
+
+};
+
+#endif /* _GR_VMCIRCBUF_NONCIRCULAR_H_ */


Property changes on: 
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_noncircular.h
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

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