'cancel' examples are a bit complicated

Discuss the OpenMP 4.0 Examples document.
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Posts: 15
Joined: Fri May 11, 2012 1:47 am

'cancel' examples are a bit complicated

Post by jgpallero »


First of all, thank you all people involved in the examples document. It's a great work!

I'm trying to learn about the new 'cancel' directive and I find the examples a bit complicated. In addition to them, I propose a very simple example like this:

Code: Select all

int limit=500,greater_than_limit=0;
double vector[NELEM];
//vector initialization...
for(int i=0;i<NELEM;i++){
    if vector[i]>limit{
        greater_than_limit = 1;
It only checks if a vector contains any element (no matter which of them) is greater than a defined limit. If this simple function is parallelized via OpenMP 4, I think it could be stopped with 'cancel', but I don't know how. I suggest the addition of this simple example to the document