Logo coherent WaveBurst  
Library Reference Guide
Logo
SymmArraySSE.cc
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Sergey Klimenko, Valentin Necula
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 #include "SymmArraySSE.hh"
20 
21 #include <stdlib.h>
22 
23 ClassImp(SymmArraySSE<float>)
24 
25 template <class Record>
27 { recSize = sizeof(Record);
28  SizeSSE = ((2*n+1)*recSize/16+1)*16; // in bytes
29  last = n;
30  allocateSSE();
31 }
32 
33 template <class Record>
35 { zero = rec = 0;
36  *this=a;
37 }
38 
39 template <class Record>
41 { recSize = other.recSize;
42  Resize(other.last);
43  for(int i=0; i<SizeSSE/recSize; ++i)rec[i] = other.rec[i];
44  return *this;
45 }
46 
47 template <class Record>
49 { free(rec);
50 }
51 
52 template <class Record>
54 {
55  int newSizeSSE = ((2*nn+1)*recSize/16+1)*16; // in bytes
56  if(newSizeSSE==SizeSSE)return;
57  free(rec);
58  last = nn;
59  SizeSSE = newSizeSSE;
60  allocateSSE();
61 }
62 
63 template <class Record>
65 { rec = 0;
66  if(posix_memalign((void**)&rec, 16, SizeSSE))
67  printf("SymmArraySSE::SymmArraySSE : memory not allocated\n");
68  zero = rec + SizeSSE/(2*recSize);
69  //if(rec)printf("SSE %d allocated\n", SizeSSE);
70  //else printf("SSE %d not allocated\n", SizeSSE);
71 }
72 
73 template <class Record>
75 { int n = SizeSSE/recSize;
76  for(int i=-n/2; i<-last; ++i)zero[i] = 0;
77  for(int i=last+1; i<n/2; ++i)zero[i] = 0;
78 }
79 
80 
81 template <class Record>
83 { fwrite(&last, sizeof(int), 1, f);
84  fwrite(&recSize, sizeof(int), 1, f);
85  fwrite(rec, recSize, 2*last+1, f);
86 }
87 
88 template <class Record>
90 { int n, newRecSz;
91  fread(&n, sizeof(int), 1, f);
92  fread(&newRecSz, sizeof(int), 1, f);
93 
94  if(newRecSz!=recSize){
95  printf("Array::Read abort b/c different record size: %d vs %d\n", newRecSz,recSize);
96  return;
97  }
98 
99  int newSizeSSE = ((2*n+1)*recSize/16+1)*16; // in bytes
100  last = n;
101 
102  if(newSizeSSE != SizeSSE){
103  if(SizeSSE)free(rec);
104  SizeSSE = newSizeSSE;
105  allocateSSE();
106  }
107  fread(rec, recSize, 2*n+1, f);
108 }
109 
110 template <class Record>
112 { for(int i=0; i<2*last+1; ++i)rec[i] = x;
113 }
114 
115 template class SymmArraySSE<int>;
116 template class SymmArraySSE<float>;
117 template class SymmArraySSE<double>;
118 
SymmArraySSE(unsigned int n=0)
Definition: SymmArraySSE.cc:26
void allocateSSE()
Definition: SymmArraySSE.cc:64
wavearray< double > a(hp.size())
int n
Definition: cwb_net.C:28
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1) *itime+ifreq;double time=itime *dT;double freq=(ifreq >0) ? ifreq *dF :dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
void Write(FILE *f)
Definition: SymmArraySSE.cc:82
i drho i
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
Record * rec
Definition: SymmArraySSE.hh:49
int recSize
always in the middle of the allocated space
Definition: SymmArraySSE.hh:51
printf("total live time: non-zero lags = %10.1f \, liveTot)
SymmArraySSE & operator=(const SymmArraySSE &other)
Definition: SymmArraySSE.cc:40
void Resize(int nn)
Definition: SymmArraySSE.cc:53
void Read(FILE *f)
Definition: SymmArraySSE.cc:89
void Init(Record x)
virtual ~SymmArraySSE()
Definition: SymmArraySSE.cc:48
void ZeroExtraElements()
Definition: SymmArraySSE.cc:74