我正在学习在FPGA上使用opencl并编写了实现Smith–Waterman algorithm的程序。但是结果是CPU上的程序比FPGA上的执行速度快。
这是我的内核代码:
__kernel void __attribute__ ((reqd_work_group_size(512,512,1)))
krnl_sw(
__global int* ref,
__global int* alt,
__global int* sw,
const int match,
const int mismatch,
const int open,
const int extend,
const int ncol,
const int nrow
) {
int col = get_global_id(0);
int row = get_global_id(1);
for (k = 2;k<ncol+nrow-1;k++)
{
if(col + row == k)
{
up_score = sw[(row - 1)*ncol + col] + extend*(row-1) + open ;
left_score = sw[row*ncol + col - 1] + extend*(row-1) + open ;
up_left_score = sw[(row - 1)*ncol + col - 1] + diag_score(ref[col - 1], alt[row - 1], match, mismatch);
sw[row*ncol + col] = max(up_score, left_score);
sw[row*ncol + col] = max(up_left_score, sw[row*ncol + col]);
}
}
return;
}
cpu上的代码:
for (i = 1;i < ncol;i++)
{
for (j = 1;j< nrow;j++)
{
up_score = sw[j - 1][i] + extend*(j-1)+open;
left_score = sw[j][i - 1] + extend * (i - 1) + open;
up_left_score = sw[j - 1][i - 1] + diag_score(ref[i - 1], alt[j - 1], match, mismatch);
sw[j][i] = max(up_score, left_score);
sw[j][i] = max(up_left_score, sw[j][i]);
}
}
内核代码有什么问题吗?