小编O.S*_*aya的帖子

Sections和OpenMP代码有时会挂起

我有使用OpenMP和C++的代码.代码正确执行但有时会挂起.我正在使用部分.你能告诉我这是什么问题吗?我尝试了几件事,但没有一件工作,比如将变量从私有变为共享.

#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define N     50

//gcc -fopenmp -o e3 e3.c
int main (int argc, char *argv[]) 
{
int i, nthreads, tid, section;
float a[N], b[N], c[N];
void print_results(float array[N], int tid, int section);

/* Some initializations */
for (i=0; i<N; i++)
  a[i] = b[i] = i * 1.0;

#pragma omp parallel private(c,i,tid,section)
  {
  tid = omp_get_thread_num(); //FIXME: how to get the thread id?
  if (tid == 0)
    {
    nthreads = omp_get_num_threads(); //FIXME: how to get …
Run Code Online (Sandbox Code Playgroud)

c c++ openmp

4
推荐指数
1
解决办法
648
查看次数

标签 统计

c ×1

c++ ×1

openmp ×1