Azzera filtri
Azzera filtri

openmp mingw mex for matlab error

3 visualizzazioni (ultimi 30 giorni)
俊凯 王
俊凯 王 il 20 Giu 2021
Modificato: Walter Roberson il 22 Giu 2021
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 Commenti
俊凯 王
俊凯 王 il 20 Giu 2021
my project is cpp,is that ok ?let me have a try
俊凯 王
俊凯 王 il 20 Giu 2021
success!thanks

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by