how to use openMP in Matlab on Windows 7
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!