欢迎来到天天文库
浏览记录
ID:59142087
大小:403.50 KB
页数:23页
时间:2020-09-11
《程序性能调优.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验题目:程序性能调优实验要求:本次实验,要求针对每个函数、每个人均至少写出3种优化版本、并根据driver报告的结果进行性能分析实验目的:理解编译器,学习程序优化,从优化程序代码和程序执行速度两方面着手。实验环境:WIN764位、ubuntu,VMwareworkstation,实验内容及操作步骤:将下载下来的kernels.c中的rotate、smooth函数进行优化。本实验的实验原理是通过循环展开、cache友好、替换变量等手段来实现程序优化。实验过程及分析:由于优化代码较长,就不进行截图。1.Naive_rotate1)原代码charnaive_rota
2、te_descr[]="naive_rotate:Naivebaselineimplementation";voidnaive_rotate(intdim,pixel*src,pixel*dst){inti,j;for(i=0;i3、是从cache友好性来分析,这个代码的效率机会很低,所以按照cache的大小,应在存储的时候进行32个像素依次存储(列存储)。做到cache友好这样就可以可以大幅度提高效率。#include#include#include"defs.h"team_tteam={"8",/*队名*/"8",/*序号*/"@qq.com",/*邮箱*/"",/*Secondmemberfullname(leaveblankifnone)*/""/*Secondmemberemailaddr(leaveblankifnone)*/};/**nai4、ve_rotate-Thenaivebaselineversionofrotate*/charnaive_rotate_descr[]="naive_rotate:Naivebaselineimplementation";voidnaive_rotate(intdim,pixel*src,pixel*dst){inti,j;for(i=0;i5、ate*IMPORTANT:Thisistheversionyouwillbegradedon*/charrotate_descr[]="rotate:Currentworkingversion,usingpointerratherthancomputingaddress";voidrotate(intdim,pixel*src,pixel*dst){inti;intj;inttmp1=dim*dim;inttmp2=dim*31;inttmp3=tmp1-dim;inttmp4=tmp1+32;inttmp5=dim+31;dst+=tmp3;for(i=0;6、i7、st=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;d8、st++;src+=di
3、是从cache友好性来分析,这个代码的效率机会很低,所以按照cache的大小,应在存储的时候进行32个像素依次存储(列存储)。做到cache友好这样就可以可以大幅度提高效率。#include#include#include"defs.h"team_tteam={"8",/*队名*/"8",/*序号*/"@qq.com",/*邮箱*/"",/*Secondmemberfullname(leaveblankifnone)*/""/*Secondmemberemailaddr(leaveblankifnone)*/};/**nai
4、ve_rotate-Thenaivebaselineversionofrotate*/charnaive_rotate_descr[]="naive_rotate:Naivebaselineimplementation";voidnaive_rotate(intdim,pixel*src,pixel*dst){inti,j;for(i=0;i5、ate*IMPORTANT:Thisistheversionyouwillbegradedon*/charrotate_descr[]="rotate:Currentworkingversion,usingpointerratherthancomputingaddress";voidrotate(intdim,pixel*src,pixel*dst){inti;intj;inttmp1=dim*dim;inttmp2=dim*31;inttmp3=tmp1-dim;inttmp4=tmp1+32;inttmp5=dim+31;dst+=tmp3;for(i=0;6、i7、st=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;d8、st++;src+=di
5、ate*IMPORTANT:Thisistheversionyouwillbegradedon*/charrotate_descr[]="rotate:Currentworkingversion,usingpointerratherthancomputingaddress";voidrotate(intdim,pixel*src,pixel*dst){inti;intj;inttmp1=dim*dim;inttmp2=dim*31;inttmp3=tmp1-dim;inttmp4=tmp1+32;inttmp5=dim+31;dst+=tmp3;for(i=0;
6、i7、st=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;d8、st++;src+=di
7、st=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;dst++;src+=dim;*dst=*src;d
8、st++;src+=di
此文档下载收益归作者所有