<?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 Cilk worker size deque  in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976443#M25072</link>
    <description>I understand that each worker in Cilk has its own deque from which it pops frames to work on and to which it pushes frames.

Is there any way I could somehow display/print/get/obtain the number of frames in a worker’s deque at any point i.e. the size of a worker’s deque? 

I have dug into Cilk runtime code (scheduler.c, global_state.cpp, stacks.c, local_state.h … just to name few) and could not recognize anything that would give me such information. Push and pop functions only work on next_frame that is just a pointer to a struct of full_frame type.

Thank you.</description>
    <pubDate>Wed, 20 Mar 2013 00:56:16 GMT</pubDate>
    <dc:creator>Haris_R_1</dc:creator>
    <dc:date>2013-03-20T00:56:16Z</dc:date>
    <item>
      <title>Cilk worker size deque</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976443#M25072</link>
      <description>I understand that each worker in Cilk has its own deque from which it pops frames to work on and to which it pushes frames.

Is there any way I could somehow display/print/get/obtain the number of frames in a worker’s deque at any point i.e. the size of a worker’s deque? 

I have dug into Cilk runtime code (scheduler.c, global_state.cpp, stacks.c, local_state.h … just to name few) and could not recognize anything that would give me such information. Push and pop functions only work on next_frame that is just a pointer to a struct of full_frame type.

Thank you.</description>
      <pubDate>Wed, 20 Mar 2013 00:56:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976443#M25072</guid>
      <dc:creator>Haris_R_1</dc:creator>
      <dc:date>2013-03-20T00:56:16Z</dc:date>
    </item>
    <item>
      <title>The number of frames in the</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976444#M25073</link>
      <description>&lt;P&gt;The number of frames in the deque of a worker w should roughly be w-&amp;gt;tail - w-&amp;gt;head. That value might be off slightly, depending on whether you want to count a worker's currently executing __cilkrts_stack_frame as being on the deque or not, and what exactly tail points to (i.e., does it point to an empty slot or the currently executing frame).&lt;/P&gt;
&lt;P&gt;I don't remember off the top of my head which way the tail is currently maintained, but I would look at the comments in scheduler.c, in the section labeled "THE protocol" for more information. Section 10.6 of the ABI also describes what happens on a spawn, where the tail pointer is incremented in __cilkrts_detach. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.cilkplus.org/sites/default/files/open_specifications/CilkPlusABI_1.1.pdf"&gt;http://www.cilkplus.org/sites/default/files/open_specifications/CilkPlusABI_1.1.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The push and pop of full frames you are seeing in the runtime code have nothing to do with the worker's deques. &lt;BR /&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 02:39:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976444#M25073</guid>
      <dc:creator>Jim_S_Intel</dc:creator>
      <dc:date>2013-03-20T02:39:00Z</dc:date>
    </item>
    <item>
      <title>A word of caution. </title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976445#M25074</link>
      <description>&lt;P&gt;A word of caution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additions to the deque happen when a cilk_spawn is executed.&amp;nbsp; The __cilkrts_stack_frame of the function doing the spawn is pushed onto the tail of the deque.&amp;nbsp; See the __cilkrts_detach logic in the ABI document Jim referenced for the details.&lt;/P&gt;
&lt;P&gt;Frames are removed from the deque from &lt;STRONG&gt;*both*&lt;/STRONG&gt; ends:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Code executing on the worker will remove entries from the tail when a spawned function who's parent has not been stolen returns.&amp;nbsp; See __cilkrts_undo_detach in cilk-abi.c for the code.&lt;/LI&gt;
&lt;LI&gt;Other workers may steal frames from the head of the deque at any time, assuming that there are frames to steal.&amp;nbsp; That's the code involving the THE protocol that Jim mentioned.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So the number you get by calculating w-&amp;gt;tail - w-&amp;gt;head is only correct at that instance, since w-&amp;gt;head may change at any time as a result of a successful steal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Barry&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 13:24:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976445#M25074</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2013-03-20T13:24:27Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976446#M25075</link>
      <description>Hello, 

first and foremost, thank you for the prompt answer

I could not find the function you mentioned in 10.6  
“void __cilkrts_detach(struct __cilkrts_stack_frame *sf);”.

These are 2 functions with “detach” in header name that could I find:
cilk-abi.c
/* Return true if undo-detach failed. */
static int __cilkrts_undo_detach(__cilkrts_stack_frame *sf)
scheduler.c
/* detach the top of the deque frame from the VICTIM and install a new CHILD frame in its place */
static void detach(__cilkrts_worker *w, __cilkrts_worker *victim, __cilkrts_stack *sd)

The idea of taking “w-&amp;gt;tail  - w-&amp;gt;head” sounded great and I tried it in a number of places in scheduler.c and the only number I get back is either 8 or 0.
I used the method from “static int can_steal_from(__cilkrts_worker *victim)”
(unsigned long)(victim-&amp;gt;tail) - (unsigned long)victim-&amp;gt;head

In addition to the above, I tried casting to other types without any success.</description>
      <pubDate>Wed, 20 Mar 2013 18:27:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976446#M25075</guid>
      <dc:creator>Haris_R_1</dc:creator>
      <dc:date>2013-03-20T18:27:13Z</dc:date>
    </item>
    <item>
      <title>&gt; I could not find the</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976447#M25076</link>
      <description>&lt;P&gt;&amp;gt; I could not find the function you mentioned in 10.6&lt;BR /&gt;&amp;gt; “void __cilkrts_detach(struct __cilkrts_stack_frame *sf);”.&lt;/P&gt;
&lt;P&gt;There is no implementation of __cilkrts_detach in the runtime. &amp;nbsp;It's always inlined by the compiler when it builds the spawn helper. &amp;nbsp;The only implementation is in section 10.6 of the ABI document.&lt;/P&gt;
&lt;P&gt;To test this, I'd run with a single worker so you're sure there are no steals going on to confuse you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; - Barry&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 19:05:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976447#M25076</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2013-03-20T19:05:12Z</dc:date>
    </item>
    <item>
      <title>Hello, thank you for the</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976448#M25077</link>
      <description>Hello, thank you for the previous responses.
So “__cilkrts_undo_detach()” is the function that pops from the tail of a worker’s deque while “__cilkrts_detach” is the one that pushes onto the deque.
Could you briefly explain the purpose of the push and pop of full frame structures in scheduler.c? I fail to make connection here.
When calling “static void detach()” from scheduler.c, it points victim’s full frame as a worker’s next frame and why not push __cilkrts_stack_frame onto the worker’s deque</description>
      <pubDate>Thu, 21 Mar 2013 17:33:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976448#M25077</guid>
      <dc:creator>Haris_R_1</dc:creator>
      <dc:date>2013-03-21T17:33:35Z</dc:date>
    </item>
    <item>
      <title>The short answer is that</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976449#M25078</link>
      <description>&lt;P&gt;The short answer is that there is not an obvious connection between full_frame and __cilkrts_stack_frame objects.&amp;nbsp;&amp;nbsp; If all you care about is figuring out what is currenly on the deque, you don't need to worry about those methods.&lt;/P&gt;
&lt;P&gt;The "push" and "pop" functions you are seeing in scheduler.c are related to the one-element "queue" of full frames that a worker maintains.&amp;nbsp;&amp;nbsp; The runtime uses this push and pop to guarantee that the worker that enters the topmost Cilk region in a program is the same one that leaves the region.&lt;/P&gt;
&lt;P&gt;Stack frames (__cilkrts_stack_frame) and full frames (full_frame) are described in the following paper:&lt;BR /&gt;&lt;A href="http://dl.acm.org/citation.cfm?id=1584017"&gt;http://dl.acm.org/citation.cfm?id=1584017&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Most of this paper is about reducers, but there is a description of the runtime at the beginning of Section 4 of stack frames and full frames.&amp;nbsp;&amp;nbsp; The paper is talking about the implementation of Cilk++, but since Cilk Plus is derived from Cilk++, most of the ideas still apply.&lt;BR /&gt;&lt;BR /&gt;Roughly speaking, a full frame object only gets created on every steal, while a __cilkrts_stack_frame object&amp;nbsp;is created for every spawning function and every time a function is spawned.&amp;nbsp;&amp;nbsp; In principle, one could have created a runtime that uses full frames for everything, but that is more expensive than necessary.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 18:24:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976449#M25078</guid>
      <dc:creator>Jim_S_Intel</dc:creator>
      <dc:date>2013-03-21T18:24:02Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976450#M25079</link>
      <description>Hello,

I understand that there is no implementation of “__cilkrts_detach” in the runtime. It is inlined by the compiler when it builds the spawn helper and the only implementation is in section 10.6 of the ABI document.

Also, “__cilkrts_undo_detach()” is the function that pops from the tail of a worker’s deque while “__cilkrts_detach” is the one that pushes onto the deque.

Is there any place in runtime code that would allow me to get notified (in any way possible) when a worker pushes an item onto its deque? Basically, I would like to know when a worker pushes something onto its deque.

Thank you again.</description>
      <pubDate>Tue, 26 Mar 2013 10:55:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976450#M25079</guid>
      <dc:creator>Haris_R_1</dc:creator>
      <dc:date>2013-03-26T10:55:35Z</dc:date>
    </item>
    <item>
      <title>For better or for worse, the</title>
      <link>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976451#M25080</link>
      <description>&lt;P&gt;For better or for worse, the answer is no.&amp;nbsp; Since __cilkrts_detach() is inlined, there is no call into the runtime in a spawn helper until the call to __cilkrts_leave_frame(), at least with code generated by the Intel compiler.&lt;/P&gt;
&lt;P&gt;GCC may be generating calls to __cilkrts_enter_frame(), but those are subject to inlining too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Barry&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2013 13:48:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cilk-worker-size-deque/m-p/976451#M25080</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2013-03-26T13:48:49Z</dc:date>
    </item>
  </channel>
</rss>

