<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Writing on file using fake mutex class in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741550#M636</link>
    <description>&lt;P&gt;Here's one example: &lt;/P&gt;
&lt;PRE&gt;
#include &lt;CILK&gt;
#include &lt;TBB&gt;
#include &lt;STDIO.H&gt;
#include &lt;STDARG.H&gt;

tbb::spin_rw_mutex countMutex;

int foo()
{
   int z=0;
   cilk_for (int i = 0; i &amp;lt; 10; i++)
   {
       tbb::spin_rw_mutex::scoped_lock lock(countMutex);
       z *= i;
   }
   return z;
}

int main()
{
    foo();
    return 0;
}
&lt;/STDARG.H&gt;&lt;/STDIO.H&gt;&lt;/TBB&gt;&lt;/CILK&gt;&lt;/PRE&gt;&lt;P&gt;Note that support for TBB spinlocks required additional support in Cilkscreen. I confess I'm not sure if we've released that version yet.  TBB locks that use OS mutexes should be fine.&lt;/P&gt;&lt;P&gt;- Barry&lt;/P&gt;</description>
    <pubDate>Mon, 09 Apr 2012 14:27:24 GMT</pubDate>
    <dc:creator>Barry_T_Intel</dc:creator>
    <dc:date>2012-04-09T14:27:24Z</dc:date>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741546#M632</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have to coordinate access to write on file from multiple concurrent workers.&lt;BR /&gt;&lt;BR /&gt;So, i use the fake mutex class, but it doesn't work. the file is not correctly wrinting (workers interrupt to write).&lt;BR /&gt;&lt;BR /&gt;cilkscreen::fake_mutex *a = cilkscreen::create_fake_mutex();   &lt;BR /&gt;a-&amp;gt;lock(); &lt;BR /&gt;&lt;BR /&gt;  gpfgout-&amp;gt;printSet(vars.gnprefix_len(), vars.gpprefix_itemset(), nsupport); &lt;BR /&gt;&lt;BR /&gt;a-&amp;gt;unlock(); &lt;BR /&gt;cilkscreen::destroy_fake_mutex(a);&lt;BR /&gt;&lt;BR /&gt;Is it correct to use fake mutex class to write on file ? or there is another class that allows writng on file ?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance,</description>
      <pubDate>Sat, 31 Mar 2012 13:44:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741546#M632</guid>
      <dc:creator>amina-jarraya</dc:creator>
      <dc:date>2012-03-31T13:44:15Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741547#M633</link>
      <description>&lt;P&gt;The fake_mutex class isn't intended to be real mutexes. They're... fake. They only signal the Cilkscreen race detector that a race is benign and can be ignored.&lt;/P&gt;&lt;P&gt;From the fake_mutex.h header file:&lt;/P&gt;&lt;PRE&gt; * Cilkscreen fake mutexes are provided to indicate to the Cilkscreen race
 * detector that a race should be ignored.

&lt;/PRE&gt;&lt;P&gt;To coordinate between multiple workers or threads, you need to use "real" mutexes.You should look at the mutexes supplied by the OS you're running on (mutex on Linux, CRITICAL_SECTION on Windows). You can use cilkscreen::lock_guard with these if you wrap them in a class which provides the same methods as cilkscreen::fake_mutex.&lt;/P&gt;&lt;P&gt;You should also look at the OS-independent mutexes provided by TBB.&lt;/P&gt;&lt;P&gt;- Barry&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2012 13:54:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741547#M633</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2012-04-02T13:54:38Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741548#M634</link>
      <description>&lt;P&gt;I've modified fake_mutex.h to make it clearer that this class does not provide mutual exclusion. &lt;/P&gt;&lt;P&gt;Also, if you're attempting to write to a file from multiple strands, you might want to look at reducer_ostream, which is intended for exactly this situation &lt;/P&gt;&lt;P&gt;- Barry&lt;/P&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Apr 2012 13:49:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741548#M634</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2012-04-03T13:49:32Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741549#M635</link>
      <description>Thank you for your answer,&lt;BR /&gt;&lt;BR /&gt;If fake mutex class does not provide mutual exclusion, so could you please show me an example to illustrate how can i use the TBB mutexes to lock/unlock sections (mutual exclusion) ?&lt;BR /&gt;&lt;BR /&gt;I found the follwing example :&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;#include &lt;CILK&gt;&lt;BR /&gt;#include &lt;TBB&gt;&lt;BR /&gt;#include &lt;IOSTREAM&gt;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; &lt;B&gt;  tbb::mutex mut;&lt;/B&gt;&lt;BR /&gt;   int sum = 0;&lt;BR /&gt;   cilk_for (int i=0; i&amp;lt;10; ++i)&lt;BR /&gt;   {&lt;BR /&gt;     mut.lock();&lt;BR /&gt;     sum = sum + i; // PROTECTED WITH LOCK&lt;BR /&gt;     mut.unlock();&lt;BR /&gt;   }&lt;BR /&gt;   std::cout &amp;lt;&amp;lt; "Sum is " &amp;lt;&amp;lt; sum &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/IOSTREAM&gt;&lt;/TBB&gt;&lt;/CILK&gt;&lt;/PRE&gt;If this example (cilkMutex.cpp) uses correctly TBB mutex, it doesn't compile, i have this error :&lt;BR /&gt;&lt;BR /&gt;amina@amina-laptop:~/projet/cilkplus-install/examples/test$ icpc -pthread -o cilkMutex cilkMutex.cpp -lcilkrts&lt;BR /&gt;/tmp/icpcyhnUVY.o: In function `main':&lt;BR /&gt;cilkMutex.cpp:(.text+0x12c): undefined reference to `tbb::internal::handle_perror(int, char const*)'&lt;BR /&gt;&lt;BR /&gt;Have you an idea for this problem ?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Apr 2012 14:20:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741549#M635</guid>
      <dc:creator>amina-jarraya</dc:creator>
      <dc:date>2012-04-09T14:20:16Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741550#M636</link>
      <description>&lt;P&gt;Here's one example: &lt;/P&gt;
&lt;PRE&gt;
#include &lt;CILK&gt;
#include &lt;TBB&gt;
#include &lt;STDIO.H&gt;
#include &lt;STDARG.H&gt;

tbb::spin_rw_mutex countMutex;

int foo()
{
   int z=0;
   cilk_for (int i = 0; i &amp;lt; 10; i++)
   {
       tbb::spin_rw_mutex::scoped_lock lock(countMutex);
       z *= i;
   }
   return z;
}

int main()
{
    foo();
    return 0;
}
&lt;/STDARG.H&gt;&lt;/STDIO.H&gt;&lt;/TBB&gt;&lt;/CILK&gt;&lt;/PRE&gt;&lt;P&gt;Note that support for TBB spinlocks required additional support in Cilkscreen. I confess I'm not sure if we've released that version yet.  TBB locks that use OS mutexes should be fine.&lt;/P&gt;&lt;P&gt;- Barry&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 14:27:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741550#M636</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2012-04-09T14:27:24Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741551#M637</link>
      <description>Thank you for your quick answer,&lt;BR /&gt;&lt;BR /&gt;I have the following error when compiling your example code :&lt;BR /&gt;&lt;BR /&gt;amina@amina-laptop:~/projet/cilkplus-install/examples/test$ icpc -pthread -o cilkMutex cilkMutex.cpp -lcilkrts&lt;BR /&gt;/tmp/icpcMfVTwe.o: In function `__$U0':&lt;BR /&gt;cilkMutex.cpp:(.text+0xe8): undefined reference to `tbb::spin_rw_mutex_v3::internal_acquire_writer()'&lt;BR /&gt;&lt;BR /&gt;have you an idea for this error ?</description>
      <pubDate>Mon, 09 Apr 2012 14:48:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741551#M637</guid>
      <dc:creator>amina-jarraya</dc:creator>
      <dc:date>2012-04-09T14:48:40Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741552#M638</link>
      <description>&lt;P&gt;You need to be linking against libtbb.so.&lt;/P&gt;&lt;P&gt;Here's the command I use to build this application on Linux:&lt;/P&gt;&lt;PRE&gt;icpc -I /home/nsl/bmtannen/project/cilkdev/linux/eng/cilkrts/unix-build/include \
-I /home/nsl/bmtannen/project/cilkdev/linux/eng/cilkrts/unix-build/../include \
-I /home/nsl/bmtannen/project/cilkdev/linux/tbb30_20110427oss/include \
&lt;SPAN style="color: red;"&gt;-D TBB_USE_THREADING_TOOLS=1&lt;/SPAN&gt;
-L /home/nsl/bmtannen/project/cilkdev/linux/eng/cilkrts/unix-build/linux64/lib -lcilkrts
&lt;SPAN style="color: red;"&gt;-L /home/nsl/bmtannen/project/cilkdev/linux/tbb30_20110427oss/build/linux_intel64_gcc_cc4.5.2_libc2.13_kernel2.6.38_debug \
-ltbb_debug&lt;/SPAN&gt; \
-o tbb-test tbb-test.cpp

&lt;/PRE&gt;&lt;P&gt;I've pulled down the TBB sources and built them myself.Your path the the TBB librarywill be different. You also probably don't need to specify the directory for the Cilk runtime.&lt;BR /&gt;&lt;BR /&gt;TBB_USE_THREADING_TOOLS needs to be defined to make sure that the notifications that Cilkscreen uses will be present.&lt;/P&gt;&lt;P&gt;- Barry&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 20:45:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741552#M638</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2012-04-09T20:45:18Z</dc:date>
    </item>
    <item>
      <title>Writing on file using fake mutex class</title>
      <link>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741553#M639</link>
      <description>Thank you Barry,&lt;BR /&gt;It works fine, i use this command :&lt;BR /&gt;&lt;BR /&gt;icpc -D TBB_USE_THREADING_TOOLS=1 -L /home/amina/Bureau/sourcesTBB/tbb30/build/linux_ia32_gcc_cc4.4.3_libc2.11.1_kernel2.6.32_debug/ -ltbb_debug -o TBB TBB.cpp -pthread -lcilkrts&lt;BR /&gt;&lt;BR /&gt;To lock sections, i use the follwing code inside the loop for :&lt;BR /&gt;&lt;BR /&gt;myMutex::scoped_lock lock;&lt;BR /&gt;lock.acquire(sm);&lt;BR /&gt; &lt;BR /&gt;z *= i;&lt;BR /&gt;&lt;BR /&gt;lock.release();&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 14 Apr 2012 16:42:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Writing-on-file-using-fake-mutex-class/m-p/741553#M639</guid>
      <dc:creator>amina-jarraya</dc:creator>
      <dc:date>2012-04-14T16:42:15Z</dc:date>
    </item>
  </channel>
</rss>

