gpt4 book ai didi

c - Rodinia 3.1 肌细胞基准中的奇怪构造

转载 作者:行者123 更新时间:2023-11-30 16:07:08 24 4
gpt4 key购买 nike

我目前正在研究概念性 RISCV SIMT 架构,我们的模拟器仅模拟一些所需的库调用。我们正在尝试运行 openmp rodinia 3.1基准测试,但由于我们只有 pthread 支持,我试图将简单的静态调度 openmp 代码转换为 pthread 代码。

我在myCell基准测试中发现了这种结构:

// master.c
void master(params) {
// declaration of th_id
int th_id;

// no initialization of th_id

#pragma omp parallel private(th_id)
{
// code that uses th_id as a "thread id" value
}
}

// main.c
#pragma omp parallel for
for (i=0; i<N; i++) {
master(params);
}

据我了解,开发人员依靠 master.c 代码中的 #pragma 来初始化变量 th_id,但我无法找不到 openmp 文档中的说明。假设 th_id 被 ompenmp 识别并初始化是完全正确还是错误?

最佳答案

此 OpenMP 基准测试代码已完全损坏。并行区域的开头应该有类似这样的内容:

th_id = omp_get_thread_num();

它获取调用线程的ID,是一个在0和执行并行区域的线程数减1之间变化的数字,其中0对应主线程。

再说一遍,这段代码确实很糟糕,似乎是从 Fortran 翻译过来的。存在越界数组访问:

int th_count[4];

...

#pragma omp parallel private(th_id)
{
...
if (th_id == th_count[4]) {
...
}

我想说你应该简单地废弃 MyCell 基准测试。

关于c - Rodinia 3.1 肌细胞基准中的奇怪构造,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59769592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com