[Scipy-svn] r4333 - in branches/refactor_fft/scipy/fftpack: . backends backends/include
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu May 15 08:29:57 EDT 2008
Author: cdavid
Date: 2008-05-15 07:29:46 -0500 (Thu, 15 May 2008)
New Revision: 4333
Added:
branches/refactor_fft/scipy/fftpack/backends/include/
branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h
branches/refactor_fft/scipy/fftpack/backends/setup.py
Modified:
branches/refactor_fft/scipy/fftpack/setup.py
Log:
Modify setup to build optional backends if available.
Added: branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h
===================================================================
--- branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:28:27 UTC (rev 4332)
+++ branches/refactor_fft/scipy/fftpack/backends/include/cycliccache.h 2008-05-15 12:29:46 UTC (rev 4333)
@@ -0,0 +1,100 @@
+#ifndef _CYCLIC_CACHE_H_
+#define _CYCLIC_CACHE_H_
+
+namespace fft {
+
+class CacheId {
+ public:
+ CacheId(int n) : m_n(n) {};
+ virtual ~CacheId() {};
+
+ virtual bool operator==(const CacheId& other) const
+ {
+ return is_equal(other);
+ };
+
+ virtual bool is_equal(const CacheId& other) const
+ {
+ return m_n == other.m_n;
+ };
+
+ public:
+ int m_n;
+
+};
+
+template <class T>
+class Cache {
+ public:
+ Cache() {};
+ Cache(const T& id) : m_id(id) {};
+ virtual ~Cache() {};
+
+ virtual bool operator==(const Cache& other) const
+ {
+ return other.m_id == m_id;
+ };
+
+ public:
+ T m_id;
+};
+
+template <class T, class U>
+class CacheManager {
+ public:
+ CacheManager(int n) :
+ m_n(n),
+ m_curn(0),
+ m_last(0)
+ {
+ m_cache = new U*[n];
+
+ };
+
+ virtual ~CacheManager()
+ {
+ int i;
+
+ for (i = 0; i < m_curn; ++i) {
+ delete m_cache[i];
+ }
+
+ delete[] m_cache;
+ }
+
+ virtual U* get_cache(const T& id)
+ {
+ int i;
+
+ /* Look in the current cache */
+ for (i = 0; i < m_curn; ++i) {
+ if ( m_cache[i]->m_id == id) {
+ m_last = i;
+ return m_cache[i];
+ }
+ }
+
+ /* If still space, create a new cache */
+ if (m_curn < m_n) {
+ i = m_curn;
+ ++m_curn;
+ } else {
+ i = (m_last < m_n - 1) ? m_last + 1 : 0;
+ delete m_cache[i];
+ }
+
+ m_cache[i] = new U(id);
+ m_last = i;
+ return m_cache[i];
+ };
+
+ private:
+ U** m_cache;
+ int m_n;
+ int m_curn;
+ int m_last;
+};
+
+}
+
+#endif
Added: branches/refactor_fft/scipy/fftpack/backends/setup.py
===================================================================
--- branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:28:27 UTC (rev 4332)
+++ branches/refactor_fft/scipy/fftpack/backends/setup.py 2008-05-15 12:29:46 UTC (rev 4333)
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# Created by Pearu Peterson, August 2002
+
+from os.path import join
+
+def build_backends(config):
+ from numpy.distutils.system_info import get_info
+ # Build backends for fftpack and convolve
+ backends_src = {}
+ backends_src['djbfft'] = [join('djbfft/', i) for i in
+ ['zfft.cxx', 'drfft.cxx', 'convolve.cxx']]
+ backends_src['fftw3'] = [join('fftw3/', i) for i in
+ ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx']]
+ backends_src['fftw2'] = [join('fftw/', i) for i in
+ ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']]
+ backends_src['fftpack'] = [join('fftpack/', i) for i in
+ ['zfft.cxx', 'drfft.cxx', 'zfftnd.cxx', 'convolve.cxx']]
+ backends_src['mkl'] = [join('mkl/', i) for i in
+ ['zfft.cxx', 'zfftnd.cxx']]
+
+ backends = ['mkl', 'djbfft', 'fftw3', 'fftw2']
+ for backend in backends:
+ info = get_info(backend)
+ if info:
+ config.add_library("%s_backend" % backend,
+ sources = backends_src[backend],
+ include_dirs = ["include",
+ info['include_dirs']])
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+
+ config = Configuration('backends', parent_package, top_path)
+ build_backends(config)
+
+ return config
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(**configuration(top_path='').todict())
Property changes on: branches/refactor_fft/scipy/fftpack/backends/setup.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: branches/refactor_fft/scipy/fftpack/setup.py
===================================================================
--- branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:28:27 UTC (rev 4332)
+++ branches/refactor_fft/scipy/fftpack/setup.py 2008-05-15 12:29:46 UTC (rev 4333)
@@ -106,6 +106,10 @@
libraries = ["dfftpack"],
include_dirs = ['src'],
)
+
+ # Build optional backends
+ config.add_subpackage('backends')
+
return config
if __name__ == '__main__':
More information about the Scipy-svn
mailing list