解决memory bound算法的一些建议
来源:互联网 发布:淘宝打印助手在哪里 编辑:程序博客网 时间:2024/06/11 09:24
1、分析算法流程,分析算法中的某些中间是否有能够合并的操作,比如对于图像先进行下采样,然后再上采样存储到原始中,类似这种的操作都可以合并操作,直接在进行下采样之后不需要另外存储图像,直接进行上采样,这样就可以合并操作,减少内存的来回读写操作。
2、利用pthread的affinity功能,把算法的主要线程均匀affinity到主要的处理器核上;不使用CPU自主分配,自主控制线程的处理方式。
3、一般情况下,memory的分配都是使用malloc,可以替换malloc,利用MMAP分配page连续的内存来减少page fault,从而提高memory的效率。
example:
pThread affinity:
https://stackoverflow.com/questions/24645880/set-cpu-affinity-when-create-a-thread
unsigned long mask; /* processor number */
for(i = 0; i < pMgr->iThreadNumber; i++)
{
mask = i;
if (sched_setaffinity(0, sizeof(mask), &mask) <0) {
printf("sched_setaffinity");
}
do some operations;
}
MMAP:
http://blog.csdn.net/oktears/article/details/39610805
samples:
void* result = __mmap2(addr, size, prot, flags, fd, offset);
int rc = madvise(result, size, MADV_HUGEPAGE);
- 解决memory bound算法的一些建议
- [C++]STL算法高效使用的一些建议
- 收录的一些建议
- java的一些建议
- alertView的一些建议
- 程序员的一些建议
- URL的一些建议
- ACM的一些建议
- 一些小的建议
- 生活的一些建议。
- 托福考试的一些建议
- 一些解决问题的建议
- 学习算法的建议
- TabPageIndicator ViewPager has not been bound 的异常解决
- 【mybatis】【idea】【maven】Invalid bound statement (not found)的解决
- 对大学生的一些建议
- 游戏开发的一些建议
- 一些比较好的建议
- upstream prematurely closed connection while reading response header from upstream分析与解决
- 开关
- Windows消息机制
- git pull all branch
- 常见HTTP状态码
- 解决memory bound算法的一些建议
- HTTP之URI和URL
- Linux使用经验
- HDU 6241 Color a Tree CCPC2017 Harbin(二分答案+上下界判定)
- 日常总结
- mysql基础
- classpath路径及ClassPathXmlApplicationContext()用法
- hihoCoder-----有歧义的号码
- 入主tensorflow前言