哪位见过下面这样并行的BFS算法(伪代码),帮忙解释一下吧

lxthau 2012-04-06 10:22:18

第三行代码:{r, r_end} = Qvfront[cta_offset + thread_id]; 该怎样理解?{r, r_end}是什么东西?

Algorithm 5. GPU pseudo-code for a warp-based, strip-mined neighbor-gathering approach.
Input: Vertex-frontier Qvfront, column-indices array C, and the offset cta_offset for the current tile within Qvfront
Functions: WarpAny(predi) returns true if any predi is set for any thread ti within the warp.

1 GatherWarp(cta_offset, Qvfront, C) {
2 volatile shared comm[WARPS][3];
3 {r, r_end} = Qvfront[cta_offset + thread_id];
4 while (WarpAny(r_end – r)) {
5
6 // vie for control of warp
7 if (r_end – r)
8 comm[warp_id][0] = lane_id;
9
10 // winner describes adjlist
11 if (comm[warp_id][0] == lane_id) {
12 comm[warp_id][1] = r;
13 comm[warp_id][2] = r_end;
14 r = r_end;
15 }
16
17 // strip-mine winner’s adjlist
18 r_gather = comm[warp_id][1] + lane_id;
19 r_gather_end = comm[warp_id][2];
20 while (r_gather < r_gather_end) {
21 volatile neighbor = C[r_gather];
22 r_gather += WARP_SIZE;
23 }
24 }
25 }

对该算法的描述:
Coarse-grained, warp-based gathering. Threads enlist the entire warp to assist in gathering. As described in
Algorithm 5, each thread attempts to vie for control of its warp by writing its thread-identifier into a single word shared by all threads of that warp. Only one write will succeed, thus determining which is allowed to subsequently enlist the warp as a whole to read its corresponding neighbors. This process repeats for every warp until its threads have all had their adjacent neighbors gathered.

看的头都晕了。这个算法出自论文《High Performance and Scalable GPU Graph Traversal》,有没有哪位读过这篇论文?
...全文
1869 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hpsoar 2012-12-29
  • 打赏
  • 举报
回复
http://code.google.com/p/back40computing/这里有源代码 warp-based核心算法如下: 1. 一个队列,存当前层的结点,0层只有一个源结点 2. 一个Warp中的每个线程从队列取一个结节,第i个线程有Ni个邻居(我个是从R中读的),如果Ni的邻居大于32个,就参与竞争,获得控制权后,让Warp中的所有线程处理i的邻居,所谓“处理”就是从C中读出邻居,然后看看有没有被访问过,标记,放进输出队列 3. 思想就是:把大的任务量分配平均分配给大家做,防止有人没事做,空闲 以上是论文中的说法,源代码的实现实现实际是是以Block/CTA为单位,比如某个线程处理的结点,有128个以上的邻居,则参与竞争,并把邻据分配给Block中的所有线程来处理 fine-grained核心算法如下: 1. 同上 2. 第i个线程有Ni个邻居,通过Prefix-Sum计算出这个Warp一共有多少个邻居,然后为这个Warp构造一个总任务池 【N0, N1, N2, ...】目的是:比如N0 = 2, N1 = 10, N2 = 3, N4 = 20 ...,拼完之后,这个任务池的大小可能是32 * K + x 每个线程处理的邻居数为K + 0/1,比较均衡,而不是之前的2, 10, 3, 20...; 3. 论文中给出的算法,并不是一开始就建好这个任务池,而是每次往里面加32个,然后分配给线程去处理,直到没有任务可加,这样做的原因应该是无法预测这个线程池的大小 4. 思想就是:把小的不均衡的任务量,拼成大的,然后平均分配
lxthau 2012-09-03
  • 打赏
  • 举报
回复
兄台能否简单讲一下这篇文章的核心算法是怎么回事儿?[Quote=引用 1 楼 的回复:]
就是图1中,R数组相邻两个位置的数,对应某结点的adjacency list的起点和终点
[/Quote]
lxthau 2012-09-03
  • 打赏
  • 举报
回复
是的,找不出太多有用的信息来加速图算法,感觉好多都是泛泛而谈[Quote=引用 2 楼 的回复:]
这篇文章确实写得不好,感觉有很多自造的词,结果也很散,应该围绕它的算法来讲的
[/Quote]
hpsoar 2012-08-30
  • 打赏
  • 举报
回复
这篇文章确实写得不好,感觉有很多自造的词,结果也很散,应该围绕它的算法来讲的
hpsoar 2012-08-30
  • 打赏
  • 举报
回复
就是图1中,R数组相邻两个位置的数,对应某结点的adjacency list的起点和终点

353

社区成员

发帖
与我相关
我的任务
社区描述
CUDA高性能计算讨论
社区管理员
  • CUDA高性能计算讨论社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧