Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

CLOMP: kmp_lock_cond_wait runtime ERROR

remex1980
Beginner
336 Views
I wrote a CLOMP program under Redhat Enterprise 4. All OpenMP programs runs smoothly. A cluster openmp program works well, if the lock api is not called.
However, when the program reached to kmp_lock_cond_wait, a runtime error will be output, and the process will be terminated.

I really need to add the lock feature to my cluster OpenMP program. It seems that kmp_lock_cond_wait is the only choice for me.

I really appreciate your help. Thanks in advance.

Error imformations:
Cluster OMP Fatal: Proc#0 Thread#0 (INITIAL): A lock (lock=39) was needed but
not held for the operation in ../src/lock.c at line 1497.


Code:

#include

omp_lock_t *pLock = NULL;

pLock = (omp_lock_t *)kmp_sharable_malloc(sizeof(omp_lock_t));

omp_init_lock(pLock);

#pragma omp parallel num_threads(4) shared(pLock)
{
kmp_lock_cond_wait(pLock);
printf("Thread locked\n");
kmp_lock_cond_signal(pLock);
}

omp_destroy_lock(pLock);
kmp_sharable_free(pLock);
0 Kudos
2 Replies
remex1980
Beginner
336 Views
Every suggestion is welcome.
0 Kudos
Lawrence_M_Intel
Employee
336 Views
Quoting - remex1980
Every suggestion is welcome.

I'm not sure what you're trying to do.

You can use openmp locks. You should #include . See the Intel documentation or the OpenMP 3.0 specification at http://openmp.org/wp/openmp-specifications/

To acquire a lock
omp_set_lock

To check for availability of a lock:
omp_try_lock

To release a lock:
omp_unset_lock

OpenMP does not provide condition variables. Regular OpenMP locks should work fine with Cluster OpenMP.

Hopefully this will work for you.

Regards,

Larry Meadows
lawrence.f.meadows@intel.com
0 Kudos
Reply