MPI-StringMatch
所属分类:超算/并行计算
开发工具:C/C++
文件大小:10KB
下载次数:52
上传日期:2009-08-24 10:26:15
上 传 者:
phoenix168
说明: KMP串匹配、随机串匹配、近似串匹配的并行算法源码。
(KMP string matching, randomized string matching, parallel algorithm for approximate string matching source code.)
文件列表:
14-1\gen_ped.c (819, 2003-07-14)
14-1\kmp.c (7746, 2003-07-14)
14-2\rand_match.c (9405, 2003-07-14)
14-3\app_match.c (9025, 2003-07-14)
14-1 (0, 2008-05-18)
14-2 (0, 2008-05-18)
14-3 (0, 2008-05-18)
Example:
编译:gcc gen_ped.c Co gen_ped
mpicc kmp.c Co kmp
运行:首先运行gen_ped生成模式串,gen_ped Strlen Pedlen Seed Pattern_File。其中Strlen代表模式串的长度,Pedlen代表模式串的最小周期长度,Seed是随机函数使用的种子数,Pattern_File是生成数据存储的文件,这里在kmp.c中固定指定的文件名为pattern.dat。本例中使用了如下的参数。
gen_ped 3 2 1 pattern.dat
之后可以使用命令 mpirun Cnp SIZE kmp m n来运行该串匹配程序,其中SIZE是所使用的处理器个数,m表示文本串长度,n为文本串的周期长度。本实例中使用了SIZE=3个处理器,m=18,n=3。
mpirun Cnp 3 kmp 18 2
运行结果:
存储于pattern.dat中的模式串为:qmq
存储于match_result中的匹配结果为:
The Text on node 0 is asasas .
The Text on node 1 is qmqmqm .
The Text on node 2 is ypypyp .
This is the match result on node 0
(0) -
(1) -
(2) -
(3) -
This is the match result on node 1
(4) -
(5) -
(6) +
(7) -
(8) +
(9) -
This is the match result on node 2
(10) -
(11) -
(12) -
(13) -
(14) -
(15) -
说明:该运行实例中,令文本串长度为18,随机产生的文本串为asasasqmqmqmypypyp,分布在3个节点上;模式串长度为3,随机产生的模式串为qmq。最后,节点1上得到两个匹配位置,由+表示出来。
近期下载者:
相关文件:
收藏者: