NnmfPack  2.1
bdiv_mic.c
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2014 by PIR (University of Oviedo) and *
3  * INCO2 (Polytechnic University of Valencia) groups. *
4  * nnmfpack@gmail.com *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20  ***************************************************************************
21 */
33 #include "bdiv_mic.h"
34 
35 
88 int dbdivg_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const double expo, const int uType, const int nIter)
89 {
90  int error=0;
91 
92  #ifdef With_MICOffload
93  #pragma offload target(mic:0) \
94  in(m,n,k,expo,nIter) \
95  in(A:length(m*n)) \
96  inout(W:length(m*k)) \
97  inout(H:length(k*n)) \
98  inout(error)
99  {
100  #else
101  mkl_mic_enable();
102  #endif
103 
104  error = dbdivg_cpu(m, n, k, A, W, H, expo, uType, nIter);
105 
106  #ifdef With_MICOffload
107  }
108  #endif
109 
110  return error;
111 }
112 
113 
128 int sbdivg_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const float expo, const int uType, const int nIter)
129 {
130  int error=0;
131 
132  #ifdef With_MICOffload
133  #pragma offload target(mic:0) \
134  in(m,n,k,expo,nIter) \
135  in(A:length(m*n)) \
136  inout(W:length(m*k)) \
137  inout(H:length(k*n)) \
138  inout(error)
139  {
140  #else
141  mkl_mic_enable();
142  #endif
143 
144  error = sbdivg_cpu(m, n, k, A, W, H, expo, uType, nIter);
145 
146  #ifdef With_MICOffload
147  }
148  #endif
149 
150  return error;
151 }
152 
153 
154 
155 
156 
195 int dbdivone_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const int uType, const int nIter)
196 {
197  int error=0;
198 
199  #ifdef With_MICOffload
200  #pragma offload target(mic:0) \
201  in(m,n,k,nIter) \
202  in(A:length(m*n)) \
203  inout(W:length(m*k)) \
204  inout(H:length(k*n)) \
205  inout(error)
206  {
207  #else
208  mkl_mic_enable();
209  #endif
210 
211  error = dbdivone_cpu(m, n, k, A, W, H, uType, nIter);
212 
213  #ifdef With_MICOffload
214  }
215  #endif
216 
217  return error;
218 }
219 
220 
234 int sbdivone_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const int uType, const int nIter)
235 {
236  int error=0;
237 
238  #ifdef With_MICOffload
239  #pragma offload target(mic:0) \
240  in(m,n,k,nIter) \
241  in(A:length(m*n)) \
242  inout(W:length(m*k)) \
243  inout(H:length(k*n)) \
244  inout(error)
245  {
246  #else
247  mkl_mic_enable();
248  #endif
249 
250  error = sbdivone_cpu(m, n, k, A, W, H, uType, nIter);
251 
252  #ifdef With_MICOffload
253  }
254  #endif
255 
256  return error;
257 }
258 
259 
274 int dbdiv_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const double beta, const int uType, const int nIter)
275 {
276  if ((beta < 0.0) || (nIter <= 0))
277  return -1;
278 
279  if(beta>=2.0 && beta<=2.0)
280  return dmlsa_mic(m, n, k, A, W, H, uType, nIter);
281  else
282  {
283  if(beta>=1.0 && beta<=1.0)
284  return dbdivone_mic(m, n, k, A, W, H, uType, nIter);
285  else
286  return dbdivg_mic(m, n, k, A, W, H, beta, uType, nIter);
287  }
288 }
289 
290 
304 int sbdiv_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const float beta, const int uType, const int nIter)
305 {
306  if ((beta < 0.0) || (nIter <= 0))
307  return -1;
308 
309  if(beta>=2.0 && beta<=2.0)
310  return smlsa_mic(m, n, k, A, W, H, uType, nIter);
311  else
312  {
313  if(beta>=1.0 && beta<=1.0)
314  return sbdivone_mic(m, n, k, A, W, H, uType, nIter);
315  else
316  return sbdivg_mic(m, n, k, A, W, H, beta, uType, nIter);
317  }
318 }
int sbdivg_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const float expo, const int uType, const int nIter)
sbdivg_mic performs NNMF using betadivergence for general case (beta <> 1 and 2) using simple precisi...
Definition: bdiv_mic.c:128
Header file for using the betadivergence functions with MIC/MIC.
int sbdiv_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const float beta, const int uType, const int nIter)
Definition: bdiv_mic.c:304
int dbdivg_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const double expo, const int uType, const int nIter)
dbdivg_mic performs the NNMF using beta-divergence when beta is != 1 and !=2, using double precision ...
Definition: bdiv_mic.c:88
int smlsa_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const int uType, const int nIter)
smlsa_mic performs NNMF using betadivergence when beta=2 using simple precision
Definition: mlsa_mic.c:111
int dbdivone_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const int uType, const int nIter)
dbdivone_mic performs NNMF using betadivergence when beta=1 using double precision ...
Definition: bdiv_mic.c:195
int dbdivone_cpu(const int m, const int n, const int k, const double *A, double *W, double *H, const int uType, const int nIter)
dbdivone_cpu performs NNMF using beta-divergence when beta=1, using double precision ...
Definition: bdiv_cpu.c:566
int sbdivg_cpu(const int m, const int n, const int k, const float *A, float *W, float *H, const float expo, const int uType, int nIter)
sbdivg_cpu performs NNMF using betadivergence for general case (beta <> 1 and 2) using simple precisi...
Definition: bdiv_cpu.c:313
int dbdivg_cpu(const int m, const int n, const int k, const double *A, double *W, double *H, const double expo, const int uType, int nIter)
dbdivg_cpu performs the NNMF using beta-divergence when beta is != 1 and !=2, using double precision...
Definition: bdiv_cpu.c:87
int sbdivone_mic(const int m, const int n, const int k, const float *A, float *W, float *H, const int uType, const int nIter)
sbdivone_mic performs NNMF using betadivergence when beta=1 using simple precision ...
Definition: bdiv_mic.c:234
int dbdiv_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const double beta, const int uType, const int nIter)
dbdiv_mic is a wrapper that calls the adequate function to performs NNMF using betadivergence using d...
Definition: bdiv_mic.c:274
int sbdivone_cpu(const int m, const int n, const int k, const float *A, float *W, float *H, const int uType, const int nIter)
sbdivone_cpu performs NNMF using betadivergence when beta=1 using simple precision ...
Definition: bdiv_cpu.c:813
int dmlsa_mic(const int m, const int n, const int k, const double *A, double *W, double *H, const int uType, const int nIter)
dmlsa_mic performs NNMF using betadivergence when beta=2 using double precision
Definition: mlsa_mic.c:72