omp

点击此处获得更好的阅读体验


WriteUp来源

官方WP

题目描述

题目考点

解题思路

本题的目的是为了让选手熟悉 OpenMP 这个计算框架. 同时故意设置了并行中的 race condition. 选手如果理解了各线程的时间差之后, 即可得知本题真正的内部逻辑. revert 的代码非常简单.

rt.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
void rt(void){
for(int l = 0; l < 3; l++){
int64_t temp = io.d32[l];
int64_t xo = temp >> 30;
temp = temp & 0x3FFFFFFF;
for(int64_t j = 0; j < (2 << 24); j++) {
temp = (temp >> 29) | (temp << 1);
temp ^= xo ^ 3;
temp = temp & 0x3FFFFFFF;
}
temp = temp | (xo << 30);
io.d32[l] = (uint32_t) temp;
}
}