HMSBEAGLE
1.0.0
|
00001 /* 00002 * Precision.h 00003 * 00004 * Created on: Oct 13, 2009 00005 * Author: msuchard 00006 */ 00007 00008 #ifndef GPU_PRECISION_H_ 00009 #define GPU_PRECISION_H_ 00010 00011 template<typename T, typename F> 00012 inline void beagleMemCpy( T* to, F* from, unsigned int length ) 00013 { 00014 for(unsigned int m=0; m<length; m++) 00015 to[m]=(T)from[m]; 00016 }; 00017 00018 template<typename F> 00019 inline void beagleMemCpy( F* to, const F* from, unsigned int length ) 00020 { 00021 memcpy( to, from, length*sizeof(F) ); 00022 } 00023 00024 template<typename F> 00025 inline const F* beagleCastIfNecessary(const F* from, F* cache, 00026 unsigned int length) { 00027 return from; 00028 } 00029 00030 template<typename T, typename F> 00031 inline const T* beagleCastIfNecessary(const F* from, T* cache, 00032 unsigned int length) { 00033 beagleMemCpy(cache, from, length); 00034 return cache; 00035 } 00036 // 00037 //template<typename F> 00038 //inline void beagleCopyFromDeviceAndCastIfNecessary(GPUInterface* gpu, F* to, const F* from, F* cache, 00039 // unsigned int length) { 00040 // gpu->MemcpyDeviceToHost(to, from, sizeof(F) * kPatternCount); 00041 //} 00042 // 00043 //template<typename T, typename F> 00044 //inline void beagleCopyFromDeviceAndCastIfNecessary(GPUInterface* gpu, T* to, const F* from, F* cache, 00045 // unsigned int length) { 00046 // gpu->MemcpyDeviceToHost(cache, from, sizeof(F) * kPatternCount); 00047 // beagleMemCpy(to, cache, kPatternCount); 00048 //} 00049 00050 00051 //#ifdef DOUBLE_PRECISION 00052 // gpu->MemcpyDeviceToHost(outLogLikelihoods, dIntegrationTmp, sizeof(Real) * kPatternCount); 00053 //#else 00054 // gpu->MemcpyDeviceToHost(hLogLikelihoodsCache, dIntegrationTmp, sizeof(Real) * kPatternCount); 00055 // MEMCNV(outLogLikelihoods, hLogLikelihoodsCache, kPatternCount, double); 00056 //#endif 00057 00058 00059 00060 #endif /* GPU_PRECISION_H_ */