简体   繁体   English

在 C++ 中使用 openMP 实现并行 DES

[英]Parallel DES implementation using openMP in C++

I am trying to Parallelize DES but hardly getting any speedup.我正在尝试并行化 DES,但几乎没有得到任何加速。 Parallelizing the s-box part is not giving any speed up rather it is running in polynomial time.并行化 s-box 部分并没有提高任何速度,而是在多项式时间内运行。 Here is the s-box part of the DES:这是 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]);
        }

Is there a way I can parallelize s-boxes to improve speedup?有没有办法可以并行化 s-box 以提高速度? or is there another part of algorithm which can be parallelized to get maximum speedup?还是算法的另一部分可以并行化以获得最大的加速? Any examples?有什么例子吗?

use auto range1= std::async(dowork) to calculate ranges in parallel and return range1.get()+range2.get() etc..使用auto range1= std::async(dowork)并行计算范围并返回 range1.get()+range2.get() 等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM