Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4813a816 authored by hhakim's avatar hhakim
Browse files

Add support of GPU complex Faust in pyfaust.

- Issue #157's related.
- All functions supported for real Faust are 'supported' too for complex (but the tests are not widely ensured -- e.g. #181) among what Faust.dft.
parent fed57eb3
Branches
Tags
No related merge requests found
...@@ -548,8 +548,10 @@ namespace Faust ...@@ -548,8 +548,10 @@ namespace Faust
template<typename FPP> template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::fourierFaust(unsigned int n, const bool norma/*=true*/) TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::fourierFaust(unsigned int n, const bool norma/*=true*/)
{ {
throw std::runtime_error("fourierFaust is yet to implement in Faust C++ core for GPU."); auto cpu_faust = TransformHelper<FPP,Cpu>::fourierFaust(n, norma);
return nullptr; TransformHelper<FPP,GPU2>* gpu_faust = new TransformHelper<FPP,GPU2>(*cpu_faust, -1, nullptr /*TODO: dev_id and stream ?*/);
delete cpu_faust;
return gpu_faust;
} }
template<typename FPP> template<typename FPP>
......
...@@ -2435,6 +2435,7 @@ def wht(n, normed=True, dev="cpu"): ...@@ -2435,6 +2435,7 @@ def wht(n, normed=True, dev="cpu"):
and a factorization in log2(n) factors. and a factorization in log2(n) factors.
normed: default to True to normalize the Hadamard Faust as if you called normed: default to True to normalize the Hadamard Faust as if you called
Faust.normalize() and False otherwise. Faust.normalize() and False otherwise.
dev: device to create the Faust on.
Returns: Returns:
The Faust implementing the Hadamard transform of dimension n. The Faust implementing the Hadamard transform of dimension n.
...@@ -2467,7 +2468,7 @@ def wht(n, normed=True, dev="cpu"): ...@@ -2467,7 +2468,7 @@ def wht(n, normed=True, dev="cpu"):
H = Faust(core_obj=_FaustCorePy.FaustCoreGPU.hadamardFaust(log2n, normed)) H = Faust(core_obj=_FaustCorePy.FaustCoreGPU.hadamardFaust(log2n, normed))
return H return H
def dft(n, normed=True): def dft(n, normed=True, dev='cpu'):
""" """
Constructs a Faust F such that F.toarray() is the Discrete Fourier Transform square matrix of order n. Constructs a Faust F such that F.toarray() is the Discrete Fourier Transform square matrix of order n.
...@@ -2482,6 +2483,7 @@ def dft(n, normed=True): ...@@ -2482,6 +2483,7 @@ def dft(n, normed=True):
factorization in log2(n)+1 factors. factorization in log2(n)+1 factors.
normed: default to True to normalize the DFT Faust as if you called normed: default to True to normalize the DFT Faust as if you called
Faust.normalize() and False otherwise. Faust.normalize() and False otherwise.
dev: device to create the Faust on.
Returns: Returns:
The Faust implementing the DFT of dimension n. The Faust implementing the DFT of dimension n.
...@@ -2508,7 +2510,10 @@ def dft(n, normed=True): ...@@ -2508,7 +2510,10 @@ def dft(n, normed=True):
if(n > 2**log2n): raise ValueError("n must be a power of 2.") if(n > 2**log2n): raise ValueError("n must be a power of 2.")
if(not isinstance(normed, bool)): if(not isinstance(normed, bool)):
raise TypeError("normed must be True of False.") raise TypeError("normed must be True of False.")
F = Faust(core_obj=_FaustCorePy.FaustCore.fourierFaust(log2n, normed)) if dev == "cpu":
F = Faust(core_obj=_FaustCorePy.FaustCore.fourierFaust(log2n, normed))
elif dev.startswith("gpu"):
F = Faust(core_obj=_FaustCorePy.FaustCoreGPU.fourierFaust(log2n, normed))
return F return F
def eye(m,n=None,t='real', dev="cpu"): def eye(m,n=None,t='real', dev="cpu"):
......
...@@ -6,7 +6,7 @@ cdef class FaustCoreGPU: ...@@ -6,7 +6,7 @@ cdef class FaustCoreGPU:
#### ATTRIBUTE ######## #### ATTRIBUTE ########
# classe Cython # classe Cython
cdef FaustCoreCy.FaustCoreCppGPU[double]* core_faust_dbl cdef FaustCoreCy.FaustCoreCppGPU[double]* core_faust_dbl
#cdef FaustCoreCy.FaustCoreCppGPU[complex]* core_faust_cplx cdef FaustCoreCy.FaustCoreCppGPU[complex]* core_faust_cplx
cdef bool _isReal cdef bool _isReal
#### CONSTRUCTOR #### #### CONSTRUCTOR ####
#def __cinit__(self,np.ndarray[double, mode="fortran", ndim=2] mat): #def __cinit__(self,np.ndarray[double, mode="fortran", ndim=2] mat):
...@@ -51,9 +51,7 @@ cdef class FaustCoreGPU: ...@@ -51,9 +51,7 @@ cdef class FaustCoreGPU:
if(self._isReal): if(self._isReal):
self.core_faust_dbl = new FaustCoreCy.FaustCoreCppGPU[double]() self.core_faust_dbl = new FaustCoreCy.FaustCoreCppGPU[double]()
else: else:
raise ValueError("complex wrapper is not yet supported.") self.core_faust_cplx = new FaustCoreCy.FaustCoreCppGPU[complex]()
# self.core_faust_cplx = new FaustCoreCy.FaustCoreCpp[complex,
# gpu]()
for factor in list_factors: for factor in list_factors:
nbrow=factor.shape[0]; nbrow=factor.shape[0];
nbcol=factor.shape[1]; nbcol=factor.shape[1];
...@@ -70,27 +68,26 @@ cdef class FaustCoreGPU: ...@@ -70,27 +68,26 @@ cdef class FaustCoreGPU:
&indices[0], factor.nnz, &indices[0], factor.nnz,
nbrow, nbcol, optimizedCopy) nbrow, nbcol, optimizedCopy)
else: else:
raise ValueError("complex wrapper is not yet supported.") if(isinstance(factor, sparse.csc.csc_matrix)):
# if(isinstance(factor, sparse.csc.csc_matrix)): #TODO: understand how is it possible to have a sparse
# #TODO: understand how is it possible to have a sparse # mat here and fix it (because it should have been
# # mat here and fix it (because it should have been # converted above already)
# # converted above already) factor = list_factors[i] = factor.tocsr()
# factor = list_factors[i] = factor.tocsr() #print('FaustCorePy.pyx type factor=',type(factor))
# #print('FaustCorePy.pyx type factor=',type(factor)) #print("FaustCorePy.pyx factor=",factor)
# #print("FaustCorePy.pyx factor=",factor) if(isinstance(factor, np.ndarray)):
# if(isinstance(factor, np.ndarray)): data_cplx=factor.astype(np.complex128,'F')
# data_cplx=factor.astype(np.complex128,'F') self.core_faust_cplx.push_back(&data_cplx[0,0], nbrow,
# self.core_faust_cplx.push_back(&data_cplx[0,0], nbrow, nbcol, optimizedCopy)
# nbcol, optimizedCopy) else:
# else: #print("FaustCore, factor dims:", nbrow, nbcol)
# #print("FaustCore, factor dims:", nbrow, nbcol) data1d_cplx = factor.data.astype(np.complex128, 'F')
# data1d_cplx = factor.data.astype(np.complex128, 'F') indices=factor.indices.astype(np.int32, 'F')
# indices=factor.indices.astype(np.int32, 'F') indptr=factor.indptr.astype(np.int32, 'F')
# indptr=factor.indptr.astype(np.int32, 'F') self.core_faust_cplx.push_back(&data1d_cplx[0], &indptr[0],
# self.core_faust_cplx.push_back(&data1d_cplx[0], &indptr[0], &indices[0], factor.nnz,
# &indices[0], factor.nnz, nbrow, nbcol,
# nbrow, nbcol, optimizedCopy)
# optimizedCopy)
elif(core): # trick to initialize a new FaustCoreCpp from C++ (see elif(core): # trick to initialize a new FaustCoreCpp from C++ (see
# transpose, conj and adjoint) # transpose, conj and adjoint)
pass pass
...@@ -101,8 +98,8 @@ cdef class FaustCoreGPU: ...@@ -101,8 +98,8 @@ cdef class FaustCoreGPU:
cdef const char* c_str cdef const char* c_str
if(self._isReal): if(self._isReal):
c_str = self.core_faust_dbl.to_string() c_str = self.core_faust_dbl.to_string()
# else: else:
# c_str = self.core_faust_cplx.to_string() c_str = self.core_faust_cplx.to_string()
cdef length = strlen(c_str) cdef length = strlen(c_str)
#printf("%s", c_str[:length]) #printf("%s", c_str[:length])
#py_str = str(c_str[:length], 'UTF-8') #py_str = str(c_str[:length], 'UTF-8')
...@@ -113,8 +110,8 @@ cdef class FaustCoreGPU: ...@@ -113,8 +110,8 @@ cdef class FaustCoreGPU:
def display(self): def display(self):
if(self._isReal): if(self._isReal):
self.core_faust_dbl.Display() self.core_faust_dbl.Display()
# else: else:
# self.core_faust_cplx.Display() self.core_faust_cplx.Display()
def multiply(self,M): def multiply(self,M):
if(isinstance(M, FaustCoreGPU)): if(isinstance(M, FaustCoreGPU)):
...@@ -125,10 +122,10 @@ cdef class FaustCoreGPU: ...@@ -125,10 +122,10 @@ cdef class FaustCoreGPU:
M=M.astype(float,'F') M=M.astype(float,'F')
if not M.dtype=='float': if not M.dtype=='float':
raise ValueError('input M must be a double array') raise ValueError('input M must be a double array')
# else: else:
# M=M.astype(complex,'F') M=M.astype(complex,'F')
# if(M.dtype not in ['complex', 'complex128', 'complex64'] ): #could fail if complex128 etc. if(M.dtype not in ['complex', 'complex128', 'complex64'] ): #could fail if complex128 etc.
# raise ValueError('input M must be complex array') raise ValueError('input M must be complex array')
#TODO: raise exception if not real nor complex #TODO: raise exception if not real nor complex
if not M.flags['F_CONTIGUOUS']: if not M.flags['F_CONTIGUOUS']:
raise ValueError('input M must be Fortran contiguous (column major ' raise ValueError('input M must be Fortran contiguous (column major '
...@@ -177,28 +174,28 @@ cdef class FaustCoreGPU: ...@@ -177,28 +174,28 @@ cdef class FaustCoreGPU:
cdef y cdef y
cdef double[:,:] yview cdef double[:,:] yview
# cdef complex[:,:] yview_cplx cdef complex[:,:] yview_cplx
if(self._isReal): if(self._isReal):
y = np.zeros([nbrow_y,nbcol_y], dtype='d',order='F') y = np.zeros([nbrow_y,nbcol_y], dtype='d',order='F')
yview = y yview = y
# else: else:
# y = np.zeros([nbrow_y, nbcol_y], dtype='complex', order='F') y = np.zeros([nbrow_y, nbcol_y], dtype='complex', order='F')
# yview_cplx = y yview_cplx = y
#
if ndim_M == 1: if ndim_M == 1:
if(self._isReal): if(self._isReal):
self.core_faust_dbl.multiply(&yview[0,0],nbrow_y,nbcol_y,&xview_1D[0],nbrow_x,nbcol_x) self.core_faust_dbl.multiply(&yview[0,0],nbrow_y,nbcol_y,&xview_1D[0],nbrow_x,nbcol_x)
# else: else:
# self.core_faust_cplx.multiply(&yview_cplx[0,0], nbrow_y, self.core_faust_cplx.multiply(&yview_cplx[0,0], nbrow_y,
# nbcol_y, &xview_1D_cplx[0], nbcol_y, &xview_1D_cplx[0],
# nbrow_x,nbcol_x) nbrow_x,nbcol_x)
y = np.squeeze(y) # we want a single dim. (but we created two y = np.squeeze(y) # we want a single dim. (but we created two
# above) # above)
else: else:
if(self._isReal): if(self._isReal):
self.core_faust_dbl.multiply(&yview[0,0],nbrow_y,nbcol_y,&xview_2D[0,0],nbrow_x,nbcol_x) self.core_faust_dbl.multiply(&yview[0,0],nbrow_y,nbcol_y,&xview_2D[0,0],nbrow_x,nbcol_x)
# else: else:
# self.core_faust_cplx.multiply(&yview_cplx[0,0],nbrow_y,nbcol_y,&xview_2D_cplx[0,0],nbrow_x,nbcol_x) self.core_faust_cplx.multiply(&yview_cplx[0,0],nbrow_y,nbcol_y,&xview_2D_cplx[0,0],nbrow_x,nbcol_x)
return y return y
...@@ -208,9 +205,9 @@ cdef class FaustCoreGPU: ...@@ -208,9 +205,9 @@ cdef class FaustCoreGPU:
if(self._isReal): if(self._isReal):
nbrow = self.core_faust_dbl.getNbRow(); nbrow = self.core_faust_dbl.getNbRow();
nbcol = self.core_faust_dbl.getNbCol(); nbcol = self.core_faust_dbl.getNbCol();
# else: else:
# nbrow = self.core_faust_cplx.getNbRow(); nbrow = self.core_faust_cplx.getNbRow();
# nbcol = self.core_faust_cplx.getNbCol(); nbcol = self.core_faust_cplx.getNbCol();
return (nbrow,nbcol) return (nbrow,nbcol)
@staticmethod @staticmethod
...@@ -219,22 +216,22 @@ cdef class FaustCoreGPU: ...@@ -219,22 +216,22 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(field == 3): if(field == 3):
core.core_faust_dbl = \ core.core_faust_dbl = \
FaustCoreCy.FaustCoreCppGPU[double].randFaustGPU(faust_nrows, FaustCoreCy.FaustCoreCppGPU[double].randFaustGPU(faust_nrows,
faust_ncols, faust_ncols,
t, min_num_factors, t, min_num_factors,
max_num_factors, min_dim_size, max_num_factors, min_dim_size,
max_dim_size, density, per_row) max_dim_size, density, per_row)
core._isReal = True core._isReal = True
if(core.core_faust_dbl == NULL): raise MemoryError() if(core.core_faust_dbl == NULL): raise MemoryError()
elif(field == 4): elif(field == 4):
raise ValueError("Complex rand Faust is not yet implemented on " core.core_faust_cplx = \
" GPU.") FaustCoreCy.FaustCoreCppGPU[complex].randFaustGPU(faust_nrows,
# core.core_faust_cplx = faust_ncols,
# FaustCoreCy.FaustCoreCpp[complex].randFaust(faust_nrows, t, min_num_factors,
# faust_ncols, t, min_num_factors, max_num_factors, min_dim_size, max_num_factors, min_dim_size,
# max_dim_size, density, per_row) max_dim_size, density, per_row)
# if(core.core_faust_cplx == NULL): raise MemoryError() if(core.core_faust_cplx == NULL): raise MemoryError()
# core._isReal = False core._isReal = False
else: else:
raise ValueError("FaustCorePy.randFaust(): field must be 3 for real or" raise ValueError("FaustCorePy.randFaust(): field must be 3 for real or"
" 4 for complex") " 4 for complex")
...@@ -261,13 +258,12 @@ cdef class FaustCoreGPU: ...@@ -261,13 +258,12 @@ cdef class FaustCoreGPU:
raise ValueError("Faust doesn't handle a FFT of order larger than " raise ValueError("Faust doesn't handle a FFT of order larger than "
"2**31") "2**31")
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
# core.core_faust_cplx = \ core.core_faust_cplx = \
# FaustCoreCy.FaustCoreCppGPU[complex].fourierFaust(n, norma) FaustCoreCy.FaustCoreCppGPU[complex].fourierFaustGPU(n, norma)
# if(core.core_faust_cplx == NULL): if(core.core_faust_cplx == NULL):
# raise MemoryError() raise MemoryError()
FaustCoreCy.FaustCoreCppGPU[double].fourierFaustGPU(n, norma)
# fourier is always a complex Faust # fourier is always a complex Faust
core._isReal = False core._isReal = False
return core return core
...@@ -279,17 +275,18 @@ cdef class FaustCoreGPU: ...@@ -279,17 +275,18 @@ cdef class FaustCoreGPU:
core.core_faust_dbl = \ core.core_faust_dbl = \
FaustCoreCy.FaustCoreCppGPU[double].eyeFaustGPU(n, m) FaustCoreCy.FaustCoreCppGPU[double].eyeFaustGPU(n, m)
core._isReal = True core._isReal = True
# elif(t == 'complex'): elif(t == 'complex'):
# core.core_faust_cplx = FaustCoreCy.FaustCoreCppGPU[complex].eyeFaust(n, core.core_faust_cplx = \
# m) FaustCoreCy.FaustCoreCppGPU[complex].eyeFaustGPU(n,
# core._isReal = False m)
core._isReal = False
return core return core
def nbytes(self): def nbytes(self):
if(self._isReal): if(self._isReal):
nbytes = self.core_faust_dbl.getNBytes(); nbytes = self.core_faust_dbl.getNBytes();
# else: else:
# nbytes = self.core_faust_cplx.getNBytes(); nbytes = self.core_faust_cplx.getNBytes();
return nbytes return nbytes
def get_product(self): def get_product(self):
...@@ -302,13 +299,13 @@ cdef class FaustCoreGPU: ...@@ -302,13 +299,13 @@ cdef class FaustCoreGPU:
y_data = y_arr y_data = y_arr
self.core_faust_dbl.get_product(&y_data[0,0], y_arr.shape[0], self.core_faust_dbl.get_product(&y_data[0,0], y_arr.shape[0],
y_arr.shape[1]) y_arr.shape[1])
# else: else:
# y_arr = np.empty((self.core_faust_cplx.getNbRow(), self.core_faust_cplx.getNbCol()), y_arr = np.empty((self.core_faust_cplx.getNbRow(), self.core_faust_cplx.getNbCol()),
# dtype=np.complex, dtype=np.complex,
# order='F') order='F')
# y_data_cplx = y_arr y_data_cplx = y_arr
# self.core_faust_cplx.get_product(&y_data_cplx[0,0], y_arr.shape[0], self.core_faust_cplx.get_product(&y_data_cplx[0,0], y_arr.shape[0],
# y_arr.shape[1]) y_arr.shape[1])
return y_arr return y_arr
cdef multiply_faust(self, F): cdef multiply_faust(self, F):
...@@ -319,28 +316,28 @@ cdef class FaustCoreGPU: ...@@ -319,28 +316,28 @@ cdef class FaustCoreGPU:
if(F.isReal()): if(F.isReal()):
core.core_faust_dbl = \ core.core_faust_dbl = \
self.core_faust_dbl.mul_faust_gpu((<FaustCoreGPU?>F).core_faust_dbl) self.core_faust_dbl.mul_faust_gpu((<FaustCoreGPU?>F).core_faust_dbl)
# else: else:
# core = \ core = \
# <FaustCoreGPU?> (<FaustCoreGPU?> self._ascomplex()).multiply_faust(F) <FaustCoreGPU?> (<FaustCoreGPU?> self._ascomplex()).multiply_faust(F)
# else: else:
# if(F.isReal()): if(F.isReal()):
# core.core_faust_cplx = \ core.core_faust_cplx = \
# self.core_faust_cplx.mul_faust((<FaustCore?>((<FaustCore?>((<FaustCore?>F)._ascomplex())))).core_faust_cplx) self.core_faust_cplx.mul_faust_gpu((<FaustCoreGPU?>((<FaustCoreGPU?>((<FaustCoreGPU?>F)._ascomplex())))).core_faust_cplx)
# else: else:
# core.core_faust_cplx = \ core.core_faust_cplx = \
# self.core_faust_cplx.mul_faust((<FaustCore?>F).core_faust_cplx) self.core_faust_cplx.mul_faust_gpu((<FaustCoreGPU?>F).core_faust_cplx)
return core return core
raise ValueError("F must be a Faust object") raise ValueError("F must be a Faust object")
# cdef _ascomplex(self, scalar=1.0): cdef _ascomplex(self, scalar=1.0):
# cplx_facs = [self.get_fact_opt(i).astype(np.complex) for i in \ cplx_facs = [self.get_fact_opt(i).astype(np.complex) for i in \
# range(0,self.get_nb_factors())] range(0,self.get_nb_factors())]
# cplx_facs[0] *= scalar # instead of passing the scal to the cplx_facs[0] *= scalar # instead of passing the scal to the
# # construc. It avoids disp of # construc. It avoids disp of
# # deprecation warning # deprecation warning
# core = FaustCoreGPU(cplx_facs)#, alpha=scalar) core = FaustCoreGPU(cplx_facs)#, alpha=scalar)
# core._isReal = False core._isReal = False
# return core return core
def multiply_scal(self, scalar): def multiply_scal(self, scalar):
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
...@@ -353,18 +350,18 @@ cdef class FaustCoreGPU: ...@@ -353,18 +350,18 @@ cdef class FaustCoreGPU:
if(isinstance(scalar, float)): if(isinstance(scalar, float)):
core.core_faust_dbl = \ core.core_faust_dbl = \
self.core_faust_dbl.mul_scal_gpu(scalar) self.core_faust_dbl.mul_scal_gpu(scalar)
# elif(isinstance(scalar, np.complex)): elif(isinstance(scalar, np.complex)):
# core = <FaustCore?>self._ascomplex(scalar) core = <FaustCoreGPU?>self._ascomplex(scalar)
# core._isReal = False core._isReal = False
else:
raise scalar_type_err
else:
if(isinstance(scalar, np.complex) or isinstance(scalar,
float)):
core.core_faust_cplx = \
self.core_faust_cplx.mul_scal_gpu(scalar)
else: else:
raise scalar_type_err raise scalar_type_err
# else:
# if(isinstance(scalar, np.complex) or isinstance(scalar,
# float)):
# core.core_faust_cplx = \
# self.core_faust_cplx.mul_scal(scalar)
# else:
# raise scalar_type_err
return core return core
def isReal(self): def isReal(self):
...@@ -374,8 +371,8 @@ cdef class FaustCoreGPU: ...@@ -374,8 +371,8 @@ cdef class FaustCoreGPU:
cdef unsigned long long nnz = 0 cdef unsigned long long nnz = 0
if(self._isReal): if(self._isReal):
nnz = self.core_faust_dbl.nnz() nnz = self.core_faust_dbl.nnz()
# else: else:
# nnz = self.core_faust_cplx.nnz() nnz = self.core_faust_cplx.nnz()
return nnz return nnz
def norm(self, ord, **kwargs): def norm(self, ord, **kwargs):
...@@ -396,21 +393,21 @@ cdef class FaustCoreGPU: ...@@ -396,21 +393,21 @@ cdef class FaustCoreGPU:
norm = self.core_faust_dbl.normInf() norm = self.core_faust_dbl.normInf()
else: else:
norm = self.core_faust_dbl.normFro() norm = self.core_faust_dbl.normFro()
# else: else:
# if(isinstance(ord,int)): if(isinstance(ord,int)):
# norm = self.core_faust_cplx.norm(ord, threshold, max_num_its) norm = self.core_faust_cplx.norm(ord, threshold, max_num_its)
# elif(ord == np.inf): elif(ord == np.inf):
# norm = self.core_faust_cplx.normInf() norm = self.core_faust_cplx.normInf()
# else: else:
# norm = self.core_faust_cplx.normFro() norm = self.core_faust_cplx.normFro()
return norm return norm
def normalize(self, ord): def normalize(self, ord):
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.normalize_gpu(ord) core.core_faust_dbl = self.core_faust_dbl.normalize_gpu(ord)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.normalize(ord) core.core_faust_cplx = self.core_faust_cplx.normalize_gpu(ord)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -418,8 +415,8 @@ cdef class FaustCoreGPU: ...@@ -418,8 +415,8 @@ cdef class FaustCoreGPU:
cdef int nb_factors cdef int nb_factors
if(self._isReal): if(self._isReal):
nb_factors = int(self.core_faust_dbl.get_nb_factors()) nb_factors = int(self.core_faust_dbl.get_nb_factors())
# else: else:
# nb_factors = int(self.core_faust_cplx.get_nb_factors()) nb_factors = int(self.core_faust_cplx.get_nb_factors())
return nb_factors return nb_factors
def get_fact_opt(self, i): def get_fact_opt(self, i):
...@@ -435,10 +432,10 @@ cdef class FaustCoreGPU: ...@@ -435,10 +432,10 @@ cdef class FaustCoreGPU:
dtype = 'd' dtype = 'd'
is_fact_sparse = self.core_faust_dbl.is_fact_sparse(i) is_fact_sparse = self.core_faust_dbl.is_fact_sparse(i)
is_transposed = self.core_faust_dbl.isTransposed() is_transposed = self.core_faust_dbl.isTransposed()
# else: else:
# dtype = 'complex' dtype = 'complex'
# is_fact_sparse = self.core_faust_cplx.is_fact_sparse(i) is_fact_sparse = self.core_faust_cplx.is_fact_sparse(i)
# is_transposed = self.core_faust_cplx.isTransposed() is_transposed = self.core_faust_cplx.isTransposed()
if(is_fact_sparse): if(is_fact_sparse):
if(self._isReal): if(self._isReal):
# is_transposed = False # uncomment to disable the trick which # is_transposed = False # uncomment to disable the trick which
...@@ -465,31 +462,31 @@ cdef class FaustCoreGPU: ...@@ -465,31 +462,31 @@ cdef class FaustCoreGPU:
&col_ids_view[0], &col_ids_view[0],
&fact_dbl_view[0,0], &fact_dbl_view[0,0],
is_transposed) is_transposed)
# else: else:
# # is_transposed = False # uncomment to disable the trick which # is_transposed = False # uncomment to disable the trick which
# # uses csc representation instead of csr transpose # uses csc representation instead of csr transpose
# # to optimize copy # to optimize copy
# nnz = self.core_faust_cplx.get_fact_nnz(i) nnz = self.core_faust_cplx.get_fact_nnz(i)
# col_ids = np.ndarray([nnz], dtype=np.int32) col_ids = np.ndarray([nnz], dtype=np.int32)
# elts = np.ndarray([1,nnz], dtype=dtype) elts = np.ndarray([1,nnz], dtype=dtype)
# col_ids_view = col_ids col_ids_view = col_ids
# shape = [self.core_faust_cplx.get_fact_nb_rows(i), shape = [self.core_faust_cplx.get_fact_nb_rows(i),
# self.core_faust_cplx.get_fact_nb_cols(i)] self.core_faust_cplx.get_fact_nb_cols(i)]
# if(is_transposed): if(is_transposed):
# rowptr_sz = shape[1]+1 rowptr_sz = shape[1]+1
# else: else:
# rowptr_sz = shape[0]+1 rowptr_sz = shape[0]+1
#
# rowptr = np.ndarray([rowptr_sz], dtype=np.int32) rowptr = np.ndarray([rowptr_sz], dtype=np.int32)
# rowptr_view = rowptr rowptr_view = rowptr
# fact_cplx_view = elts fact_cplx_view = elts
# self.core_faust_cplx.get_fact_sparse(i, &rowptr_view[0], self.core_faust_cplx.get_fact_sparse(i, &rowptr_view[0],
# &col_ids_view[0], &col_ids_view[0],
# &fact_cplx_view[0,0], &fact_cplx_view[0,0],
# is_transposed) is_transposed)
# #print("(rowptr)=", (rowptr)) #print("(rowptr)=", (rowptr))
## print("(col_ids)=", (col_ids)) # print("(col_ids)=", (col_ids))
## print("(elts[0,:]=", (elts)) # print("(elts[0,:]=", (elts))
if(is_transposed): if(is_transposed):
fact = csc_matrix((elts[0,:], col_ids, rowptr), shape=shape) fact = csc_matrix((elts[0,:], col_ids, rowptr), shape=shape)
else: else:
...@@ -511,15 +508,15 @@ cdef class FaustCoreGPU: ...@@ -511,15 +508,15 @@ cdef class FaustCoreGPU:
<unsigned int*>NULL, <unsigned int*>NULL,
<unsigned int*>NULL, <unsigned int*>NULL,
is_transposed) is_transposed)
# else: else:
# fact = np.ndarray([self.core_faust_cplx.get_fact_nb_rows(i), fact = np.ndarray([self.core_faust_cplx.get_fact_nb_rows(i),
# self.core_faust_cplx.get_fact_nb_cols(i)], dtype=dtype, self.core_faust_cplx.get_fact_nb_cols(i)], dtype=dtype,
# order=order) order=order)
# fact_cplx_view = fact fact_cplx_view = fact
# self.core_faust_cplx.get_fact_dense(i, &fact_cplx_view[0, 0], self.core_faust_cplx.get_fact_dense(i, &fact_cplx_view[0, 0],
# <unsigned int*>NULL, <unsigned int*>NULL,
# <unsigned int*>NULL, <unsigned int*>NULL,
# is_transposed) is_transposed)
return fact return fact
...@@ -527,8 +524,8 @@ cdef class FaustCoreGPU: ...@@ -527,8 +524,8 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.left_gpu(id) core.core_faust_dbl = self.core_faust_dbl.left_gpu(id)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.left(id) core.core_faust_cplx = self.core_faust_cplx.left_gpu(id)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -536,8 +533,8 @@ cdef class FaustCoreGPU: ...@@ -536,8 +533,8 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.right_gpu(id) core.core_faust_dbl = self.core_faust_dbl.right_gpu(id)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.right(id) core.core_faust_cplx = self.core_faust_cplx.right_gpu(id)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -545,8 +542,8 @@ cdef class FaustCoreGPU: ...@@ -545,8 +542,8 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.transpose_gpu() core.core_faust_dbl = self.core_faust_dbl.transpose_gpu()
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.transpose() core.core_faust_cplx = self.core_faust_cplx.transpose_gpu()
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -554,8 +551,8 @@ cdef class FaustCoreGPU: ...@@ -554,8 +551,8 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.conjugate_gpu() core.core_faust_dbl = self.core_faust_dbl.conjugate_gpu()
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.conjugate() core.core_faust_cplx = self.core_faust_cplx.conjugate_gpu()
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -565,10 +562,10 @@ cdef class FaustCoreGPU: ...@@ -565,10 +562,10 @@ cdef class FaustCoreGPU:
core.core_faust_dbl = self.core_faust_dbl.zpruneout_gpu(nnz_tres, core.core_faust_dbl = self.core_faust_dbl.zpruneout_gpu(nnz_tres,
npasses, npasses,
only_forward) only_forward)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.zpruneout(nnz_tres, core.core_faust_cplx = self.core_faust_cplx.zpruneout_gpu(nnz_tres,
# npasses, npasses,
# only_forward) only_forward)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -576,8 +573,8 @@ cdef class FaustCoreGPU: ...@@ -576,8 +573,8 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.adjoint_gpu() core.core_faust_dbl = self.core_faust_dbl.adjoint_gpu()
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.adjoint() core.core_faust_cplx = self.core_faust_cplx.adjoint_gpu()
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -587,23 +584,23 @@ cdef class FaustCoreGPU: ...@@ -587,23 +584,23 @@ cdef class FaustCoreGPU:
if(dev.startswith('gpu')): if(dev.startswith('gpu')):
if(self._isReal): if(self._isReal):
core_gpu.core_faust_dbl = self.core_faust_dbl.clone_gpu() core_gpu.core_faust_dbl = self.core_faust_dbl.clone_gpu()
# else: else:
# core_gpu.core_faust_cplx = self.core_faust_cplx.clone_gpu() core_gpu.core_faust_cplx = self.core_faust_cplx.clone_gpu()
core_gpu._isReal = self._isReal core_gpu._isReal = self._isReal
return core_gpu return core_gpu
elif(dev == 'cpu'): elif(dev == 'cpu'):
if(self._isReal): if(self._isReal):
core_cpu.core_faust_dbl = self.core_faust_dbl.clone_cpu() core_cpu.core_faust_dbl = self.core_faust_dbl.clone_cpu()
core_cpu._isReal = self._isReal core_cpu._isReal = self._isReal
# else: else:
# core_cpu.core_faust_cplx = self.core_faust_cplx.clone_cpu() core_cpu.core_faust_cplx = self.core_faust_cplx.clone_cpu()
return core_cpu return core_cpu
else: else:
raise ValueError('dev='+str(dev)+' is not a valid device') raise ValueError('dev='+str(dev)+' is not a valid device')
def vertcat(self,F): def vertcat(self,F):
# if(F.isReal() and not self.isReal()): if(F.isReal() and not self.isReal()):
# return self._vertcat((<FaustCore?>F)._ascomplex()) return self._vertcat((<FaustCoreGPU?>F)._ascomplex())
return self._vertcat(F) return self._vertcat(F)
cdef _horzcat(self, F): cdef _horzcat(self, F):
...@@ -611,60 +608,62 @@ cdef class FaustCoreGPU: ...@@ -611,60 +608,62 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
#TODO/ F must be a FaustCore #TODO/ F must be a FaustCore
if(self._isReal): if(self._isReal):
# if(not F.isReal()): if(not F.isReal()):
# self = self._ascomplex() self = self._ascomplex()
# core.core_faust_cplx = self.core_faust_cplx.horzcat((<FaustCore?>F).core_faust_cplx) core.core_faust_cplx = \
# else: self.core_faust_cplx.horzcat_gpu((<FaustCoreGPU?>F).core_faust_cplx)
core.core_faust_dbl = \ else:
self.core_faust_dbl.horzcat_gpu((<FaustCoreGPU?>F).core_faust_dbl) core.core_faust_dbl = \
# else: self.core_faust_dbl.horzcat_gpu((<FaustCoreGPU?>F).core_faust_dbl)
# core.core_faust_cplx = \ else:
# self.core_faust_cplx.horzcat((<FaustCore?>F).core_faust_cplx) core.core_faust_cplx = \
self.core_faust_cplx.horzcat_gpu((<FaustCoreGPU?>F).core_faust_cplx)
core._isReal = core.core_faust_dbl != NULL core._isReal = core.core_faust_dbl != NULL
return core return core
def horzcat(self,F): def horzcat(self,F):
# if(F.isReal() and not self.isReal()): if(F.isReal() and not self.isReal()):
# return self._horzcat((<FaustCore?>F)._ascomplex()) return self._horzcat((<FaustCoreGPU?>F)._ascomplex())
return self._horzcat(F) return self._horzcat(F)
cdef _vertcat(self, F): cdef _vertcat(self, F):
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
#TODO/ F must be a FaustCore #TODO/ F must be a FaustCore
if(self._isReal): if(self._isReal):
# if(not F.isReal()): if(not F.isReal()):
# self = self._ascomplex() self = self._ascomplex()
# core.core_faust_cplx = self.core_faust_cplx.vertcat((<FaustCore?>F).core_faust_cplx) core.core_faust_cplx = \
# else: self.core_faust_cplx.vertcat_gpu((<FaustCoreGPU?>F).core_faust_cplx)
core.core_faust_dbl = \ else:
self.core_faust_dbl.vertcat_gpu((<FaustCoreGPU?>F).core_faust_dbl) core.core_faust_dbl = \
# else: self.core_faust_dbl.vertcat_gpu((<FaustCoreGPU?>F).core_faust_dbl)
# core.core_faust_cplx = \ else:
# self.core_faust_cplx.vertcat((<FaustCore?>F).core_faust_cplx) core.core_faust_cplx = \
self.core_faust_cplx.vertcat_gpu((<FaustCoreGPU?>F).core_faust_cplx)
core._isReal = core.core_faust_dbl != NULL core._isReal = core.core_faust_dbl != NULL
return core return core
cdef _vertcatn(self, Fs): cdef _vertcatn(self, Fs):
cdef FaustCoreCy.FaustCoreCppGPU[double]** _Fs cdef FaustCoreCy.FaustCoreCppGPU[double]** _Fs
# cdef FaustCoreCy.FaustCoreCppGPU[complex]** _Fs_cplx cdef FaustCoreCy.FaustCoreCppGPU[complex]** _Fs_cplx
if self.isReal(): if self.isReal():
_Fs = <FaustCoreCy.FaustCoreCppGPU[double]**> PyMem_Malloc(sizeof(void*) * _Fs = <FaustCoreCy.FaustCoreCppGPU[double]**> PyMem_Malloc(sizeof(void*) *
len(Fs)) len(Fs))
# else: else:
# _Fs_cplx = <FaustCoreCy.FaustCoreCpp[complex]**> PyMem_Malloc(sizeof(void*) * _Fs_cplx = <FaustCoreCy.FaustCoreCppGPU[complex]**> PyMem_Malloc(sizeof(void*) *
# len(Fs)) len(Fs))
for i, F in enumerate(Fs): for i, F in enumerate(Fs):
if F.isReal(): if F.isReal():
_Fs[i] = (<FaustCoreGPU?>F).core_faust_dbl _Fs[i] = (<FaustCoreGPU?>F).core_faust_dbl
# else: else:
# _Fs_cplx[i] = (<FaustCore?>F).core_faust_cplx _Fs_cplx[i] = (<FaustCoreGPU?>F).core_faust_cplx
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.vertcatn_gpu(_Fs, len(Fs)) core.core_faust_dbl = self.core_faust_dbl.vertcatn_gpu(_Fs, len(Fs))
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.vertcatn_gpu(_Fs_cplx, core.core_faust_cplx = self.core_faust_cplx.vertcatn_gpu(_Fs_cplx,
# len(Fs)) len(Fs))
core._isReal = core.core_faust_dbl != NULL core._isReal = core.core_faust_dbl != NULL
return core return core
...@@ -676,35 +675,35 @@ cdef class FaustCoreGPU: ...@@ -676,35 +675,35 @@ cdef class FaustCoreGPU:
any_complex = not args[i].isReal() any_complex = not args[i].isReal()
i+=1 i+=1
for F in args: for F in args:
# if F.isReal() and any_complex: if F.isReal() and any_complex:
# F = (<FaustCore?>F)._ascomplex() F = (<FaustCoreGPU?>F)._ascomplex()
Fs += [F] Fs += [F]
# if any_complex and self.isReal(): if any_complex and self.isReal():
# self = (<FaustCore?>self)._ascomplex() self = (<FaustCoreGPU?>self)._ascomplex()
return self._vertcatn(Fs) return self._vertcatn(Fs)
cdef _horzcatn(self, Fs): cdef _horzcatn(self, Fs):
cdef FaustCoreCy.FaustCoreCppGPU[double]** _Fs cdef FaustCoreCy.FaustCoreCppGPU[double]** _Fs
# cdef FaustCoreCy.FaustCoreCpp[complex]** _Fs_cplx cdef FaustCoreCy.FaustCoreCppGPU[complex]** _Fs_cplx
if self.isReal(): if self.isReal():
_Fs = <FaustCoreCy.FaustCoreCppGPU[double]**> PyMem_Malloc(sizeof(void*) * _Fs = <FaustCoreCy.FaustCoreCppGPU[double]**> PyMem_Malloc(sizeof(void*) *
len(Fs)) len(Fs))
# else: else:
# _Fs_cplx = <FaustCoreCy.FaustCoreCpp[complex]**> PyMem_Malloc(sizeof(void*) * _Fs_cplx = <FaustCoreCy.FaustCoreCppGPU[complex]**> PyMem_Malloc(sizeof(void*) *
# len(Fs)) len(Fs))
for i, F in enumerate(Fs): for i, F in enumerate(Fs):
if F.isReal(): if F.isReal():
_Fs[i] = (<FaustCoreGPU?>F).core_faust_dbl _Fs[i] = (<FaustCoreGPU?>F).core_faust_dbl
# else: else:
# _Fs_cplx[i] = (<FaustCore?>F).core_faust_cplx _Fs_cplx[i] = (<FaustCoreGPU?>F).core_faust_cplx
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
# print("self.isReal():", self.isReal()) # print("self.isReal():", self.isReal())
if self.isReal(): if self.isReal():
core.core_faust_dbl = self.core_faust_dbl.horzcatn_gpu(_Fs, len(Fs)) core.core_faust_dbl = self.core_faust_dbl.horzcatn_gpu(_Fs, len(Fs))
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.horzcatn_gpu(_Fs_cplx, core.core_faust_cplx = self.core_faust_cplx.horzcatn_gpu(_Fs_cplx,
# len(Fs)) len(Fs))
core._isReal = core.core_faust_dbl != NULL core._isReal = core.core_faust_dbl != NULL
return core return core
...@@ -717,20 +716,20 @@ cdef class FaustCoreGPU: ...@@ -717,20 +716,20 @@ cdef class FaustCoreGPU:
any_complex = not args[i].isReal() any_complex = not args[i].isReal()
i+=1 i+=1
for F in args: for F in args:
# if F.isReal() and any_complex: if F.isReal() and any_complex:
# F = (<FaustCore?>F)._ascomplex() F = (<FaustCoreGPU?>F)._ascomplex()
Fs += [F] Fs += [F]
# print("any_complex:", any_complex) # print("any_complex:", any_complex)
# if any_complex and self.isReal(): if any_complex and self.isReal():
# self = (<FaustCore?>self)._ascomplex() self = (<FaustCoreGPU?>self)._ascomplex()
return self._horzcatn(Fs) return self._horzcatn(Fs)
def device(self): def device(self):
cdef char c_str[256] cdef char c_str[256]
if(self._isReal): if(self._isReal):
self.core_faust_dbl.device_gpu(c_str) self.core_faust_dbl.device_gpu(c_str)
# else: else:
# self.core_faust_cplx.device_gpu(c_str) self.core_faust_cplx.device_gpu(c_str)
cdef length = strlen(c_str) cdef length = strlen(c_str)
#printf("%s", c_str[:length]) #printf("%s", c_str[:length])
#py_str = str(c_str[:length], 'UTF-8') #py_str = str(c_str[:length], 'UTF-8')
...@@ -749,11 +748,11 @@ cdef class FaustCoreGPU: ...@@ -749,11 +748,11 @@ cdef class FaustCoreGPU:
end_row_id, end_row_id,
start_col_id, start_col_id,
end_col_id) end_col_id)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.slice_gpu(start_row_id, core.core_faust_cplx = self.core_faust_cplx.slice_gpu(start_row_id,
# end_row_id, end_row_id,
# start_col_id, start_col_id,
# end_col_id) end_col_id)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -788,13 +787,13 @@ cdef class FaustCoreGPU: ...@@ -788,13 +787,13 @@ cdef class FaustCoreGPU:
core.core_faust_dbl = \ core.core_faust_dbl = \
self.core_faust_dbl.fancy_idx_gpu(&row_indices_view[0], row_indices.size, self.core_faust_dbl.fancy_idx_gpu(&row_indices_view[0], row_indices.size,
&col_indices_view[0], col_indices.size) &col_indices_view[0], col_indices.size)
# else: else:
# core.core_faust_cplx = \ core.core_faust_cplx = \
# self.core_faust_cplx.fancy_idx(&row_indices_view[0], self.core_faust_cplx.fancy_idx_gpu(&row_indices_view[0],
# row_indices.size, row_indices.size,
# &col_indices_view[0], &col_indices_view[0],
# col_indices.size) col_indices.size)
#
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -807,8 +806,8 @@ cdef class FaustCoreGPU: ...@@ -807,8 +806,8 @@ cdef class FaustCoreGPU:
cfilepath[i+1] = 0 cfilepath[i+1] = 0
if(self._isReal): if(self._isReal):
ret = self.core_faust_dbl.save_mat_file(cfilepath) ret = self.core_faust_dbl.save_mat_file(cfilepath)
# else: else:
# ret = self.core_faust_cplx.save_mat_file(cfilepath) ret = self.core_faust_cplx.save_mat_file(cfilepath)
if(not ret): if(not ret):
raise Exception("Failed to save the file: "+filepath) raise Exception("Failed to save the file: "+filepath)
PyMem_Free(cfilepath) PyMem_Free(cfilepath)
...@@ -842,28 +841,28 @@ cdef class FaustCoreGPU: ...@@ -842,28 +841,28 @@ cdef class FaustCoreGPU:
else: else:
raise("x must be real if Faust is.") raise("x must be real if Faust is.")
# shouldn't happen normally (avoided by calling function) # shouldn't happen normally (avoided by calling function)
# else: else:
# x_data_cplx = X.data x_data_cplx = X.data
# nbrow = self.core_faust_cplx.getNbRow() nbrow = self.core_faust_cplx.getNbRow()
# if(self.core_faust_cplx.getNbCol() != X.shape[0]): raise e if(self.core_faust_cplx.getNbCol() != X.shape[0]): raise e
# y_data_arr = np.empty((nbrow,nbcol), dtype=np.complex, order='F') # we don't know beforehand Y nnz y_data_arr = np.empty((nbrow,nbcol), dtype=np.complex, order='F') # we don't know beforehand Y nnz
# y_data_cplx = y_data_arr y_data_cplx = y_data_arr
# if(not self._isReal): if(not self._isReal):
# self.core_faust_cplx.multiply_gpu(&y_data_cplx[0,0], nbrow, nbcol, self.core_faust_cplx.multiply_gpu(&y_data_cplx[0,0], nbrow, nbcol,
# &x_data_cplx[0], &x_indptr[0], &x_data_cplx[0], &x_indptr[0],
# &x_indices[0], &x_indices[0],
# x_nnz, X.shape[0], X.shape[1]) x_nnz, X.shape[0], X.shape[1])
# else: else:
# raise("x must be complex if Faust is") raise("x must be complex if Faust is")
# # shouldn't happen normally (avoided by calling function) # shouldn't happen normally (avoided by calling function)
return y_data_arr return y_data_arr
def optimize_storage(self, time=False): def optimize_storage(self, time=False):
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.optimize_storage_gpu(time) core.core_faust_dbl = self.core_faust_dbl.optimize_storage_gpu(time)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.optimize_storage_gpu(time) core.core_faust_cplx = self.core_faust_cplx.optimize_storage_gpu(time)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -871,8 +870,8 @@ cdef class FaustCoreGPU: ...@@ -871,8 +870,8 @@ cdef class FaustCoreGPU:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.optimize_gpu(transp) core.core_faust_dbl = self.core_faust_dbl.optimize_gpu(transp)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.optimize_gpu(transp) core.core_faust_cplx = self.core_faust_cplx.optimize_gpu(transp)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
...@@ -880,18 +879,18 @@ cdef class FaustCoreGPU: ...@@ -880,18 +879,18 @@ cdef class FaustCoreGPU:
if(inplace): if(inplace):
if(self._isReal): if(self._isReal):
self.core_faust_dbl.optimize_time_gpu(transp, inplace, nsamples) self.core_faust_dbl.optimize_time_gpu(transp, inplace, nsamples)
# else: else:
# self.core_faust_cplx.optimize_time(transp, inplace, nsamples) self.core_faust_cplx.optimize_time(transp, inplace, nsamples)
else: else:
core = FaustCoreGPU(core=True) core = FaustCoreGPU(core=True)
if(self._isReal): if(self._isReal):
core.core_faust_dbl = self.core_faust_dbl.optimize_time_gpu(transp, core.core_faust_dbl = self.core_faust_dbl.optimize_time_gpu(transp,
inplace, inplace,
nsamples) nsamples)
# else: else:
# core.core_faust_cplx = self.core_faust_cplx.optimize_time(transp, core.core_faust_cplx = self.core_faust_cplx.optimize_time_gpu(transp,
# inplace, inplace,
# nsamples) nsamples)
core._isReal = self._isReal core._isReal = self._isReal
return core return core
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment