- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Does Cilk Plus support fake_mutex? I could not find it in the documentation or language specification. Thanks.
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
fake_mutex isn't part of the language. It's a feature of theCilk screen race detector, and shipped with the Cilk Plus SDK which you can download for free from http://software.intel.com/en-us/articles/intel-cilk-plus-software-development-kit/.
- Barry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which header file should I import? My include directory does not have cilk/fake_lock.h. I'm usingcomposer_xe_2011_sp1.7.256. Thanks.
Yod
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First you need to install the Cilk Plus SDK as I stated in the previous reply. Then you can install cilktools/fake_mutex. Here's one of our test programs as an example:
#include#include #include #include #include int x; void race(void) { x = 0; } void lock_and_race (cilkscreen::fake_mutex *m) { m->lock(); race(); m->unlock(); } void test_bare_fake_lock(void) { printf ("test_bare_fake_lock\n"); cilkscreen::fake_mutex *m = cilkscreen::create_fake_mutex(); cilk_spawn lock_and_race(m); cilk_spawn lock_and_race(m); cilk_spawn lock_and_race(m); cilk_spawn lock_and_race(m); cilk_sync; cilkscreen::destroy_fake_mutex(m); } void guard_and_race (cilkscreen::fake_mutex *m) { cilkscreen::lock_guard<:FAKE_MUTEX> guard(*m); race(); } void test_guarded_fake_lock(void) { printf ("test_guarded_fake_lock\n"); cilkscreen::fake_mutex *m = cilkscreen::create_fake_mutex(); cilk_spawn guard_and_race(m); cilk_spawn guard_and_race(m); cilk_spawn guard_and_race(m); cilk_spawn guard_and_race(m); cilk_sync; cilkscreen::destroy_fake_mutex(m); } int main (int argc, char *argv[]) { test_bare_fake_lock(); test_guarded_fake_lock(); printf("done\n"); return 0; }
- Barry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Barry,
When i try to compile this program (named mutex.cpp), i have the following errors :
$ icpc -pthread -o mutex mutex.cpp -lcilkrts
/home/amina/projet/cilkplus-install/include/cilktools/fake_mutex.h(62): error: argument of type "const char *" is incompatible with parameter of type "void *"
__cilkscreen_acquire_lock(&lock_val);
^
/home/amina/projet/cilkplus-install/include/cilktools/fake_mutex.h(71): error: argument of type "const char *" is incompatible with parameter of type "void *"
__cilkscreen_release_lock(&lock_val);
^
compilation aborted for mutex.cpp (code 2)
I attached the files : fake_mutex.h and cilkscreen.h.
But when i compile it with the command g++, it works fine (g++ -pthread -o mutex mutex.cpp -lcilkrts). (for notes : i use the gcc 4.7.0 version).
Have you a fix for this ?
Thank you,
When i try to compile this program (named mutex.cpp), i have the following errors :
$ icpc -pthread -o mutex mutex.cpp -lcilkrts
/home/amina/projet/cilkplus-install/include/cilktools/fake_mutex.h(62): error: argument of type "const char *" is incompatible with parameter of type "void *"
__cilkscreen_acquire_lock(&lock_val);
^
/home/amina/projet/cilkplus-install/include/cilktools/fake_mutex.h(71): error: argument of type "const char *" is incompatible with parameter of type "void *"
__cilkscreen_release_lock(&lock_val);
^
compilation aborted for mutex.cpp (code 2)
I attached the files : fake_mutex.h and cilkscreen.h.
But when i compile it with the command g++, it works fine (g++ -pthread -o mutex mutex.cpp -lcilkrts). (for notes : i use the gcc 4.7.0 version).
Have you a fix for this ?
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a known problem in cilkscreen.h that is fixed in a future version of the tools. You can fix it your version by modifying the definition of __cilkscreen_metacall in your copy:
/*
* Cilkscreen "functions". These macros generate metadata in your application
* to notify Cilkscreen of program state changes
*/
#if ! defined(CILK_STUB) && defined(__INTEL_COMPILER)
# define __cilkscreen_metacall(annotation,expr) \
__notify_intrinsic((char *)annotation,expr)
#else
# define __cilkscreen_metacall(annotation,expr) (annotation, (void) (expr))
#endif
- Barry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Barry, it works fine :)

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