MATLAB Answers

0

how to use openMP in Matlab on Windows 7

Asked by Yangyang Xu on 24 Jun 2014
Latest activity Answered by 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?

  0 Comments

Sign in to comment.

1 Answer

Answer by shaohui chen on 10 Sep 2014

I think you need MSVC professional to utilize openmp.

  0 Comments

Sign in to comment.