HMSBEAGLE  1.0.0
Precision.h
1 /*
2  * Precision.h
3  *
4  * Created on: Oct 13, 2009
5  * Author: msuchard
6  */
7 
8 #ifndef GPU_PRECISION_H_
9 #define GPU_PRECISION_H_
10 
11 template<typename T, typename F>
12 inline void beagleMemCpy( T* to, F* from, unsigned int length )
13 {
14  for(unsigned int m=0; m<length; m++)
15  to[m]=(T)from[m];
16 };
17 
18 template<typename F>
19 inline void beagleMemCpy( F* to, const F* from, unsigned int length )
20 {
21  memcpy( to, from, length*sizeof(F) );
22 }
23 
24 template<typename F>
25 inline const F* beagleCastIfNecessary(const F* from, F* cache,
26  unsigned int length) {
27  return from;
28 }
29 
30 template<typename T, typename F>
31 inline const T* beagleCastIfNecessary(const F* from, T* cache,
32  unsigned int length) {
33  beagleMemCpy(cache, from, length);
34  return cache;
35 }
36 //
37 //template<typename F>
38 //inline void beagleCopyFromDeviceAndCastIfNecessary(GPUInterface* gpu, F* to, const F* from, F* cache,
39 // unsigned int length) {
40 // gpu->MemcpyDeviceToHost(to, from, sizeof(F) * kPatternCount);
41 //}
42 //
43 //template<typename T, typename F>
44 //inline void beagleCopyFromDeviceAndCastIfNecessary(GPUInterface* gpu, T* to, const F* from, F* cache,
45 // unsigned int length) {
46 // gpu->MemcpyDeviceToHost(cache, from, sizeof(F) * kPatternCount);
47 // beagleMemCpy(to, cache, kPatternCount);
48 //}
49 
50 
51 //#ifdef DOUBLE_PRECISION
52 // gpu->MemcpyDeviceToHost(outLogLikelihoods, dIntegrationTmp, sizeof(Real) * kPatternCount);
53 //#else
54 // gpu->MemcpyDeviceToHost(hLogLikelihoodsCache, dIntegrationTmp, sizeof(Real) * kPatternCount);
55 // MEMCNV(outLogLikelihoods, hLogLikelihoodsCache, kPatternCount, double);
56 //#endif
57 
58 
59 
60 #endif /* GPU_PRECISION_H_ */