当前位置: 首页 > news >正文

太原网站排名系统西安专业网站建设服务

太原网站排名系统,西安专业网站建设服务,wordpress utc时间慢8小时,公司设计图片跟1D一样#xff0c;2D的代码也没有运行过。旧的方法看看就好。 声明二维Texture texturefloat, 2 texConstSrc; texturefloat, 2 texIn; texturefloat, 2 texOut; 访问二维Texture 使用2D的Texture的便利性体现在blend_kernel函数里。不再需要通…跟1D一样2D的代码也没有运行过。旧的方法看看就好。 声明二维Texture texturefloat, 2 texConstSrc; texturefloat, 2 texIn; texturefloat, 2 texOut; 访问二维Texture 使用2D的Texture的便利性体现在blend_kernel函数里。不再需要通过xy去计算一维索引。二维texture使用tex2D()去读取数据。 __global__ void blend_kernel( float *dst,bool dstOut ) {// map from threadIdx/BlockIdx to pixel positionint x threadIdx.x blockIdx.x * blockDim.x;int y threadIdx.y blockIdx.y * blockDim.y;int offset x y * blockDim.x * gridDim.x;float t, l, c, r, b;if (dstOut) {t tex2D(texIn,x,y-1);l tex2D(texIn,x-1,y);c tex2D(texIn,x,y);r tex2D(texIn,x1,y);b tex2D(texIn,x,y1);} else {t tex2D(texOut,x,y-1);l tex2D(texOut,x-1,y);c tex2D(texOut,x,y);r tex2D(texOut,x1,y);b tex2D(texOut,x,y1);}dst[offset] c SPEED * (t b r l - 4 * c); } 然后拷贝热源数据 __global__ void copy_const_kernel( float *iptr ) {// map from threadIdx/BlockIdx to pixel positionint x threadIdx.x blockIdx.x * blockDim.x;int y threadIdx.y blockIdx.y * blockDim.y;int offset x y * blockDim.x * gridDim.x;float c tex2D(texConstSrc,x,y);if (c ! 0)iptr[offset] c; } 二维Texture绑定 使用维Texture去绑定一维数组稍微复杂一些 cudaChannelFormatDesc desc cudaCreateChannelDescfloat(); HANDLE_ERROR( cudaBindTexture2D( NULL, texConstSrc, data.dev_constSrc,desc, DIM, DIM, sizeof(float)*DIM)); HANDLE_ERROR( cudaBindTexture2D( NULL, texIn, data.dev_inSrc,desc, DIM, DIM, sizeof(float)*DIM)); HANDLE_ERROR( cudaBindTexture2D( NULL, texOut, data.dev_outSrc,desc, DIM, DIM, sizeof(float)*DIM));解除绑定 解除绑定的方式跟D相同 cudaUnbindTexture(texIn); cudaUnbindTexture(texOut); cudaUnbindTexture(texConstSrc); 完整代码 #include ../common/book.h #include ../common/cpu_anim.h#define DIM 1024 #define PI 3.1415926535897932f #define MAX_TEMP 1.0f #define MIN_TEMP 0.0001f #define SPEED 0.25f// these exist on the GPU side texturefloat,2 texConstSrc; texturefloat,2 texIn; texturefloat,2 texOut;__global__ void blend_kernel( float *dst,bool dstOut ) {// map from threadIdx/BlockIdx to pixel positionint x threadIdx.x blockIdx.x * blockDim.x;int y threadIdx.y blockIdx.y * blockDim.y;int offset x y * blockDim.x * gridDim.x;float t, l, c, r, b;if (dstOut) {t tex2D(texIn,x,y-1);l tex2D(texIn,x-1,y);c tex2D(texIn,x,y);r tex2D(texIn,x1,y);b tex2D(texIn,x,y1);} else {t tex2D(texOut,x,y-1);l tex2D(texOut,x-1,y);c tex2D(texOut,x,y);r tex2D(texOut,x1,y);b tex2D(texOut,x,y1);}dst[offset] c SPEED * (t b r l - 4 * c); }__global__ void copy_const_kernel( float *iptr ) {// map from threadIdx/BlockIdx to pixel positionint x threadIdx.x blockIdx.x * blockDim.x;int y threadIdx.y blockIdx.y * blockDim.y;int offset x y * blockDim.x * gridDim.x;float c tex2D(texConstSrc,x,y);if (c ! 0)iptr[offset] c; }// globals needed by the update routine struct DataBlock {unsigned char *output_bitmap;float *dev_inSrc;float *dev_outSrc;float *dev_constSrc;CPUAnimBitmap *bitmap;cudaEvent_t start, stop;float totalTime;float frames; };void anim_gpu( DataBlock *d, int ticks ) {HANDLE_ERROR( cudaEventRecord( d-start, 0 ) );dim3 blocks(DIM/16,DIM/16);dim3 threads(16,16);CPUAnimBitmap *bitmap d-bitmap;// since tex is global and bound, we have to use a flag to// select which is in/out per iterationvolatile bool dstOut true;for (int i0; i90; i) {float *in, *out;if (dstOut) {in d-dev_inSrc;out d-dev_outSrc;} else {out d-dev_inSrc;in d-dev_outSrc;}copy_const_kernelblocks,threads( in );blend_kernelblocks,threads( out, dstOut );dstOut !dstOut;}float_to_colorblocks,threads( d-output_bitmap,d-dev_inSrc );HANDLE_ERROR( cudaMemcpy( bitmap-get_ptr(),d-output_bitmap,bitmap-image_size(),cudaMemcpyDeviceToHost ) );HANDLE_ERROR( cudaEventRecord( d-stop, 0 ) );HANDLE_ERROR( cudaEventSynchronize( d-stop ) );float elapsedTime;HANDLE_ERROR( cudaEventElapsedTime( elapsedTime,d-start, d-stop ) );d-totalTime elapsedTime;d-frames;printf( Average Time per frame: %3.1f ms\n,d-totalTime/d-frames ); }// clean up memory allocated on the GPU void anim_exit( DataBlock *d ) {cudaUnbindTexture( texIn );cudaUnbindTexture( texOut );cudaUnbindTexture( texConstSrc );HANDLE_ERROR( cudaFree( d-dev_inSrc ) );HANDLE_ERROR( cudaFree( d-dev_outSrc ) );HANDLE_ERROR( cudaFree( d-dev_constSrc ) );HANDLE_ERROR( cudaEventDestroy( d-start ) );HANDLE_ERROR( cudaEventDestroy( d-stop ) ); }int main( void ) {DataBlock data;CPUAnimBitmap bitmap( DIM, DIM, data );data.bitmap bitmap;data.totalTime 0;data.frames 0;HANDLE_ERROR( cudaEventCreate( data.start ) );HANDLE_ERROR( cudaEventCreate( data.stop ) );int imageSize bitmap.image_size();HANDLE_ERROR( cudaMalloc( (void**)data.output_bitmap,imageSize ) );// assume float 4 chars in size (ie rgba)HANDLE_ERROR( cudaMalloc( (void**)data.dev_inSrc,imageSize ) );HANDLE_ERROR( cudaMalloc( (void**)data.dev_outSrc,imageSize ) );HANDLE_ERROR( cudaMalloc( (void**)data.dev_constSrc,imageSize ) );cudaChannelFormatDesc desc cudaCreateChannelDescfloat();HANDLE_ERROR( cudaBindTexture2D( NULL, texConstSrc,data.dev_constSrc,desc, DIM, DIM,sizeof(float) * DIM ) );HANDLE_ERROR( cudaBindTexture2D( NULL, texIn,data.dev_inSrc,desc, DIM, DIM,sizeof(float) * DIM ) );HANDLE_ERROR( cudaBindTexture2D( NULL, texOut,data.dev_outSrc,desc, DIM, DIM,sizeof(float) * DIM ) );// initialize the constant datafloat *temp (float*)malloc( imageSize );for (int i0; iDIM*DIM; i) {temp[i] 0;int x i % DIM;int y i / DIM;if ((x300) (x600) (y310) (y601))temp[i] MAX_TEMP;}temp[DIM*100100] (MAX_TEMP MIN_TEMP)/2;temp[DIM*700100] MIN_TEMP;temp[DIM*300300] MIN_TEMP;temp[DIM*200700] MIN_TEMP;for (int y800; y900; y) {for (int x400; x500; x) {temp[xy*DIM] MIN_TEMP;}}HANDLE_ERROR( cudaMemcpy( data.dev_constSrc, temp,imageSize,cudaMemcpyHostToDevice ) ); // initialize the input datafor (int y800; yDIM; y) {for (int x0; x200; x) {temp[xy*DIM] MAX_TEMP;}}HANDLE_ERROR( cudaMemcpy( data.dev_inSrc, temp,imageSize,cudaMemcpyHostToDevice ) );free( temp );bitmap.anim_and_exit( (void (*)(void*,int))anim_gpu,(void (*)(void*))anim_exit ); }
http://www.hkea.cn/news/14265929/

相关文章:

  • 苏州市建设安全监督局网站wordpress不提示更新
  • ui设计培训班排名引擎优化seo是什么
  • 大庆建设网站表格下载dw软件手机版
  • 苏州网页服务开发与网站建设对电子商务网站建设的认识
  • 网站服务器位于北美湖北建站中心
  • ps做网站导航条高度拙人营造设计公司官网
  • 中药材天地网做中药零售网站成都网站建设网站制作公司
  • 网站建设选择题题库网站建设 官网
  • 河南微网站开发河南高端网站高端网站建设
  • 神奇网站廊坊seo外包公司费用
  • 西安工商注册网上平台北京网站优化外包
  • 产品是做网站做网站能做职业吗
  • 网站空间哪里便宜山西房地产网站建设
  • 民生热点新闻seo咨询价格找推推蛙
  • 宁波网站建设方案报价长沙网开亿面做网站多少钱
  • 国内外网站大连建设工程交易中心
  • 建筑毕业设计代做网站网站侧边菜单
  • seo网站建设规划做网站好的网络公司
  • 黄页网页的推广网站wordpress jexus
  • 外贸网站建设不可缺少的灵活性一般做企业网站需要什么
  • 揭阳网站开发mituad网站备案管理办法
  • 做网站服务费税率邯郸网站建设优化排名
  • 做网站需要会编程吗网站建设通常用到哪些编程
  • 中国网站建设市场排名做设计素材在哪个网站
  • 贵阳手机网站开发商务网站建设与维护 ppt
  • 域名网站注册最划算当前主流的网络营销方式
  • 搭建网站需要多少钱网站建设方式丨金手指排名26
  • 如何搭建网站教程南通做网站优化
  • 创建个人网站的流程平台搭建步骤
  • 做网站建设需要什么资质商城app开发价格