Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

OpenMP for loop

eliweiss
Beginner
365 Views
Hi,

i am trying to use openmp.
i have a loop the goes over a vector of objects and does an operation on each of them.
i have reduced the code to this;
#pragma omp parallel for
for (int i=0;isize();i++)
{
std::cout << "Thread id:" << omp_get_thread_num() << " num " << omp_get_num_threads() << std::endl;
}

for this i get the 2 following warnings
.ClassifierKNN.cpp(122): warning #1433: OpenMP for-test may not conform
for (i=0;isize();i++)
^

.ClassifierKNN.cpp(122) : (col. 7) remark: OpenMP: Loop's header stmt (STMT_LABEL) not found or it is a dead loop.

when i run this i can see i have only a single thread.


if i replace m_TrainData->size() with a number i get only the second warning and still a single thread when run.


Thanks in advance.


Eli.





0 Kudos
2 Replies
fullung
Beginner
365 Views
You'll probably want to assign m_TrainData->size() to a variable before the loop. I don't think OpenMP can deal with a loop that can potentially change its termination condition while it is executing.



0 Kudos
eliweiss
Beginner
365 Views
That did it.

Thanks.

0 Kudos
Reply