[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9233 - gnuradio/branches/developers/nldudok1/gpgpu-wi
From: |
nldudok1 |
Subject: |
[Commit-gnuradio] r9233 - gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime |
Date: |
Sun, 10 Aug 2008 18:47:01 -0600 (MDT) |
Author: nldudok1
Date: 2008-08-10 18:46:59 -0600 (Sun, 10 Aug 2008)
New Revision: 9233
Added:
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.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_flat_flowgraph.cc
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.cc
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.h
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.i
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:
add gr_vmcircbuf_cuda
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/Makefile.am
2008-08-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/Makefile.am
2008-08-11 00:46:59 UTC (rev 9233)
@@ -21,12 +21,13 @@
include $(top_srcdir)/Makefile.common
-AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
+AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES)
$(CUDA_CFLAGS)
noinst_LTLIBRARIES = libruntime.la libruntime-qa.la
libruntime_la_LIBADD = \
- $(SHM_OPEN_LIBS)
+ $(SHM_OPEN_LIBS) \
+ $(CUDA_LIBS)
libruntime_la_SOURCES = \
@@ -64,6 +65,7 @@
gr_vmcircbuf_createfilemapping.cc \
gr_vmcircbuf_sysv_shm.cc \
gr_vmcircbuf_noncircular.cc \
+ gr_vmcircbuf_cuda.cc \
gr_select_handler.cc
libruntime_qa_la_SOURCES = \
@@ -119,6 +121,7 @@
gr_vmcircbuf_sysv_shm.h \
gr_vmcircbuf_createfilemapping.h \
gr_vmcircbuf_noncircular.h \
+ gr_vmcircbuf_cuda.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_flat_flowgraph.cc
===================================================================
---
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
2008-08-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
2008-08-11 00:46:59 UTC (rev 9233)
@@ -109,7 +109,20 @@
nitems = std::max(nitems,
static_cast<int>(2*(decimation*multiple+history)));
}
- return gr_make_buffer(nitems, item_size);
+ if( GR_BUFFER_DEFAULT==block->output_signature()->buffer_type())
+ return gr_make_buffer(nitems, item_size);
+ else if(
GR_BUFFER_EXTERNAL_BLOCK_HAS_ITS_OWN_FACTORY==block->output_signature()->buffer_type())
+ {
+ gr_buffer_sptr ext_buffer;
+ //gr_buffer_sptr ext_buffer=grblock->make_buffer(nitems, item_size);//TODO
implement grblock->make_buffer
+ //if (!ext_buffer)
+ throw std::runtime_error("allocate_buffer make_buffer() not implemented
for this block");
+ return ext_buffer;
+ } else
+ {
+ throw std::runtime_error("allocate_buffer block->output_signature() has
illegal buffer_type");
+ //return 0;
+ }
}
void
Modified:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.cc
===================================================================
---
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.cc
2008-08-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.cc
2008-08-11 00:46:59 UTC (rev 9233)
@@ -29,50 +29,51 @@
gr_io_signature_sptr
gr_make_io_signaturev(int min_streams, int max_streams,
- const std::vector<int> &sizeof_stream_items)
+ const std::vector<int> &sizeof_stream_items,
gr_buffer_type buffer_type)
{
return gr_io_signature_sptr (new gr_io_signature (min_streams, max_streams,
- sizeof_stream_items));
+ sizeof_stream_items,
buffer_type));
}
gr_io_signature_sptr
gr_make_io_signature(int min_streams, int max_streams,
- int sizeof_stream_item)
+ int sizeof_stream_item, gr_buffer_type buffer_type)
{
std::vector<int> sizeof_items(1);
sizeof_items[0] = sizeof_stream_item;
- return gr_make_io_signaturev(min_streams, max_streams, sizeof_items);
+ return gr_make_io_signaturev(min_streams, max_streams, sizeof_items,
buffer_type);
}
gr_io_signature_sptr
gr_make_io_signature2(int min_streams, int max_streams,
int sizeof_stream_item1,
- int sizeof_stream_item2)
+ int sizeof_stream_item2, gr_buffer_type buffer_type)
{
std::vector<int> sizeof_items(2);
sizeof_items[0] = sizeof_stream_item1;
sizeof_items[1] = sizeof_stream_item2;
- return gr_make_io_signaturev(min_streams, max_streams, sizeof_items);
+ return gr_make_io_signaturev(min_streams, max_streams, sizeof_items,
buffer_type);
}
gr_io_signature_sptr
gr_make_io_signature3(int min_streams, int max_streams,
int sizeof_stream_item1,
int sizeof_stream_item2,
- int sizeof_stream_item3)
+ int sizeof_stream_item3, gr_buffer_type buffer_type)
{
std::vector<int> sizeof_items(3);
sizeof_items[0] = sizeof_stream_item1;
sizeof_items[1] = sizeof_stream_item2;
sizeof_items[2] = sizeof_stream_item3;
- return gr_make_io_signaturev(min_streams, max_streams, sizeof_items);
+ return gr_make_io_signaturev(min_streams, max_streams, sizeof_items,
buffer_type);
}
// ------------------------------------------------------------------------
gr_io_signature::gr_io_signature (int min_streams, int max_streams,
- const std::vector<int> &sizeof_stream_items)
+ const std::vector<int> &sizeof_stream_items,
+ gr_buffer_type buffer_type)
{
if (min_streams < 0
|| (max_streams != IO_INFINITE && max_streams < min_streams))
@@ -89,6 +90,7 @@
d_min_streams = min_streams;
d_max_streams = max_streams;
d_sizeof_stream_item = sizeof_stream_items;
+ d_buffer_type = buffer_type;
}
gr_io_signature::~gr_io_signature ()
@@ -110,3 +112,4 @@
{
return d_sizeof_stream_item;
}
+
Modified:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.h
===================================================================
---
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.h
2008-08-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.h
2008-08-11 00:46:59 UTC (rev 9233)
@@ -25,6 +25,13 @@
#include <gr_runtime_types.h>
+ enum gr_buffer_type {
+ GR_BUFFER_DEFAULT = 0, // default buffer = circular buffer
in memory of host processor
+ // created by
gr_vmcircbuf_sysconfig->get_default_factory()
+ GR_BUFFER_EXTERNAL_BLOCK_HAS_ITS_OWN_FACTORY = 1, // block creates its
own buffer by block_instance->get_buffer_factory()
+ // This memory might not be
in host main memory, so no direct copies
+ // or pointer dereferencing
allowed.
+ };
/*!
* \brief Create an i/o signature
*
@@ -35,7 +42,7 @@
*/
gr_io_signature_sptr
gr_make_io_signature(int min_streams, int max_streams,
- int sizeof_stream_item);
+ int sizeof_stream_item,gr_buffer_type
buffer_type=GR_BUFFER_DEFAULT);
/*!
* \brief Create an i/o signature
@@ -48,7 +55,8 @@
gr_io_signature_sptr
gr_make_io_signature2(int min_streams, int max_streams,
int sizeof_stream_item1,
- int sizeof_stream_item2
+ int sizeof_stream_item2,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT
);
/*!
@@ -64,7 +72,8 @@
gr_make_io_signature3(int min_streams, int max_streams,
int sizeof_stream_item1,
int sizeof_stream_item2,
- int sizeof_stream_item3
+ int sizeof_stream_item3,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT
);
/*!
@@ -78,29 +87,34 @@
* value of the last entry in sizeof_stream_items is used for the missing
values.
* sizeof_stream_items must contain at least 1 entry.
*/
+
+
gr_io_signature_sptr
gr_make_io_signaturev(int min_streams, int max_streams,
- const std::vector<int> &sizeof_stream_items);
+ const std::vector<int> &sizeof_stream_items,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT
+ );
/*!
* \brief i/o signature for input and output ports.
*/
class gr_io_signature {
+
int d_min_streams;
int d_max_streams;
std::vector<int> d_sizeof_stream_item;
+ gr_buffer_type d_buffer_type;
gr_io_signature(int min_streams, int max_streams,
- const std::vector<int> &sizeof_stream_items);
+ const std::vector<int> &sizeof_stream_items, gr_buffer_type
buffer_type=GR_BUFFER_DEFAULT);
friend gr_io_signature_sptr
gr_make_io_signaturev(int min_streams,
int max_streams,
- const std::vector<int> &sizeof_stream_item);
+ const std::vector<int> &sizeof_stream_item,
gr_buffer_type buffer_type);
public:
-
static const int IO_INFINITE = -1;
~gr_io_signature ();
@@ -109,6 +123,7 @@
int max_streams () const { return d_max_streams; }
int sizeof_stream_item (int index) const;
std::vector<int> sizeof_stream_items() const;
+ gr_buffer_type buffer_type() const { return d_buffer_type; }
};
Modified:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.i
===================================================================
---
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.i
2008-08-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_io_signature.i
2008-08-11 00:46:59 UTC (rev 9233)
@@ -29,34 +29,47 @@
%rename(io_signature3) gr_make_io_signature3;
%rename(io_signaturev) gr_make_io_signaturev;
+ enum gr_buffer_type {
+ GR_BUFFER_DEFAULT = 0, // default buffer = circular buffer
in memory of host processor
+ // created by
gr_vmcircbuf_sysconfig->get_default_factory()
+ GR_BUFFER_EXTERNAL_BLOCK_HAS_ITS_OWN_FACTORY = 1, // block creates its
own buffer by block_instance->get_buffer_factory()
+ // This memory might not be
in host main memory, so no direct copies
+ // or pointer dereferencing
allowed.
+ };
gr_io_signature_sptr
gr_make_io_signature(int min_streams, int max_streams,
- int sizeof_stream_item);
+ int sizeof_stream_item,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT);
gr_io_signature_sptr
gr_make_io_signature2(int min_streams, int max_streams,
int sizeof_stream_item1,
- int sizeof_stream_item2
+ int sizeof_stream_item2,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT
);
gr_io_signature_sptr
gr_make_io_signature3(int min_streams, int max_streams,
int sizeof_stream_item1,
int sizeof_stream_item2,
- int sizeof_stream_item3
+ int sizeof_stream_item3,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT
);
gr_io_signature_sptr
gr_make_io_signaturev(int min_streams, int max_streams,
- const std::vector<int> &sizeof_stream_items);
+ const std::vector<int> &sizeof_stream_items,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT);
class gr_io_signature {
- gr_io_signature (int min_streams, int max_streams, int sizeof_stream_item);
+ gr_io_signature (int min_streams, int max_streams, int sizeof_stream_item,
+ gr_buffer_type buffer_type=GR_BUFFER_DEFAULT);
friend gr_io_signature_sptr
gr_make_io_signaturev(int min_streams,
int max_streams,
- const std::vector<int> &sizeof_stream_item);
+ const std::vector<int> &sizeof_stream_item,
+ gr_buffer_type buffer_type);
public:
@@ -69,5 +82,6 @@
int max_streams () const { return d_max_streams; }
int sizeof_stream_item (int index) const;
std::vector<int> sizeof_stream_items() const;
+ gr_buffer_type buffer_type() const { return d_buffer_type; }
};
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-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.cc
2008-08-11 00:46:59 UTC (rev 9233)
@@ -37,6 +37,7 @@
#include <gr_vmcircbuf_mmap_shm_open.h>
#include <gr_vmcircbuf_mmap_tmpfile.h>
#include <gr_vmcircbuf_noncircular.h>
+#include <gr_vmcircbuf_cuda.h>
static const char *FACTORY_PREF_KEY = "gr_vmcircbuf_default_factory";
@@ -216,6 +217,7 @@
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,8 +239,13 @@
{
unsigned int *p = (unsigned int *) c->pointer_to_first_copy ();
for (unsigned int i = 0; i < size / sizeof (int); i++)
- p[i] = counter + 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;
+ }
//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);
@@ -258,13 +265,23 @@
// fprintf (stderr, "p1 = %p, p2 = %p\n", p1, p2);
for (unsigned int i = 0; i < size / sizeof (int); i++){
- if (p1[i] != counter + 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){
ok = false;
if (verbose)
fprintf (stderr, " p1[%d] == %u, expected %u\n", i, p1[i], counter +
i);
break;
}
- if (p2[i] != counter + i){
+ 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 (verbose)
fprintf (stderr, " p2[%d] == %u, expected %u\n", i, p2[i], counter +
i);
ok = false;
Modified:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h
===================================================================
---
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h
2008-08-10 23:32:12 UTC (rev 9232)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf.h
2008-08-11 00:46:59 UTC (rev 9233)
@@ -34,9 +34,10 @@
int d_size;
char *d_base;
bool d_is_circular;
+ bool d_no_direct_pointer_access;
// CREATORS
- gr_vmcircbuf (int size) : d_size (size), d_base (0), d_is_circular(true) {};
+ gr_vmcircbuf (int size) : d_size (size), d_base (0),
d_is_circular(true),d_no_direct_pointer_access(false) {};
public:
virtual ~gr_vmcircbuf ();
@@ -44,12 +45,22 @@
// ACCESSORS
void *pointer_to_first_copy () const { return d_base; }
void *pointer_to_second_copy () const { return d_base + d_size; }
+ /*!
+ * \brief return the buffer size in bytes
+ */
+ virtual int size() const { return 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; }
+ /*!
+ * \brief return true if you cannot access the buffer memory directly using
a pointer.
+ * return false if you can access this buffer with a pointer like
normal memory.
+ * If this returns true you can only access the buffer using the copy
routines.
+ */
+ virtual bool has_no_direct_pointer_access() const { return
d_no_direct_pointer_access; }
// MODIFIERS
/*!
Added:
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
(rev 0)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.cc
2008-08-11 00:46:59 UTC (rev 9233)
@@ -0,0 +1,151 @@
+/* -*- 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_cuda.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>
+
+#ifdef HAVE_CUDA_RUNTIME_H
+#include <cuda_runtime.h>
+#endif
+#ifdef HAVE_CUTIL_H
+#include <cutil.h>
+#endif
+
+gr_vmcircbuf_cuda::gr_vmcircbuf_cuda (int size)
+ : gr_vmcircbuf (size)
+{
+#if !defined(HAVE_CUDA_RUNTIME_H)
+ fprintf (stderr, "gr_vmcircbuf_cuda: CUDA is not available\n");
+ throw std::runtime_error ("gr_vmcircbuf_cuda");
+#else
+ d_is_circular=false;
+ d_no_direct_pointer_access=true;
+ cudaError_t res=cudaMalloc( (void**) &(d_base),size*2 );
+ //CUDA_SAFE_CALL( cudaMalloc( (void**) &(d_base),size ));
+
+ if (res != cudaSuccess){
+ d_base=NULL; // cleanup
+ perror ("gr_vmcircbuf_cuda: cudaMalloc");
+ throw std::runtime_error ("gr_vmcircbuf_cuda");
+ }
+
+ // Now remember the important stuff
+ d_size = size;
+#endif
+}
+
+void
+gr_vmcircbuf_cuda::copy_buf_to_buf(void * dst,void * src,unsigned int len)
+{
+#if defined(HAVE_CUDA_RUNTIME_H)
+ assert(len<=d_size);
+ cudaError_t res=cudaMemcpy(dst, src, len, cudaMemcpyDeviceToDevice);
+ if (res != cudaSuccess){
+ perror ("gr_vmcircbuf_cuda:copy_buf_to_buf cudaMemcpy");
+ throw std::runtime_error ("gr_vmcircbuf_cuda");
+ }
+#endif /*HAVE_CUDA_RUNTIME_H*/
+}
+
+void
+gr_vmcircbuf_cuda::copy_buf_to_mem(void * dst,void * src,unsigned int len)
+{
+#if defined(HAVE_CUDA_RUNTIME_H)
+ assert(len<=d_size);
+ cudaError_t res=cudaMemcpy(dst, src, len, cudaMemcpyDeviceToHost);
+ if (res != cudaSuccess){
+ perror ("gr_vmcircbuf_cuda:copy_buf_to_mem cudaMemcpy");
+ throw std::runtime_error ("gr_vmcircbuf_cuda");
+ }
+#endif /*HAVE_CUDA_RUNTIME_H*/
+}
+
+void
+gr_vmcircbuf_cuda::copy_mem_to_buf(void * dst,void * src,unsigned int len)
+{
+#if defined(HAVE_CUDA_RUNTIME_H)
+ assert(len<=d_size);
+ cudaError_t res=cudaMemcpy(dst, src, len, cudaMemcpyHostToDevice);
+ if (res != cudaSuccess){
+ perror ("gr_vmcircbuf_cuda:copy_mem_to_buf cudaMemcpy");
+ throw std::runtime_error ("gr_vmcircbuf_cuda");
+ }
+#endif /*HAVE_CUDA_RUNTIME_H*/
+}
+
+
+
+gr_vmcircbuf_cuda::~gr_vmcircbuf_cuda ()
+{
+#if defined(HAVE_CUDA_RUNTIME_H)
+ cudaError_t res=cudaFree(d_base);
+ if (res !=cudaSuccess){
+ perror ("gr_vmcircbuf_cuda: cudaFree");
+ }
+#endif /*HAVE_CUDA_RUNTIME_H*/
+}
+
+// ----------------------------------------------------------------
+// The factory interface
+// ----------------------------------------------------------------
+
+
+gr_vmcircbuf_factory *gr_vmcircbuf_cuda_factory::s_the_factory = 0;
+
+gr_vmcircbuf_factory *
+gr_vmcircbuf_cuda_factory::singleton ()
+{
+ if (s_the_factory)
+ return s_the_factory;
+
+ s_the_factory = new gr_vmcircbuf_cuda_factory ();
+ return s_the_factory;
+}
+
+int
+gr_vmcircbuf_cuda_factory::granularity ()
+{
+ return 1;//gr_pagesize ();
+}
+
+gr_vmcircbuf *
+gr_vmcircbuf_cuda_factory::make (int size)
+{
+ try {
+ return new gr_vmcircbuf_cuda (size);
+ }
+ catch (...){
+ return 0;
+ }
+}
Property changes on:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.h
===================================================================
---
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.h
(rev 0)
+++
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.h
2008-08-11 00:46:59 UTC (rev 9233)
@@ -0,0 +1,109 @@
+/* -*- 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_CUDA_H_
+#define _GR_VMCIRCBUF_CUDA_H_
+
+#include <gr_vmcircbuf.h>
+
+/*!
+ * \brief concrete class to implement emulated circular buffers with CUDA
+ * \ingroup base
+ */
+class gr_vmcircbuf_cuda : public gr_vmcircbuf {
+ public:
+
+ // CREATORS
+
+ gr_vmcircbuf_cuda (int size);
+ virtual ~gr_vmcircbuf_cuda ();
+ // 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_cuda_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_cuda_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_CUDA_H_ */
Property changes on:
gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime/gr_vmcircbuf_cuda.h
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9233 - gnuradio/branches/developers/nldudok1/gpgpu-wip/gnuradio-core/src/lib/runtime,
nldudok1 <=