[Scipy-svn] r4364 - in branches/refactor_fft/scipy/fftpack/backends/mkl: . src
scipy-svn at scipy.org
scipy-svn at scipy.org
Fri May 16 02:17:32 EDT 2008
Author: cdavid
Date: 2008-05-16 01:17:24 -0500 (Fri, 16 May 2008)
New Revision: 4364
Added:
branches/refactor_fft/scipy/fftpack/backends/mkl/src/
branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h
branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfft.cxx
branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfftnd.cxx
Removed:
branches/refactor_fft/scipy/fftpack/backends/mkl/api.h
branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx
branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx
Log:
Move mkl backend sources one dir deeper.
Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/api.h
===================================================================
--- branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-16 06:16:23 UTC (rev 4363)
+++ branches/refactor_fft/scipy/fftpack/backends/mkl/api.h 2008-05-16 06:17:24 UTC (rev 4364)
@@ -1,16 +0,0 @@
-#ifndef _SCIPY_FFTPACK_MKL_API_H_
-#define _SCIPY_FFTPACK_MKL_API_H_
-
-#include "misc.h"
-
-/*
- * straight FFT api
- */
-void zfft_mkl(complex_double * inout,
- int n, int direction, int howmany, int normalize);
-
-void zfftnd_mkl(complex_double * inout, int rank,
- int *dims, int direction, int howmany,
- int normalize);
-
-#endif
Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/src/api.h (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/mkl/api.h)
Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfft.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx)
Copied: branches/refactor_fft/scipy/fftpack/backends/mkl/src/zfftnd.cxx (from rev 4353, branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx)
Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx
===================================================================
--- branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx 2008-05-16 06:16:23 UTC (rev 4363)
+++ branches/refactor_fft/scipy/fftpack/backends/mkl/zfft.cxx 2008-05-16 06:17:24 UTC (rev 4364)
@@ -1,92 +0,0 @@
-#include <new>
-
-#include <mkl_dfti.h>
-
-#include "api.h"
-#include "cycliccache.h"
-
-using namespace fft;
-
-class MKLCacheId : public CacheId {
- public:
- MKLCacheId(int n) : CacheId(n) {};
-};
-
-
-class MKLCache: public Cache<MKLCacheId> {
- public:
- MKLCache(const MKLCacheId& id);
- virtual ~MKLCache();
-
- int compute_forward(complex_double * inout) const;
- int compute_backward(complex_double * inout) const;
-
- protected:
- DFTI_DESCRIPTOR_HANDLE m_hdl;
-};
-
-MKLCache::MKLCache(const MKLCacheId& id)
-: Cache<MKLCacheId>(id)
-{
- int n = id.m_n;
-
- DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, 1, (long)n);
- DftiCommitDescriptor(m_hdl);
-
- return;
-}
-
-MKLCache::~MKLCache()
-{
- DftiFreeDescriptor(&m_hdl);
-}
-
-int MKLCache::compute_forward(complex_double *inout) const
-{
- DftiComputeForward(m_hdl, (double *) inout);
- return 0;
-}
-
-int MKLCache::compute_backward(complex_double *inout) const
-{
- DftiComputeBackward(m_hdl, (double *) inout);
- return 0;
-}
-
-CacheManager<MKLCacheId, MKLCache> zmkl_cmgr(10);
-
-void zfft_mkl(complex_double * inout,
- int n, int direction, int howmany, int normalize)
-{
- int i;
- complex_double *ptr = inout;
- MKLCache *cache;
-
- cache = zmkl_cmgr.get_cache(MKLCacheId(n));
-
- switch (direction) {
-
- case 1:
- for (i = 0; i < howmany; ++i, ptr += n) {
- cache->compute_forward(ptr);
- }
- break;
-
- case -1:
- for (i = 0; i < howmany; ++i, ptr += n) {
- cache->compute_backward(ptr);
- }
- break;
-
- default:
- fprintf(stderr, "zfft: invalid direction=%d\n", direction);
- }
-
- if (normalize) {
- ptr = inout;
- for (i = n * howmany - 1; i >= 0; --i) {
- *((double *) (ptr)) /= n;
- *((double *) (ptr++) + 1) /= n;
- }
- }
-}
Deleted: branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx
===================================================================
--- branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx 2008-05-16 06:16:23 UTC (rev 4363)
+++ branches/refactor_fft/scipy/fftpack/backends/mkl/zfftnd.cxx 2008-05-16 06:17:24 UTC (rev 4364)
@@ -1,211 +0,0 @@
-/*
- * MKL backend for multi dimensional fft
- *
- * Original code by David M. Cooke
- *
- * Last Change: Tue May 13 05:00 PM 2008 J
- */
-#include <new>
-
-#include <mkl_dfti.h>
-
-#include "api.h"
-#include "cycliccache.h"
-
-using namespace fft;
-
-static int equal_dims(int rank,int *dims1,int *dims2)
-{
- int i;
- for (i = 0; i < rank; ++i) {
- if (dims1[i] != dims2[i]) {
- return 0;
- }
- }
- return 1;
-}
-
-class NDMKLCacheId {
- public:
- NDMKLCacheId(int rank, int *dim);
- virtual ~NDMKLCacheId();
-
- NDMKLCacheId(const NDMKLCacheId &);
-
- virtual bool operator==(const NDMKLCacheId & other) const {
- return is_equal(other);
- };
-
- virtual bool is_equal(const NDMKLCacheId & other) const;
-
- public:
- int m_rank;
- int *m_dims;
-
- private:
- int init(int rank, int *dims);
-};
-
-int NDMKLCacheId::init(int rank, int *dims)
-{
- m_dims = (int *) malloc(sizeof(int) * rank);
- if (m_dims == NULL) {
- return -1;
- }
- memcpy(m_dims, dims, rank * sizeof(*m_dims));
-
- return 0;
-
-}
-
-NDMKLCacheId::NDMKLCacheId(int rank, int *dims) :
- m_rank(rank)
-{
- if (init(rank, dims)) {
- goto fail;
- }
-
-fail:
- std::bad_alloc();
-}
-
-NDMKLCacheId::NDMKLCacheId(const NDMKLCacheId & copy) :
- m_rank(copy.m_rank)
-{
- if (init(copy.m_rank, copy.m_dims)) {
- goto fail;
- }
-
-fail:
- std::bad_alloc();
-}
-
-NDMKLCacheId::~NDMKLCacheId()
-{
- free(m_dims);
-}
-
-bool NDMKLCacheId::is_equal(const NDMKLCacheId & other) const
-{
- bool res;
-
- if (m_rank == other.m_rank) {
- res = equal_dims(m_rank, m_dims, other.m_dims);
- } else {
- return false;
- }
-
- return res;
-}
-
-/*
- * Cache class for nd-MKL
- */
-class NDMKLCache:public Cache < NDMKLCacheId > {
- public:
- NDMKLCache(const NDMKLCacheId & id);
- virtual ~ NDMKLCache();
-
- int compute_forward(double * inout) const
- {
- DftiComputeForward(m_hdl, inout);
- return 0;
- };
-
- int compute_backward(double * inout) const
- {
- DftiComputeBackward(m_hdl, inout);
- return 0;
- };
-
- protected:
- int m_rank;
- int *m_dims;
- long *m_ndims;
- DFTI_DESCRIPTOR_HANDLE m_hdl;
-
- private:
- long *convert_dims(int n, int *dims) const;
-
-};
-
-NDMKLCache::NDMKLCache(const NDMKLCacheId & id)
-: Cache < NDMKLCacheId > (id)
-{
- m_rank = id.m_rank;
- m_ndims = convert_dims(id.m_rank, id.m_dims);
- m_dims = (int *) malloc(sizeof(int) * m_rank);
- if (m_dims == NULL) {
- goto fail;
- }
-
- memcpy(m_dims, id.m_dims, sizeof(int) * m_rank);
- DftiCreateDescriptor(&m_hdl, DFTI_DOUBLE, DFTI_COMPLEX, (long) m_rank,
- m_ndims);
- DftiCommitDescriptor(m_hdl);
-
- return;
-
-fail:
- throw std::bad_alloc();
-}
-
-NDMKLCache::~NDMKLCache()
-{
- DftiFreeDescriptor(&m_hdl);
- free(m_dims);
- free(m_ndims);
-}
-
-long* NDMKLCache::convert_dims(int n, int *dims) const
-{
- long *ndim;
- int i;
-
- ndim = (long *) malloc(sizeof(*ndim) * n);
- for (i = 0; i < n; i++) {
- ndim[i] = (long) dims[i];
- }
- return ndim;
-}
-
-static CacheManager < NDMKLCacheId, NDMKLCache > ndmkl_cmgr(10);
-
-void zfftnd_mkl(complex_double * inout, int rank,
- int *dims, int direction, int howmany,
- int normalize)
-{
- int i, sz;
- complex_double *ptr = inout;
- NDMKLCache *cache;
-
- sz = 1;
- for (i = 0; i < rank; ++i) {
- sz *= dims[i];
- }
-
- cache = ndmkl_cmgr.get_cache(NDMKLCacheId(rank, dims));
- switch(direction) {
- case 1:
- for (i = 0; i < howmany; ++i, ptr += sz) {
- cache->compute_forward((double*)ptr);
- }
- break;
- case -1:
- for (i = 0; i < howmany; ++i, ptr += sz) {
- cache->compute_backward((double*)ptr);
- }
- break;
- default:
- fprintf(stderr,
- "nd mkl:Wrong direction (this is a bug)\n");
- return;
- }
- if (normalize) {
- ptr = inout;
- for (i = sz * howmany - 1; i >= 0; --i) {
- *((double *) (ptr)) /= sz;
- *((double *) (ptr++) + 1) /= sz;
- }
- }
-}
More information about the Scipy-svn
mailing list