如何使用OpenMP访问三种不同的功能 [英] How to access three different function using OpenMP

查看:139
本文介绍了如何使用OpenMP访问三种不同的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


如何使用OpenMP访问三种不同的功能?
我具有三个不同的功能,我需要使用OpenMP进行使用/操作-因此,在执行三个功能之后-将要在第四个功能中使用三个功能OUTPUT作为输入

Hello,


How to access three different function using OpenMP??
i have three different functions, i need to use/operate using OpenMP - so after three function execution - going to use the three functions OUTPUT in fourth Function as input

Ex A:

int Funct1(int x,int y)
{
  // Some Calculation
}

float Func2(float x, float y)
{
  // some Calculation
}

double Func3(double x,double y)
{
  /// Performs some different operation 
}

double d = Func1 + func2 + func3 ;



怎么做??我是这个OpenMP的新手.



How to do?? i am new to this OpenMP

推荐答案

您可以执行以下操作:

You can do something like this:

int a;
float b;
double c;

#pragma omp parallel sections
{
   // Run each section in parallel
   #pragma omp section
   { a = func1(); }
   #pragma omp section
   { b = func2(); }
   #pragma omp section
   { c = func3(); }
}

// We are back in main thread, sum it up
double d = a + b + c;


这篇关于如何使用OpenMP访问三种不同的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆