how to use openMP in Matlab on Windows 7

1 view (last 30 days)
Yangyang Xu
Yangyang Xu on 24 Jun 2014
Answered: shaohui chen on 10 Sep 2014
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?

Answers (1)

shaohui chen
shaohui chen on 10 Sep 2014
I think you need MSVC professional to utilize openmp.

Categories

Find more on Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!