Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SymmArraySSE.cc
Go to the documentation of this file.
1 #include "SymmArraySSE.hh"
2 
3 #include <stdlib.h>
4 
5 ClassImp(SymmArraySSE<float>)
6 
7 template <class Record>
8 SymmArraySSE<Record>::SymmArraySSE(unsigned int n)
9 { recSize = sizeof(Record);
10  SizeSSE = ((2*n+1)*recSize/16+1)*16; // in bytes
11  last = n;
12  allocateSSE();
13 }
14 
15 template <class Record>
17 { zero = rec = 0;
18  *this=a;
19 }
20 
21 template <class Record>
23 { recSize = other.recSize;
24  Resize(other.last);
25  for(int i=0; i<SizeSSE/recSize; ++i)rec[i] = other.rec[i];
26  return *this;
27 }
28 
29 template <class Record>
31 { free(rec);
32 }
33 
34 template <class Record>
36 {
37  int newSizeSSE = ((2*nn+1)*recSize/16+1)*16; // in bytes
38  if(newSizeSSE==SizeSSE)return;
39  free(rec);
40  last = nn;
41  SizeSSE = newSizeSSE;
42  allocateSSE();
43 }
44 
45 template <class Record>
47 { rec = 0;
48  if(posix_memalign((void**)&rec, 16, SizeSSE))
49  printf("SymmArraySSE::SymmArraySSE : memory not allocated\n");
50  zero = rec + SizeSSE/(2*recSize);
51  //if(rec)printf("SSE %d allocated\n", SizeSSE);
52  //else printf("SSE %d not allocated\n", SizeSSE);
53 }
54 
55 template <class Record>
57 { int n = SizeSSE/recSize;
58  for(int i=-n/2; i<-last; ++i)zero[i] = 0;
59  for(int i=last+1; i<n/2; ++i)zero[i] = 0;
60 }
61 
62 
63 template <class Record>
65 { fwrite(&last, sizeof(int), 1, f);
66  fwrite(&recSize, sizeof(int), 1, f);
67  fwrite(rec, recSize, 2*last+1, f);
68 }
69 
70 template <class Record>
72 { int n, newRecSz;
73  fread(&n, sizeof(int), 1, f);
74  fread(&newRecSz, sizeof(int), 1, f);
75 
76  if(newRecSz!=recSize){
77  printf("Array::Read abort b/c different record size: %d vs %d\n", newRecSz,recSize);
78  return;
79  }
80 
81  int newSizeSSE = ((2*n+1)*recSize/16+1)*16; // in bytes
82  last = n;
83 
84  if(newSizeSSE != SizeSSE){
85  if(SizeSSE)free(rec);
86  SizeSSE = newSizeSSE;
87  allocateSSE();
88  }
89  fread(rec, recSize, 2*n+1, f);
90 }
91 
92 template <class Record>
94 { for(int i=0; i<2*last+1; ++i)rec[i] = x;
95 }
96 
97 template class SymmArraySSE<int>;
98 template class SymmArraySSE<float>;
99 template class SymmArraySSE<double>;
100 
SymmArraySSE(unsigned int n=0)
Definition: SymmArraySSE.cc:8
void allocateSSE()
Definition: SymmArraySSE.cc:46
tuple f
Definition: cwb_online.py:91
printf("total live time: non-zero lags = %10.1f \n", liveTot)
wavearray< double > a(hp.size())
int n
Definition: cwb_net.C:10
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<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t 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:64
i drho i
Record * rec
Definition: SymmArraySSE.hh:31
int recSize
always in the middle of the allocated space
Definition: SymmArraySSE.hh:33
SymmArraySSE & operator=(const SymmArraySSE &other)
Definition: SymmArraySSE.cc:22
void Resize(int nn)
Definition: SymmArraySSE.cc:35
void Read(FILE *f)
Definition: SymmArraySSE.cc:71
void Init(Record x)
Definition: SymmArraySSE.cc:93
virtual ~SymmArraySSE()
Definition: SymmArraySSE.cc:30
void ZeroExtraElements()
Definition: SymmArraySSE.cc:56