[Genabel-commits] r1831 - in pkg/OmicABELnoMM: . src tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 23 16:10:02 CEST 2014
Author: afrank
Date: 2014-09-23 16:10:02 +0200 (Tue, 23 Sep 2014)
New Revision: 1831
Modified:
pkg/OmicABELnoMM/configure.ac
pkg/OmicABELnoMM/src/AIOwrapper.cpp
pkg/OmicABELnoMM/src/AIOwrapper.h
pkg/OmicABELnoMM/src/Algorithm.cpp
pkg/OmicABELnoMM/src/Definitions.h
pkg/OmicABELnoMM/tests/test.cpp
Log:
Fixed compilation error introduced by SVN. Some performance improvements.
Modified: pkg/OmicABELnoMM/configure.ac
===================================================================
--- pkg/OmicABELnoMM/configure.ac 2014-09-23 10:32:30 UTC (rev 1830)
+++ pkg/OmicABELnoMM/configure.ac 2014-09-23 14:10:02 UTC (rev 1831)
@@ -18,13 +18,10 @@
# Set some default compile flags
if test -z "$CXXFLAGS"; then
# User did not set CXXFLAGS, so we can put in our own defaults
-<<<<<<< .mine
+
CXXFLAGS=" -O3 -std=c++11 -march=native -mfpmath=sse -flto -funroll-loops"
#CXXFLAGS="-g -ggdb -std=c++11"
-=======
- CXXFLAGS=" -O3 -march=corei7 -mfpmath=sse -mtune=corei7 -flto -funroll-loops"
- #CXXFLAGS="-g -ggdb"
->>>>>>> .r1828
+
fi
if test -z "$CPPFLAGS"; then
# User did not set CPPFLAGS, so we can put in our own defaults
Modified: pkg/OmicABELnoMM/src/AIOwrapper.cpp
===================================================================
--- pkg/OmicABELnoMM/src/AIOwrapper.cpp 2014-09-23 10:32:30 UTC (rev 1830)
+++ pkg/OmicABELnoMM/src/AIOwrapper.cpp 2014-09-23 14:10:02 UTC (rev 1831)
@@ -1,33 +1,34 @@
-#include "AIOwrapper.h"
-
-
-
-AIOwrapper::AIOwrapper()
-{
- Fhandler = &FHandler;
- io_overhead = "*";
-}
-
-AIOwrapper::~AIOwrapper()
-{
-
-}
-
-
-void AIOwrapper::initialize(struct Settings ¶ms)
-{
-
-
- pthread_mutex_init( &(FHandler.m_more), NULL);
- pthread_mutex_init( &(FHandler.m_read), NULL);
- pthread_mutex_init( &(FHandler.m_buff_upd), NULL);
-
- pthread_cond_init(&(FHandler.condition_more), NULL);
- pthread_cond_init(&(FHandler.condition_read), NULL);
-
- pthread_barrier_init(&(FHandler.finalize_barrier),NULL,2);
-
-
+#include "AIOwrapper.h"
+
+
+
+AIOwrapper::AIOwrapper()
+{
+ Fhandler = &FHandler;
+ io_overhead = "*";
+}
+
+AIOwrapper::~AIOwrapper()
+{
+
+}
+
+
+void AIOwrapper::initialize(struct Settings ¶ms)
+{
+
+
+ pthread_mutex_init( &(FHandler.m_more), NULL);
+ pthread_mutex_init( &(FHandler.m_read), NULL);
+ pthread_mutex_init( &(FHandler.m_buff_upd), NULL);
+ pthread_mutex_init( &(FHandler.out_buff_upd), NULL);
+
+ pthread_cond_init(&(FHandler.condition_more), NULL);
+ pthread_cond_init(&(FHandler.condition_read), NULL);
+
+ pthread_barrier_init(&(FHandler.finalize_barrier),NULL,2);
+
+
Fhandler->fakefiles = params.use_fake_files;
@@ -37,7 +38,7 @@
cout << "Requested dosages model wihtout a valid model!" << endl;
exit(1);
}
-
+
Fhandler->not_done = true;
Fhandler->model = params.model;
Fhandler->fname_dosages = params.fname_dosages;
@@ -45,13 +46,13 @@
Fhandler->fileR = 0;
Fhandler->add_dosages = false;
-
-
- if(!Fhandler->fakefiles)
- {
- Fhandler->fnameAL = params.fnameAL;
- Fhandler->fnameAR = params.fnameAR;
- Fhandler->fnameY = params.fnameY;
+
+
+ if(!Fhandler->fakefiles)
+ {
+ Fhandler->fnameAL = params.fnameAL;
+ Fhandler->fnameAR = params.fnameAR;
+ Fhandler->fnameY = params.fnameY;
Fhandler->fnameOutFiles = params.fnameOutFiles;
Fhandler->storeBin = params.storeBin;
@@ -61,10 +62,10 @@
Fhandler->min_p_disp = params.minPdisp;
Fhandler->min_R2_disp = params.minR2disp;
-
-
- Yfvi = load_databel_fvi( (Fhandler->fnameY+".fvi").c_str() );
- ALfvi = load_databel_fvi( (Fhandler->fnameAL+".fvi").c_str() );
+
+
+ Yfvi = load_databel_fvi( (Fhandler->fnameY+".fvi").c_str() );
+ ALfvi = load_databel_fvi( (Fhandler->fnameAL+".fvi").c_str() );
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
@@ -76,11 +77,11 @@
cout << Fhandler->fnameAR << ":" << ARfvi->fvi_header.numObservations << endl;
exit(1);
}
-
+
params.n = min((int)(ALfvi->fvi_header.numObservations),params.limit_n);
Fhandler->fileN = params.n;
-
+
params.m = min((int)(ARfvi->fvi_header.numVariables/params.r),params.limit_m/params.r);
#ifdef DEBUG
@@ -99,8 +100,8 @@
Fhandler->fileR = params.r;
Fhandler->modelR = Fhandler->fileR;
-
- params.t = min((int)(Yfvi->fvi_header.numVariables),params.limit_t);
+
+ params.t = min((int)(Yfvi->fvi_header.numVariables),params.limit_t);
params.l = ALfvi->fvi_header.numVariables;
int yname_idx=0;//starting idx for names on ALfvi->data
@@ -131,25 +132,25 @@
// cout << i << ": " << ALnames[i] << "\t";
}
-
-
- int opt_tb = 1000;
- int opt_mb = 100;//4WONT WORK WTF?
-
- params.mb = min(params.m, opt_mb);
+
+
+ int opt_tb = 1000;
+ int opt_mb = 100;//4WONT WORK WTF?
+
+ params.mb = min(params.m, opt_mb);
params.tb = min(params.t, opt_tb);
-
-
- }
- else
- {
- //other params come from outside
+
+
}
+ else
+ {
+ //other params come from outside
+ }
- params.mb = min(params.m,params.mb);
+ params.mb = min(params.m,params.mb);
params.tb = min(params.t,params.tb);
Fhandler->Ar_file_blocksize = params.mb;
@@ -192,7 +193,7 @@
Fhandler->modelR = 1;
- switch (Fhandler->model)
+ switch (Fhandler->model)
{
case -1://nomodel
@@ -208,7 +209,7 @@
Fhandler->dosage_skip = 1;//last columns is irrelevant
params.r = 1;
Fhandler->add_dosages = true;
- break;
+ break;
case 1://dom
if(Fhandler->fileR != 3 && Fhandler->fileR != 2)
{
@@ -348,10 +349,10 @@
ifstream fp_I;
fp_I.open ((Fhandler->fname_interactions+".fvd").c_str(), ios::in | ios::binary);
- if(!fp_I.is_open())
- {
- cout << "Error opening Interactions File " << Fhandler->fname_interactions << endl;
- exit(1);
+ if(!fp_I.is_open())
+ {
+ cout << "Error opening Interactions File " << Fhandler->fname_interactions << endl;
+ exit(1);
}
@@ -411,11 +412,11 @@
- params.n -= (excl_count + Almissings + interaction_missings);
-
+ params.n -= (excl_count + Almissings + interaction_missings);
+
params.p = params.l + params.r;
- if(!Fhandler->fakefiles)
+ if(!Fhandler->fakefiles)
{
//!******nameGATHER****************
@@ -531,11 +532,11 @@
//!write info file for results
ofstream fp_InfoResults;
- fp_InfoResults.open((Fhandler->fnameOutFiles + "_sto.ibin").c_str(),ios::out | ios::binary | ios::trunc);
- if(fp_InfoResults == 0)
- {
- cout << "Error Creating File: " << (Fhandler->fnameOutFiles + "_sto.ibin") << endl;
- exit(1);
+ fp_InfoResults.open((Fhandler->fnameOutFiles + "_sto.ibin").c_str(),ios::out | ios::binary | ios::trunc);
+ if(fp_InfoResults == 0)
+ {
+ cout << "Error Creating File: " << (Fhandler->fnameOutFiles + "_sto.ibin") << endl;
+ exit(1);
}
fp_InfoResults.write( (char*)¶ms.n,sizeof(int));
fp_InfoResults.write( (char*)¶ms.l,sizeof(int));
@@ -572,34 +573,34 @@
}
-
+
//check p < n!!!!
if(params.p >= params.n)
- {
- cout << "Error! The amount of unknows (individuals|elements) must be greater than total of variables (#covariates+#ind.variables)!" << endl;
- exit(1);
- }
-
- //block size to keep mem under 1 gigabyte
-// int opt_block = params.n/(4*1000^3)*(1/(2*params.r));
-// int opt_tb = max(4*2000,opt_block);
-// int opt_mb = max(2000,opt_block);
-//
+ {
+ cout << "Error! The amount of unknows (individuals|elements) must be greater than total of variables (#covariates+#ind.variables)!" << endl;
+ exit(1);
+ }
+
+ //block size to keep mem under 1 gigabyte
+// int opt_block = params.n/(4*1000^3)*(1/(2*params.r));
+// int opt_tb = max(4*2000,opt_block);
+// int opt_mb = max(2000,opt_block);
+//
#ifdef DEBUG
cout << "m:" << params.m << " lmb:" << params.mb << " ln:"<< params.n << " lr:" << params.r << endl ;
- #endif
-
- prepare_AL(params.l,params.n);
- prepare_AR( params.mb, params.n, Fhandler->fileM, params.r);
- prepare_OutFiles();
- prepare_Y(params.tb, params.n, params.t);
-
-
-
- //
-
-}
+ #endif
+ prepare_AL(params.l,params.n);
+ prepare_AR( params.mb, params.n, Fhandler->fileM, params.r);
+ prepare_OutFiles();
+ prepare_Y(params.tb, params.n, params.t);
+
+
+
+ //
+
+}
+
void AIOwrapper::generate_singleinteraction_multset(float* interaction_data, int cols_indp_data, float* ARorig, int ar_orig_block_size, int n, float* dest, bool keep_original )
{
int new_r = 1;
@@ -665,30 +666,30 @@
}
}
}
-
-void AIOwrapper::finalize()
-{
-
- Fhandler->not_done = false;
- pthread_mutex_lock(&(Fhandler->m_more));
- pthread_cond_signal( &(Fhandler->condition_more ));
- pthread_mutex_unlock(&(Fhandler->m_more));
-
+
+void AIOwrapper::finalize()
+{
+
+ Fhandler->not_done = false;
+ pthread_mutex_lock(&(Fhandler->m_more));
+ pthread_cond_signal( &(Fhandler->condition_more ));
+ pthread_mutex_unlock(&(Fhandler->m_more));
+
pthread_barrier_wait(&(Fhandler->finalize_barrier));
pthread_join( (Fhandler->iothread), NULL);
-
- finalize_Y();
- finalize_AR();
- finalize_AL();
- finalize_OutFiles();
-
- pthread_attr_destroy(&(Fhandler->attr));
-
- pthread_mutex_destroy(&(Fhandler->m_more));
- pthread_cond_destroy(&(Fhandler->condition_more));
-
- pthread_mutex_destroy(&(Fhandler->m_read));
+
+ finalize_Y();
+ finalize_AR();
+ finalize_AL();
+ finalize_OutFiles();
+
+ pthread_attr_destroy(&(Fhandler->attr));
+
+ pthread_mutex_destroy(&(Fhandler->m_more));
+ pthread_cond_destroy(&(Fhandler->condition_more));
+
+ pthread_mutex_destroy(&(Fhandler->m_read));
pthread_cond_destroy(&(Fhandler->condition_read));
delete Fhandler->excl_List;
@@ -700,28 +701,28 @@
-
-
-
-}
-
-
-
-void AIOwrapper::finalize_OutFiles()
-{
-
-}
-
-
-void* AIOwrapper::async_io( void *ptr )
-{
- //cout << "async_io\n" << flush;
- type_fileh* Fhandler = (type_fileh *)ptr;
- int size_buff,tmp_y_blockSize,tmp_ar_blockSize;
-
- struct timespec timeToWait;
- FILE* fp_Y;
+
+
+}
+
+
+
+
+void AIOwrapper::finalize_OutFiles()
+{
+
+}
+
+
+void* AIOwrapper::async_io( void *ptr )
+{
+ //cout << "async_io\n" << flush;
+ type_fileh* Fhandler = (type_fileh *)ptr;
+ int size_buff,tmp_y_blockSize,tmp_ar_blockSize;
+
+ struct timespec timeToWait;
+ FILE* fp_Y;
ifstream fp_Ar;
ifstream fp_I;
@@ -731,31 +732,31 @@
int y_file_pos = 0;
int ar_file_pos = 0;
-
- if(!Fhandler->fakefiles)
- {
- fp_Y = fopen((Fhandler->fnameY+".fvd").c_str(), "rb");
- if(fp_Y == 0)
- {
- cout << "Error opening File Y " << Fhandler->fnameY << endl;
- exit(1);
- }
- fp_Ar.open ((Fhandler->fnameAR+".fvd").c_str(), ios::in | ios::binary);
-
- if(!fp_Ar.is_open())
- {
- cout << "Error opening File Xr " << Fhandler->fnameAR << endl;
- exit(1);
- }
+ if(!Fhandler->fakefiles)
+ {
+ fp_Y = fopen((Fhandler->fnameY+".fvd").c_str(), "rb");
+ if(fp_Y == 0)
+ {
+ cout << "Error opening File Y " << Fhandler->fnameY << endl;
+ exit(1);
+ }
+ fp_Ar.open ((Fhandler->fnameAR+".fvd").c_str(), ios::in | ios::binary);
- fp_sigResults.open((Fhandler->fnameOutFiles + "_dis.txt").c_str(),ios::out | ios::trunc);
- if(fp_sigResults == 0)
- {
- cout << "Error Creating File " << (Fhandler->fnameOutFiles + "_dis.txt") << endl;
- exit(1);
+ if(!fp_Ar.is_open())
+ {
+ cout << "Error opening File Xr " << Fhandler->fnameAR << endl;
+ exit(1);
}
+
+ fp_sigResults.open((Fhandler->fnameOutFiles + "_dis.txt").c_str(),ios::out | ios::trunc);
+ if(fp_sigResults == 0)
+ {
+ cout << "Error Creating File " << (Fhandler->fnameOutFiles + "_dis.txt") << endl;
+ exit(1);
+ }
+
fp_sigResults << "Phe\tSNP\tn\tnPct\tB\tR2\tSE\tT\tP" << endl;
//float *a= new float [Fhandler->fileM*Fhandler->fileM*Fhandler->fileM];
@@ -768,10 +769,10 @@
fp_I.open ((Fhandler->fname_interactions+".fvd").c_str(), ios::in | ios::binary);
- if(!fp_I.is_open())
- {
- cout << "Error opening Interactions File in AIO" << Fhandler->fname_interactions << endl;
- exit(1);
+ if(!fp_I.is_open())
+ {
+ cout << "Error opening Interactions File in AIO" << Fhandler->fname_interactions << endl;
+ exit(1);
}
fp_I.seekg( ini_filepos*sizeof(type_precision) , ios::beg );
@@ -819,97 +820,97 @@
if(Fhandler->storeBin)
{
- fp_allResults.open((Fhandler->fnameOutFiles + "_sto.dbin").c_str(),ios::out | ios::binary | ios::trunc);
- if(fp_allResults == 0)
- {
- cout << "Error Creating File "<< (Fhandler->fnameOutFiles + "_sto.bin") << endl;
- exit(1);
+ fp_allResults.open((Fhandler->fnameOutFiles + "_sto.dbin").c_str(),ios::out | ios::binary | ios::trunc);
+ if(fp_allResults == 0)
+ {
+ cout << "Error Creating File "<< (Fhandler->fnameOutFiles + "_sto.bin") << endl;
+ exit(1);
}
}
-
- }
- else
- {
- //cout << "\nPreping files\n" << flush;
- fp_Y = fopen("tempY.bin", "w+b");
- if(fp_Y == 0)
- {
- cout << "Error creating temp File Y " << endl;
- exit(1);
- }
- type_precision* tempbuff1 = new type_precision[Fhandler->n*Fhandler->y_blockSize];
- fwrite(tempbuff1, sizeof(type_precision), Fhandler->n*Fhandler->y_blockSize, fp_Y);
-
- delete []tempbuff1;
-
-
+
+ }
+ else
+ {
+ //cout << "\nPreping files\n" << flush;
+ fp_Y = fopen("tempY.bin", "w+b");
+ if(fp_Y == 0)
+ {
+ cout << "Error creating temp File Y " << endl;
+ exit(1);
+ }
+ type_precision* tempbuff1 = new type_precision[Fhandler->n*Fhandler->y_blockSize];
+ fwrite(tempbuff1, sizeof(type_precision), Fhandler->n*Fhandler->y_blockSize, fp_Y);
+
+ delete []tempbuff1;
+
+
ofstream fp_Art;
- fp_Art.open ("tempAR.bin",ios::out | ios::binary );
- if(!fp_Art.is_open())
- {
- cout << "Error creating temp File AR " << endl;
- exit(1);
- }
- type_precision* tempbuff2 = new type_precision[Fhandler->n*Fhandler->Ar_blockSize*Fhandler->r];
+ fp_Art.open ("tempAR.bin",ios::out | ios::binary );
+ if(!fp_Art.is_open())
+ {
+ cout << "Error creating temp File AR " << endl;
+ exit(1);
+ }
+ type_precision* tempbuff2 = new type_precision[Fhandler->n*Fhandler->Ar_blockSize*Fhandler->r];
fp_Art.write((char*)tempbuff2, sizeof(type_precision)*Fhandler->n*Fhandler->Ar_blockSize*Fhandler->r);
fp_Art.close();
- fp_Ar.open ("tempAR.bin",ios::in | ios::binary );
-
- delete []tempbuff2;
-
-
- //cout << "\nEnd preping files\n" << flush;
-
+ fp_Ar.open ("tempAR.bin",ios::in | ios::binary );
+
+ delete []tempbuff2;
+
+
+ //cout << "\nEnd preping files\n" << flush;
+
}
- //pthread_barrier_wait(&(Fhandler->finalize_barrier));//for testing only
-
-
- bool Local_not_done = true;
+ //pthread_barrier_wait(&(Fhandler->finalize_barrier));//for testing only
+
+
+ bool Local_not_done = true;
Fhandler->reset_wait = false;
- #ifdef DEBUG
+ #ifdef DEBUG
cout << " m:" << Fhandler->Ar_to_readSize << " mb:" << Fhandler->Ar_file_blocksize << endl<<flush ;
- #endif
- while(Local_not_done)
- {
-
- while(!Fhandler->empty_buffers.empty() && Fhandler->y_to_readSize && Fhandler->not_done)
- {
-
- tmp_y_blockSize = Fhandler->y_blockSize;
- if(Fhandler->y_to_readSize < Fhandler->y_blockSize)
- tmp_y_blockSize = Fhandler->y_to_readSize;
-
- Fhandler->y_to_readSize -= tmp_y_blockSize;
- size_buff = Fhandler->n * tmp_y_blockSize;
+ #endif
+ while(Local_not_done)
+ {
-
-
- pthread_mutex_lock(&(Fhandler->m_buff_upd));
+ while(!Fhandler->empty_buffers.empty() && Fhandler->y_to_readSize && Fhandler->not_done)
+ {
-
- type_buffElement* tobeFilled = Fhandler->empty_buffers.front();
- Fhandler->empty_buffers.pop();
-
-
+ tmp_y_blockSize = Fhandler->y_blockSize;
+ if(Fhandler->y_to_readSize < Fhandler->y_blockSize)
+ tmp_y_blockSize = Fhandler->y_to_readSize;
+
+ Fhandler->y_to_readSize -= tmp_y_blockSize;
+ size_buff = Fhandler->n * tmp_y_blockSize;
+
+
+
+ pthread_mutex_lock(&(Fhandler->m_buff_upd));
+
+
+ type_buffElement* tobeFilled = Fhandler->empty_buffers.front();
+ Fhandler->empty_buffers.pop();
+
+
tobeFilled->size = tmp_y_blockSize;
- //cout << "tbz:" << tmp_y_blockSize << " " << flush;
-
- if(Fhandler->fakefiles)
- {
- fseek ( fp_Y , 0 , SEEK_SET );
+ //cout << "tbz:" << tmp_y_blockSize << " " << flush;
+
+ if(Fhandler->fakefiles)
+ {
+ fseek ( fp_Y , 0 , SEEK_SET );
size_t result = fread (tobeFilled->buff,sizeof(type_precision),size_buff,fp_Y);
- result++;
- int old_seed = Fhandler->seed;
- srand (old_seed);
- re_random_vec(tobeFilled->buff, size_buff );
- re_random_vec_nan(tobeFilled->buff, size_buff );
- Fhandler->seed += 75;
- }
- else
+ result++;
+ int old_seed = Fhandler->seed;
+ srand (old_seed);
+ re_random_vec(tobeFilled->buff, size_buff );
+ re_random_vec_nan(tobeFilled->buff, size_buff );
+ Fhandler->seed += 75;
+ }
+ else
{
list< pair<int,int> >* excl_List = Fhandler->excl_List;
@@ -934,66 +935,66 @@
}
}
- y_file_pos += tmp_y_blockSize*Fhandler->fileN;
+ y_file_pos += tmp_y_blockSize*Fhandler->fileN;
-
- if(Fhandler->y_to_readSize <= 0)
- {
+
+ if(Fhandler->y_to_readSize <= 0)
+ {
fseek ( fp_Y , 0 , SEEK_SET );
- //cout << "resetY" << endl;
- }
- }
-
-
-
- Fhandler->full_buffers.push(tobeFilled);
-
- pthread_mutex_unlock(&(Fhandler->m_buff_upd));
-
- pthread_mutex_lock(&(Fhandler->m_read));
- pthread_cond_signal( &(Fhandler->condition_read ));
- pthread_mutex_unlock(&(Fhandler->m_read));
-
- }
-
- while(!Fhandler->ar_empty_buffers.empty() && Fhandler->Ar_to_readSize && Fhandler->not_done)
+ //cout << "resetY" << endl;
+ }
+ }
+
+
+
+ Fhandler->full_buffers.push(tobeFilled);
+
+ pthread_mutex_unlock(&(Fhandler->m_buff_upd));
+
+ pthread_mutex_lock(&(Fhandler->m_read));
+ pthread_cond_signal( &(Fhandler->condition_read ));
+ pthread_mutex_unlock(&(Fhandler->m_read));
+
+ }
+
+ while(!Fhandler->ar_empty_buffers.empty() && Fhandler->Ar_to_readSize && Fhandler->not_done)
{
-
- tmp_ar_blockSize = Fhandler->Ar_file_blocksize;
- if(Fhandler->Ar_to_readSize < Fhandler->Ar_file_blocksize)
+
+ tmp_ar_blockSize = Fhandler->Ar_file_blocksize;
+ if(Fhandler->Ar_to_readSize < Fhandler->Ar_file_blocksize)
tmp_ar_blockSize = Fhandler->Ar_to_readSize;
-
+
#ifdef DEBUG
cout << "tmp_ar_blockSize:" << tmp_ar_blockSize << " " ;
#endif
-
- Fhandler->Ar_to_readSize -= tmp_ar_blockSize;
- size_buff = Fhandler->n * tmp_ar_blockSize*Fhandler->r;
-
- pthread_mutex_lock(&(Fhandler->m_buff_upd));
- type_buffElement* tobeFilled = Fhandler->ar_empty_buffers.front();
- Fhandler->ar_empty_buffers.pop();
-
-
+
+ Fhandler->Ar_to_readSize -= tmp_ar_blockSize;
+ size_buff = Fhandler->n * tmp_ar_blockSize*Fhandler->r;
+
+ pthread_mutex_lock(&(Fhandler->m_buff_upd));
+ type_buffElement* tobeFilled = Fhandler->ar_empty_buffers.front();
+ Fhandler->ar_empty_buffers.pop();
+
+
tobeFilled->size = tmp_ar_blockSize;
#ifdef DEBUG
cout << tmp_ar_blockSize << " " << Fhandler->Ar_file_blocksize << " " ;
- #endif
-
- if(Fhandler->fakefiles)
- {
- fp_Ar.seekg ( 0 , ios::beg );
- fp_Ar.read ((char*)tobeFilled->buff,sizeof(type_precision)*size_buff);
-
- re_random_vec(tobeFilled->buff , Fhandler->n * tmp_ar_blockSize*Fhandler->r );
- re_random_vec_nan(tobeFilled->buff , Fhandler->n * tmp_ar_blockSize*Fhandler->r );
-
- }
- else
+ #endif
+
+ if(Fhandler->fakefiles)
{
+ fp_Ar.seekg ( 0 , ios::beg );
+ fp_Ar.read ((char*)tobeFilled->buff,sizeof(type_precision)*size_buff);
+
+ re_random_vec(tobeFilled->buff , Fhandler->n * tmp_ar_blockSize*Fhandler->r );
+ re_random_vec_nan(tobeFilled->buff , Fhandler->n * tmp_ar_blockSize*Fhandler->r );
+
+ }
+ else
+ {
#ifdef DEBUG
- cout << " "<< Fhandler->use_dosages << " " << Fhandler->add_dosages <<" " << Fhandler->model << " " << Fhandler->fileR << " " << Fhandler->dosage_skip << endl;
+ cout << " "<< Fhandler->use_dosages << " " << Fhandler->add_dosages <<" " << Fhandler->model << " " << Fhandler->fileR << " " << Fhandler->dosage_skip << endl;
#endif
list< pair<int,int> >* excl_List = Fhandler->excl_List;
@@ -1047,8 +1048,8 @@
if(Fhandler->add_dosages)
{
//cout << "adding ";
- cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
- Fhandler->n, 1, Fhandler->fileR-Fhandler->dosage_skip, 1.0, Fhandler->ArDosage, Fhandler->n, Fhandler->dosages,Fhandler->fileR-Fhandler->dosage_skip ,
+ cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
+ Fhandler->n, 1, Fhandler->fileR-Fhandler->dosage_skip, 1.0, Fhandler->ArDosage, Fhandler->n, Fhandler->dosages,Fhandler->fileR-Fhandler->dosage_skip ,
0.0, &(file_data[i*Fhandler->n]), Fhandler->n);
}
else
@@ -1168,8 +1169,8 @@
-
-
+
+
}
if(Fhandler->Ar_to_readSize <= 0)
@@ -1186,32 +1187,32 @@
#ifdef DEBUG
cout << "reseting ar" << flush;
#endif
- }
-
- Fhandler->ar_full_buffers.push(tobeFilled);
- // cout << "\nStoring " << tobeFilled << endl;
- pthread_mutex_unlock(&(Fhandler->m_buff_upd));
-
- pthread_mutex_lock(&(Fhandler->m_read));
- pthread_cond_signal( &(Fhandler->condition_read ));
- pthread_mutex_unlock(&(Fhandler->m_read));
-
- }
- //B write
-
- while(!Fhandler->write_full_buffers.empty() && Local_not_done)
+ }
+
+ Fhandler->ar_full_buffers.push(tobeFilled);
+ // cout << "\nStoring " << tobeFilled << endl;
+ pthread_mutex_unlock(&(Fhandler->m_buff_upd));
+
+ pthread_mutex_lock(&(Fhandler->m_read));
+ pthread_cond_signal( &(Fhandler->condition_read ));
+ pthread_mutex_unlock(&(Fhandler->m_read));
+
+ }
+ //B write
+
+ while(!Fhandler->write_full_buffers.empty() && Local_not_done)
{
//cout << "S" << " ";
-
- pthread_mutex_lock(&(Fhandler->m_buff_upd));
- list < resultH >* tobeWritten = Fhandler->write_full_buffers.front();
- Fhandler->write_full_buffers.pop();
-
-
- if(Fhandler->fakefiles)
- {
-
+
+ pthread_mutex_lock(&(Fhandler->out_buff_upd));
+ list < resultH >* tobeWritten = Fhandler->write_full_buffers.front();
+ Fhandler->write_full_buffers.pop();
+
+
+ if(Fhandler->fakefiles)
+ {
+
}
if(!Fhandler->fakefiles && !tobeWritten->empty())
@@ -1299,11 +1300,11 @@
}
- }
-
-
-
- Fhandler->write_empty_buffers.push(tobeWritten);
+ }
+
+
+
+ Fhandler->write_empty_buffers.push(tobeWritten);
// cout << "\nStoring " << tobeWritten << endl;
//cout << "Done Storing" << endl;
@@ -1311,124 +1312,124 @@
-
- pthread_mutex_unlock(&(Fhandler->m_buff_upd));
-
-
- pthread_mutex_lock(&(Fhandler->m_read));
- pthread_cond_signal( &(Fhandler->condition_read ));
- pthread_mutex_unlock(&(Fhandler->m_read));
-
+ pthread_mutex_unlock(&(Fhandler->out_buff_upd));
+
+
+
+ pthread_mutex_lock(&(Fhandler->m_read));
+ pthread_cond_signal( &(Fhandler->condition_read ));
+ pthread_mutex_unlock(&(Fhandler->m_read));
+
}
if(!Fhandler->not_done && Fhandler->write_full_buffers.empty())
- {Local_not_done = false;}
-
-
-#ifdef WINDOWS
- SYSTEMTIME time;
- GetSystemTime(&time);
-
- timeToWait.tv_sec = time.wSecond + 500/1000;
- long int morenanos = (500%1000)*1000000;
- timeToWait.tv_nsec = time.wMilliseconds*1000 + morenanos ;
-#else
- clock_gettime(CLOCK_REALTIME, &timeToWait);
- timeToWait.tv_nsec += 150;
-#endif
-
- pthread_mutex_lock(&(Fhandler->m_more));
- pthread_cond_timedwait( &(Fhandler->condition_more), &(Fhandler->m_more), &timeToWait );
- pthread_mutex_unlock( &(Fhandler->m_more ));
-
- pthread_mutex_lock(&(Fhandler->m_read));
- pthread_cond_signal( &(Fhandler->condition_read ));
- pthread_mutex_unlock(&(Fhandler->m_read));
-
-
+ {Local_not_done = false;}
+
+
+#ifdef WINDOWS
+ SYSTEMTIME time;
+ GetSystemTime(&time);
+
+ timeToWait.tv_sec = time.wSecond + 500/1000;
+ long int morenanos = (500%1000)*1000000;
+ timeToWait.tv_nsec = time.wMilliseconds*1000 + morenanos ;
+#else
+ clock_gettime(CLOCK_REALTIME, &timeToWait);
+ timeToWait.tv_nsec += 10000000;
+#endif
+
+ pthread_mutex_lock(&(Fhandler->m_more));
+ pthread_cond_timedwait( &(Fhandler->condition_more), &(Fhandler->m_more), &timeToWait );
+ pthread_mutex_unlock( &(Fhandler->m_more ));
+
+ pthread_mutex_lock(&(Fhandler->m_read));
+ pthread_cond_signal( &(Fhandler->condition_read ));
+ pthread_mutex_unlock(&(Fhandler->m_read));
+
+
}
-
-
- //barrier
- pthread_barrier_wait(&(Fhandler->finalize_barrier));
- {
+
+ //barrier
+ pthread_barrier_wait(&(Fhandler->finalize_barrier));
+
+ {
type_buffElement* tmp;
- if(Fhandler->currentReadBuff)
- {
- Fhandler->full_buffers.push(Fhandler->currentReadBuff);
- Fhandler->currentReadBuff=0;
+ if(Fhandler->currentReadBuff)
+ {
+ Fhandler->full_buffers.push(Fhandler->currentReadBuff);
+ Fhandler->currentReadBuff=0;
}
-
- while(!Fhandler->full_buffers.empty())
- {
- tmp= Fhandler->full_buffers.front();
- Fhandler->full_buffers.pop();
- delete []tmp->buff;
- delete tmp;
- }
-
- while(!Fhandler->empty_buffers.empty())
- {
- tmp= Fhandler->empty_buffers.front();
- Fhandler->empty_buffers.pop();
- delete []tmp->buff;
+
+ while(!Fhandler->full_buffers.empty())
+ {
+ tmp= Fhandler->full_buffers.front();
+ Fhandler->full_buffers.pop();
+ delete []tmp->buff;
+ delete tmp;
+ }
+
+ while(!Fhandler->empty_buffers.empty())
+ {
+ tmp= Fhandler->empty_buffers.front();
+ Fhandler->empty_buffers.pop();
+ delete []tmp->buff;
delete tmp;
-
+
}
- if(Fhandler->Ar_currentReadBuff)
- {
- Fhandler->ar_full_buffers.push(Fhandler->Ar_currentReadBuff);
- Fhandler->Ar_currentReadBuff=0;
- }
-
- while(!Fhandler->ar_full_buffers.empty())
- {
- tmp= Fhandler->ar_full_buffers.front();
- Fhandler->ar_full_buffers.pop();
- delete []tmp->buff;
- delete tmp;
- }
-
- while(!Fhandler->ar_empty_buffers.empty())
- {
- tmp= Fhandler->ar_empty_buffers.front();
- Fhandler->ar_empty_buffers.pop();
- delete []tmp->buff;
- delete tmp;
- }
-
- while(!Fhandler->write_full_buffers.empty())
- {
- list < resultH >* tmp2= Fhandler->write_full_buffers.front();
- Fhandler->write_full_buffers.pop();
- delete tmp2;
- }
-
- while(!Fhandler->write_empty_buffers.empty())
- {
- list < resultH >* tmp2= Fhandler->write_empty_buffers.front();
- Fhandler->write_empty_buffers.pop();
- delete tmp2;
+ if(Fhandler->Ar_currentReadBuff)
+ {
+ Fhandler->ar_full_buffers.push(Fhandler->Ar_currentReadBuff);
+ Fhandler->Ar_currentReadBuff=0;
}
+ while(!Fhandler->ar_full_buffers.empty())
+ {
+ tmp= Fhandler->ar_full_buffers.front();
+ Fhandler->ar_full_buffers.pop();
+ delete []tmp->buff;
+ delete tmp;
+ }
+ while(!Fhandler->ar_empty_buffers.empty())
+ {
+ tmp= Fhandler->ar_empty_buffers.front();
+ Fhandler->ar_empty_buffers.pop();
+ delete []tmp->buff;
+ delete tmp;
+ }
+
+ while(!Fhandler->write_full_buffers.empty())
+ {
+ list < resultH >* tmp2= Fhandler->write_full_buffers.front();
+ Fhandler->write_full_buffers.pop();
+ delete tmp2;
+ }
+
+ while(!Fhandler->write_empty_buffers.empty())
+ {
+ list < resultH >* tmp2= Fhandler->write_empty_buffers.front();
+ Fhandler->write_empty_buffers.pop();
+ delete tmp2;
+ }
+
+
if(Fhandler->use_interactions)
{
delete [](Fhandler->interaction_data);
fp_I.close();
}
- }
-
-
-
- fclose(fp_Y);
+ }
+
+
+
+ fclose(fp_Y);
fp_Ar.close();
fp_sigResults.close();
@@ -1436,347 +1437,348 @@
- return 0;
-
-
-
-}
-
-void AIOwrapper::load_ARblock(type_precision** Ar, int &Ar_blockSize)
-{
-
- //int status;
- // int createstatus = 0;
- //cout<<"^";
-
- while(Fhandler->ar_full_buffers.empty())
- {
- pthread_mutex_lock(&(Fhandler->m_more));
- pthread_cond_signal( &(Fhandler->condition_more ));
- pthread_mutex_unlock(&(Fhandler->m_more));
-
- io_overhead = "#";
-
- pthread_mutex_lock(&(Fhandler->m_read));
- pthread_cond_wait( &(Fhandler->condition_read), &(Fhandler->m_read ));
- pthread_mutex_unlock(&(Fhandler->m_read));
- }
-
-
- //!read new rdy buffer
+ return 0;
+
+
+
+}
+
+void AIOwrapper::load_ARblock(type_precision** Ar, int &Ar_blockSize)
+{
+
+ //int status;
+ // int createstatus = 0;
+ //cout<<"^";
+
+ while(Fhandler->ar_full_buffers.empty())
+ {
+ pthread_mutex_lock(&(Fhandler->m_more));
+ pthread_cond_signal( &(Fhandler->condition_more ));
+ pthread_mutex_unlock(&(Fhandler->m_more));
+
+ io_overhead = "#";
+
+ pthread_mutex_lock(&(Fhandler->m_read));
+ pthread_cond_wait( &(Fhandler->condition_read), &(Fhandler->m_read ));
+ pthread_mutex_unlock(&(Fhandler->m_read));
+ }
+
+
+ //!read new rdy buffer
pthread_mutex_lock(&(Fhandler->m_buff_upd));
-
- if(Fhandler->Ar_currentReadBuff)
- {
- Fhandler->ar_empty_buffers.push(Fhandler->Ar_currentReadBuff);
- }
-
- Fhandler->Ar_currentReadBuff = Fhandler->ar_full_buffers.front();
- Fhandler->ar_full_buffers.pop();
-
- //cout << "\nReading " << Fhandler->Ar_currentReadBuff << endl;
- Fhandler->Ar = Fhandler->Ar_currentReadBuff->buff;
+
+ if(Fhandler->Ar_currentReadBuff)
+ {
+ Fhandler->ar_empty_buffers.push(Fhandler->Ar_currentReadBuff);
+ }
+
+ Fhandler->Ar_currentReadBuff = Fhandler->ar_full_buffers.front();
+ Fhandler->ar_full_buffers.pop();
+
+ //cout << "\nReading " << Fhandler->Ar_currentReadBuff << endl;
+ Fhandler->Ar = Fhandler->Ar_currentReadBuff->buff;
Ar_blockSize = Fhandler->Ar_currentReadBuff->size;
-
-
- pthread_mutex_unlock(&(Fhandler->m_buff_upd));
-
-
-
- pthread_mutex_lock(&(Fhandler->m_more));
- pthread_cond_signal( &(Fhandler->condition_more ));
- pthread_mutex_unlock(&(Fhandler->m_more));
-
-
- (*Ar) = Fhandler->Ar;
-
-
-
-
-
-
-}
-
-void AIOwrapper::load_Yblock(type_precision** Y, int &y_blockSize)
-{
-
- //int status;
- //int createstatus = 0;
-
- while(Fhandler->full_buffers.empty())
- {
-
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/genabel -r 1831
More information about the Genabel-commits
mailing list