필터 지우기
필터 지우기

openmp mingw mex for matlab error

조회 수: 3 (최근 30일)
俊凯 王
俊凯 王 2021년 6월 20일
편집: Walter Roberson 2021년 6월 22일
i use Code block and my compiler environment is mingw 6.30.At the beginning, I created the following OpenMP code in the code block
There was no error
#include <iostream>
#include<omp.h>
#include<stdio.h>
#include<mex.h>
using namespace std;
int main()
{
int A = 100;
#pragma omp parallel for lastprivate(A) firstprivate(A)
for(int i = 0; i<10;i++)
{
A=A+i;
}
printf("%d\n",A);
cout<<omp_get_active_level()<<"\n"//this function omp_get_active_level() is compatible in cpp
return 0;
}
code like this,i am sure that mingw6.30 gcc is compatible with openmp function like omp_get_active_level()
next setup,i want to change this code to mexfunction for matlab ,so code changed like this
#include <iostream>
#include<omp.h>
#include<stdio.h>
#include<mex.h>
using namespace std;
int test()
{
int A = 100;
#pragma omp parallel for lastprivate(A) firstprivate(A)
for(int i = 0; i<10;i++)
{
A=A+i;
}
printf("%d\n",A);
cout<<omp_get_active_level()<<"\n"//this function omp_get_active_level() is compatible in cpp
return 0;
}
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
{
test();
}
in matlab2020b,i select my matlab mex compiler mingw6.30 rather than vc++,but when i compile cpp to mex(i input mex -v COMPFLAGS="$COMPFLAGS -openmp" main.cpp),matlab warning like this
this makes me puzzles,because in code block,pure cpp project is compatible to run with omp_get_active_level,while in mex compiler,matlab warning this function undefined,after i delete omp_get_active_level,mex compiler show no error,why?whether matlab mexfunction support omp_get_active_level or not
  댓글 수: 4
俊凯 王
俊凯 王 2021년 6월 20일
my project is cpp,is that ok ?let me have a try
俊凯 王
俊凯 王 2021년 6월 20일
success!thanks

댓글을 달려면 로그인하십시오.

답변 (0개)

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by