【发布时间】:2022-01-18 23:48:40
【问题描述】:
我正在尝试并行化 DES,但几乎没有得到任何加速。并行化 s-box 部分并没有提高任何速度,而是在多项式时间内运行。 这是 DES 的 s-box 部分:
int row[8],col[8],val[8];
//s box parallelism
#pragma omp parallel for num_threads(8) schedule(static)
for (int i = 0; i < 8; i++) {
//the value of '0' is 48, '1' is 49 and so on. but since we are referring the matrix index, we are interested in 0,1,..
//So, the '0' should be subtracted . i.e. the 49 value of '1' will be 49-48=1.
int tid = omp_get_thread_num();
row[tid] = 2 * int(x[tid * 6] - '0') + int(x[tid * 6 + 5] - '0');
col[tid] = 8 * int(x[tid * 6 + 1] - '0') + 4 * int(x[tid * 6 + 2] - '0') + 2 * int(x[tid * 6 + 3] - '0') + int(x[tid * 6 + 4] - '0');
val[tid] = sbox[tid][row[tid]][col[tid]];
result[tid]= decimalToBinary(val[tid]);
}
有没有一种方法可以并行化 s-box 以提高速度?还是算法的另一部分可以并行化以获得最大的加速?有什么例子吗?
【问题讨论】:
-
你的工作量是微不足道的。除非
decimalToBinary有大约 1 万个操作,否则并行执行此操作毫无意义。 -
@VictorEijkhout 那我还能并行化哪些其他部分?
标签: c++ multithreading parallel-processing openmp des