Page 1 of 1

'cancel' examples are a bit complicated

Posted: Thu Nov 14, 2013 8:11 am
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