摘要: We can never be satisfied with the program just only running correctly.The reduction summation program described in previous blog post needs to be optimized. 1.make the best use of hardware and do... 阅读全文
posted @ 2015-05-08 22:01 Hobbit 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 归约算法的基本思想是,对一个输入数组执行某种计算,然后产生一个更小的结果数组。当大量的数进行加和计算时,可以利用归约算法,多线程同时进行求和计算,使得时间复杂度下降。 算法思想如下: 设数据总数为N,输入数组为a[N]。首先启用N/2个线程,对于第i个线程,计算 a[i]=a[i]+a[i+N/2],此时,每个线程都将两个值合并为一个值,得到部分和数组,即a[0]到a[N/... 阅读全文
posted @ 2015-03-25 18:20 Hobbit 阅读(6046) 评论(1) 推荐(1) 编辑