Call for cancellation structure simple example

General OpenMP discussion
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help:
Posts: 15
Joined: Fri May 11, 2012 1:47 am

Call for cancellation structure simple example

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 = i+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. Can someone, please, post a version using the OpenMP 4 'cancel' order? I suggest also the addition of this simple example to the document