[Genabel-commits] r1862 - pkg/OmicABELnoMM/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Oct 28 12:05:44 CET 2014
Author: afrank
Date: 2014-10-28 12:05:43 +0100 (Tue, 28 Oct 2014)
New Revision: 1862
Modified:
pkg/OmicABELnoMM/src/AIOwrapper.cpp
pkg/OmicABELnoMM/src/AIOwrapper.h
pkg/OmicABELnoMM/src/Algorithm.cpp
pkg/OmicABELnoMM/src/Algorithm.h
pkg/OmicABELnoMM/src/Utility.cpp
pkg/OmicABELnoMM/src/Utility.h
Log:
More cleanup. Fixed all reasonable CPPCHECK errors, warnings.
Modified: pkg/OmicABELnoMM/src/AIOwrapper.cpp
===================================================================
--- pkg/OmicABELnoMM/src/AIOwrapper.cpp 2014-10-28 10:20:35 UTC (rev 1861)
+++ pkg/OmicABELnoMM/src/AIOwrapper.cpp 2014-10-28 11:05:43 UTC (rev 1862)
@@ -72,7 +72,7 @@
ARfvi = load_databel_fvi( (Fhandler->fnameAR+".fvi").c_str() );
if(ALfvi->fvi_header.numObservations != ARfvi->fvi_header.numObservations && ARfvi->fvi_header.numObservations != Yfvi->fvi_header.numObservations
- && ARfvi->fvi_header.numObservations != Yfvi->fvi_header.numObservations )
+ && ALfvi->fvi_header.numObservations != Yfvi->fvi_header.numObservations )
{
cout << "The number of elements/individuals from the input files do not coincide with each other! See:" << endl;
cout << Fhandler->fnameY << ":" << Yfvi->fvi_header.numObservations << endl;
@@ -136,8 +136,8 @@
string YidNames;
string ALidName;
string ARidName;
- string INTidName;
+
int yname_idx=0;//starting idx for names on ALfvi->data
for(int i = 0; i < params.n; i++)
{
@@ -772,10 +772,18 @@
}
+ free_databel_fvi(&Yfvi);
+ free_databel_fvi(&ALfvi);
+ free_databel_fvi(&ARfvi);
+ if( Fhandler->use_interactions)
+ {
+ free_databel_fvi(&Ifvi);
+ }
+
}
@@ -1750,48 +1758,7 @@
-void AIOwrapper::reset_Y()
-{
- //void *status;
- Fhandler->seed = 1337;
-
- cout << "ry" << flush;
-
- Fhandler->reset_wait = true;
- pthread_barrier_wait(&(Fhandler->finalize_barrier));
-
- pthread_mutex_lock(&(Fhandler->m_buff_upd));
- Fhandler->y_to_readSize = Fhandler->Y_Amount;
-
- if(Fhandler->currentReadBuff)
- {
- Fhandler->full_buffers.push(Fhandler->currentReadBuff);
- Fhandler->currentReadBuff=0;
- }
-
- while(!Fhandler->full_buffers.empty())
- {
- Fhandler->empty_buffers.push(Fhandler->full_buffers.front());
- for( int i = 0; i < Fhandler->n*Fhandler->y_blockSize; i++)
- {
- ((Fhandler->full_buffers.front())->buff)[i] = 0;
- }
- Fhandler->full_buffers.pop();
- }
- pthread_mutex_unlock(&(Fhandler->m_buff_upd));
-
- Fhandler->reset_wait = false;
-
- pthread_barrier_wait(&(Fhandler->finalize_barrier));
-
- pthread_mutex_lock(&(Fhandler->m_more));
- pthread_cond_signal( &(Fhandler->condition_more ));
- pthread_mutex_unlock(&(Fhandler->m_more));
-
-
-}
-
void AIOwrapper::reset_AR()
{
Modified: pkg/OmicABELnoMM/src/AIOwrapper.h
===================================================================
--- pkg/OmicABELnoMM/src/AIOwrapper.h 2014-10-28 10:20:35 UTC (rev 1861)
+++ pkg/OmicABELnoMM/src/AIOwrapper.h 2014-10-28 11:05:43 UTC (rev 1862)
@@ -188,7 +188,7 @@
void load_AL(type_precision** AL);
void load_ARblock(type_precision** Y, int &blockSize);
void load_Yblock(type_precision** Y, int &blockSize);
- void reset_Y();
+
void reset_AR();
void getCurrentWriteBuffers(list < resultH >* &sigResults);
Modified: pkg/OmicABELnoMM/src/Algorithm.cpp
===================================================================
--- pkg/OmicABELnoMM/src/Algorithm.cpp 2014-10-28 10:20:35 UTC (rev 1861)
+++ pkg/OmicABELnoMM/src/Algorithm.cpp 2014-10-28 11:05:43 UTC (rev 1862)
@@ -29,32 +29,8 @@
}
-void Algorithm::extract_subMatrix(float* source, float* dest,
- int dim1_source, int dim2_source,
- int dim1_ini, int dim1_end, int dim2_ini,
- int dim2_end)
-{
- int i, j, idx = 0;
- int size, source_ini;
- for (i = dim2_ini; i < dim2_end; i++)
- {
- j = dim1_ini;
- source_ini = i * dim1_source+j;
- size = dim1_end - dim1_ini;
- memcpy( (float*)&dest[idx],
- (float*)&source[source_ini],
- size * sizeof(float) );
-// for (j = dim1_ini; j<dim1_end; j++)
-// {
-// dest[idx] = source[i*dim1_source+j];
-// idx++;
-// }
- idx += size;
- }
-}
-
void Algorithm::prepare_QY(float* qy, float* top,
float* bot, int dim1_QY,
int dim2_QY, int dim1_qy_bot, int bot_blocks )
@@ -81,76 +57,7 @@
}
-float* Algorithm::extract_R(float* A, int dim1_A, int dim2_A)
-{
- float* R = (float*)calloc(dim2_A * dim2_A,
- sizeof(float));
- int i, j;
- int R_idx = 0;
-
- for (i = 0; i < dim2_A; i++)
- {
- for (j = 0; j <= i; j++)
- {
- R[R_idx] = A[j + i * dim1_A];
- R_idx++;
- }
- R_idx = dim2_A * (i+1);
- }
- return R;
-}
-
-
-float* Algorithm::prepare_R(float* RL, int dim1_A,
- int dim2_AL, int dim2_AR)
-{
- int R_dim = (dim2_AR + dim2_AL);
- float* R = new float[R_dim * R_dim];
-
- int i, j;
-
- int RL_idx = 0;
- int R_idx = 0;
-
- for (i = 0; i < dim2_AL; i++)
- {
- for (j = 0; j <= i; j++)
- {
- RL_idx = i * dim1_A + j;
- R_idx = i * R_dim + j;
- R[R_idx] = RL[RL_idx];
- }
- }
- return R;
-}
-
-
-void Algorithm::update_R(float* R, float* topRr,
- float* botRr, int dim1, int dim2, int r)
-{
- int i, j, w;
- int max = dim1 * dim2;
- int rtr_idx = 0;
- int rbr_idx = 0;
- for (j = r; j > 0; j--)
- {
- for (i = max - dim1 * j; i < max - dim1 * j + dim2 - r; i++)
- {
- R[i] = topRr[rtr_idx];
- rtr_idx++;
- }
- w = i;
-
- for (i = w; i < w + r; i++)
- {
- R[i] = botRr[rbr_idx];
- rbr_idx++;
- }
- }
-}
-
-
void Algorithm::build_S(float* S, float* Stl,
float* Str, float* Sbr, int l, int r)
{
@@ -507,17 +414,17 @@
float* Ay_top = new float[l * y_amount];
float* Ay_bot = new float[y_block_size * a_block_size * r];
- float* y_residual = new float[n * y_block_size ];
- float* y_res_norms = new float[a_block_size];
+ //float* y_residual = new float[n * y_block_size ];
+ //float* y_res_norms = new float[a_block_size];
//list<long int>* al_nan_idxs = new list<long int>[l];
list<long int>* y_nan_idxs = new list<long int>[y_block_size];
list<long int>* ar_nan_idxs = new list<long int>[a_block_size*r];
int* Ymiss=new int[y_block_size];
- std::map <int , list < int > > y_missings_jj;
+
float* A = new float[n * p * 1];
float* AR;// = new float[n * r * a_block_size * 1];
@@ -940,8 +847,8 @@
//delete []S;
delete []y_nan_idxs;
delete []ar_nan_idxs;
- delete []y_residual;
- delete []y_res_norms;
+
+
delete []Stl_corr;
delete []Str_corr;
delete []Sbr_corr;
Modified: pkg/OmicABELnoMM/src/Algorithm.h
===================================================================
--- pkg/OmicABELnoMM/src/Algorithm.h 2014-10-28 10:20:35 UTC (rev 1861)
+++ pkg/OmicABELnoMM/src/Algorithm.h 2014-10-28 11:05:43 UTC (rev 1862)
@@ -109,22 +109,14 @@
int iX, int iiX, int jY, int jjY);
- void update_R(float* R, float* topRr, float* botRr,
- int dim1, int dim2, int r);
- float* extract_R(float* A, int dim1_A, int dim2_A);
-
- float* prepare_R(float* RL, int dim1_A, int dim2_AL, int dim2_AR);
-
void prepare_QY(float* qy, float* top, float* bot, int dim1_QY,
int dim2_QY, int dim1_qy_bot, int bot_blocks);
void prepare_Bfinal(float* bfinal, float* bsource, int a_amount,
int y_amount, int p);
- void extract_subMatrix(float* source, float* dest, int dim1_source,
- int dim2_source, int dim1_ini, int dim1_end,
- int dim2_ini, int dim2_end);
+
void build_S(float* S, float* Stl, float* Str, float* Sbr, int l, int r);
Modified: pkg/OmicABELnoMM/src/Utility.cpp
===================================================================
--- pkg/OmicABELnoMM/src/Utility.cpp 2014-10-28 10:20:35 UTC (rev 1861)
+++ pkg/OmicABELnoMM/src/Utility.cpp 2014-10-28 11:05:43 UTC (rev 1862)
@@ -28,9 +28,45 @@
}
+void cpu_benchmark(int n, int samples, double &duration, double &GFLOPS)
+{
+ type_precision* A = new type_precision[n * n];
+ type_precision* B = new type_precision[n * n];
+ type_precision* C = new type_precision[n * n];
+ cputime_type start_tick, end_tick;
+ duration = 9999999999.0;
+ int b = 0;
+ for (int i = 0; i < samples; i++)
+ {
+ re_random_vec(A, n*n);
+ re_random_vec(B, n*n);
+ re_random_vec(C, n*n);
+ get_ticks(start_tick);
+ cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, n, n, n,
+ 1.0, A, n, B, n, 1.0, C, n);
+ get_ticks(end_tick);
+ duration = min(duration, (double)(ticks2sec(end_tick, start_tick)));
+ int a = 0;
+ for (int j = 0; j < n * n ; j++)
+ {
+ a += A[j] + B[j] + C[j];
+ }
+ b += a;
+ }
+ //!2nnn - nn + 2nn (from+c)
+ GFLOPS = gemm_flops(n, n, n, 0);
+
+ cout << b;
+
+ delete []A;
+ delete []B;
+ delete []C;
+}
+
+
void re_random_vec(type_precision* vec, int size)
{
for (int i = 0; i < size; i++)
Modified: pkg/OmicABELnoMM/src/Utility.h
===================================================================
--- pkg/OmicABELnoMM/src/Utility.h 2014-10-28 10:20:35 UTC (rev 1861)
+++ pkg/OmicABELnoMM/src/Utility.h 2014-10-28 11:05:43 UTC (rev 1862)
@@ -16,6 +16,8 @@
type_precision* random_vec(int size);
void re_random_vec(type_precision* vec, int size);
+void cpu_benchmark(int n, int samples, double &duration, double &GFLOPS);
+
inline void copy_vec(type_precision*old, type_precision* new_vec, int size)
{
memcpy( (type_precision*)new_vec,
More information about the Genabel-commits
mailing list