- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
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);
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Every suggestion is welcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - remex1980
Every suggestion is welcome.
I'm not sure what you're trying to do.
You can use openmp locks. You should #include
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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page