no match operator

General OpenMP discussion

no match operator

Postby mononoke » Tue Jun 03, 2008 5:43 am

Hi all
I got such an error when trying to compile some premade codes

In a simplified way it looks like this:
omp_lock_t lock;
omp_init_lock(&lock);
...
if (lock!=NULL) {
do something;
omp_unset_lock(&lock);
}

this will give a compile error in gcc: no match operator !=
however, straight pass in icpc.
"lock!=NULL" looks wrong, but somehow icpc understands, though the program still crashes at last.

Can anyone tell me what does "lock!=NULL" exactly mean to do (possiblely allowed in older version of OMP?) and how to correct it?

many thanks
mononoke
 
Posts: 1
Joined: Tue Jun 03, 2008 5:27 am

Re: no match operator

Postby ejd » Tue Jun 03, 2008 6:39 am

You can not be sure how an implementation is going to defined "omp_lock_t" (the type of a lock). The OpenMP spec doesn't say exactly what this is - which allows an implementation to defined it. It could be a pointer to a structure or it could be a structure. That is why in one implementation writing "lock != NULL" will work and in another implementation it won't. I am not sure exactly what they are trying to do. From your code segment, it looks as though they are trying to see if the lock is set - since they are doing something and then calling unlock. This is not the way to do it though. They should be using either omp_set_lock or omp_test_lock. The OpenMP spec is quite clear and states in the lock routines section "an OpenMP lock variable must be accessed only through the routines described in this section". Checking to see if the lock variable is set to NULL this way makes the program non-OpenMP compliant.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: no match operator

Postby djo35 » Thu Jun 05, 2008 3:22 am

Hello mononoke,

> this will give a compile error in gcc: no match operator !=
> however, straight pass in icpc.

A copy of your compiler error might be helpful. If gcc can't understand the 'NULL' statement you probably need to add
#include <stdlib.h>
to the top of your source file.

> Can anyone tell me what does "lock!=NULL" exactly mean to do
This means "if 'lock' is not NULL then proceed"m ie "if this isn't locked do something"

djo
djo35
 
Posts: 11
Joined: Wed May 28, 2008 8:24 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 13 guests