how to use openMP in Matlab on Windows 7

Dear All,
I am trying OpenMP by the following simple code
/*ompTest.c */
#include "mex.h"
#include "stdio.h"
#include "stdlib.h"
#include "omp.h"
void mexFunction(
int nargout,
mxArray *pargout [ ],
int nargin,
const mxArray *pargin [ ]
){
ptrdiff_t num_Thread = (ptrdiff_t) mxGetScalar(pargin[0]);
# pragma omp parallel num_threads(numThread){
int my_rank = omp_get_thread_num();
int thread_count = omp_get_num_threads();
printf("Hello from thread %d of %d\n",my_rank,thread_count);
}
return;
}
Then I compile it using
mex CC=gcc CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp" ompTest.c
and also
mex -v ompTest.c COMPFLAGS="$COMPFLAGS /openmp"
as suggested by some people.
However, it always reported
fatal error C1083: Cannot open include file: 'omp.h': No such file or directory
I don't find any people that has the same problem. Anybody can help me on this? I installed SDK 7.1 kit. Do I need to install some more file to have omp.h?

Respuestas (1)

shaohui chen
shaohui chen el 10 de Sept. de 2014

0 votos

I think you need MSVC professional to utilize openmp.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.

Preguntada:

el 24 de Jun. de 2014

Respondida:

el 10 de Sept. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by