call-operatorhttps://software.intel.com/en-us/tags/23033/all
enIntel ArBB Segregated Storage and Data Copieshttps://software.intel.com/en-us/articles/intel-arbb-segregated-storage-and-data-copies
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p><strong>Summary</strong><br />This article will answer the question when and how many copies occur for the inputs and outputs of an Intel ArBB function. This article is based on a webinar, the material of the webinar can be found <a href="/en-us/articles/arbb-webinar-feb-22-2011" rel="nofollow">here</a>.<br /><br /><strong>Intel ArBB Functions<br /></strong>First of all, we need to have a closer look at the term "Intel ArBB function".<br /><br /><strong><span>void arbb_function(<em>signature</em>);</span></strong><br /><br /><strong>void:</strong> multiple values can be returned</p>
<ul><li>Via argument list</li>
</ul><p><strong><em>Signature</em>:</strong><br /><strong>outputs</strong> or <strong>in-outs</strong> are passed</p>
<ul><li>By "non-const reference<strong>"</strong></li>
</ul><p><strong>inputs</strong> are passed</p>
<ul><li>By "const reference", or</li>
<li>By-value</li>
</ul><p><strong>Types:</strong> Intel ArBB types</p>
<ul><li>scalars,</li>
<li>containers, and</li>
<li><a href="/sites/products/documentation/arbb/arbb_userguide_lnx/GUID-4CF06011-3F98-4C8A-BE34-90C732E33DE4.htm" rel="nofollow">user-defined types</a></li>
</ul><p>An Intel ArBB function is a C/C++ function as shown above which can be called using the Intel ArBB call-operator.<br /><br /><strong>Intel ArBB Call-Operator<br /></strong>The figure below is illustrating the Just-In-Time (JIT) compilation process as invoked by the call-operator.<br /><img src="/sites/default/files/m/d/4/1/d/8/jit-compiler-and-native-code-generation.png" alt="jit-compiler-and-native-code-generation.png" title="jit-compiler-and-native-code-generation.png" width="50%" /><br />The vertical line is similar to the time axis first showing the "as-if" execution, followed by the generation of an Intermediate Representation (IR) of the code. On the right hand side of the time axis, the execution is ready to proceed with the supplied actual arguments. The variable named "my_function" (green) is a pointer to a function, it is only called by the call-operator when it is seen the first time to actually collect the IR of an Intel ArBB function. The function pointer is also a key value used for the caching of the generated code. Passing the same function pointer again to the call-operator will immediately proceed with the native execution of the JIT-generated code.<br /><br />Please note, when turning the Intel ArBB runtime into the emulation mode (ARBB_EMULATE=1, or ARBB_OPT_LEVEL=O0), the call-operator looks the same except that the "as-if" execution will actually execute the effect of the Intel ArBB function (no JIT-compilation, serial execution).<br /><br /><strong>Bind Interface<br /></strong>Making use of one of the overloaded Intel ArBB bind functions is subject of the "bind interface". The bind interface can be used to bind a buffer to a default-constructed dense container. Passing such a container into an Intel ArBB function is subject of data copies into the segregated Intel ArBB data storage space. A distinction can be made between "copy-in" and "copy-out" with respect to the inputs and outputs of an Intel ArBB function. Please note, an in-out argument is subject of two copies in cases where the argument is actually used as an input of an Intel ArBB function. Using an in-out argument only on the left hand side (lhs, or destination) can prevent the "copy-in".<br /><br /><em>A "copy-in" occurs every time on each input (including an in-out which is used as an input) when calling an Intel ArBB function. A "copy-out" occurs every time on each output (including an in-out used as an output) when calling an Intel ArBB function. Calling an ArBB function is meant to happen via the call-operator (not in emulation mode), or meant to be directly using a closure. (Note, that unused arguments do not fall under these rules. Further, this only applies to the native execution and not the the emulation mode of Intel ArBB)</em><br /><br />Copies are omitted when all of the following conditions are met:</p>
<ul><li>Sufficient aligmnent according to the Intel ArBB malloc functions</li>
<li>Default pattern specified when calling bind (no stride/pitch)</li>
<li>Non-remote execution</li>
</ul><p>To summarize, whether copies are made or not is depending on:</p>
<ul><li>Signature of the bind function, i.e. when using user-defined types (UDTs), or explicitly using a non-default pitch (stride)</li>
<li>Where the execution happens, i.e. on the host-side, or as a remote execution (e.g. in case of executions targeting Intel® MIC architecture)</li>
<li>Sufficient buffer alignment</li>
</ul><p>One can <strong>explicitly</strong> avoid these copies by using the range interface which consists of the following dense container methods:</p>
<ul><li>write_only_range()</li>
<li>read_only_range()</li>
<li>read_write_range()</li>
</ul><p>To write a correct Intel ArBB program, these methods must be used in order to make sure bound buffers are updated accordingly. This mechanism is helping to avoid automatic "copy-in" and automatic "copy-out" per use of the call-operator. This also applies to successive calls when proceeding with a dense container argument previously involved into an Intel ArBB call. Intel ArBB might enforce the use of the above three methods in the future such that one cannot rely on an automatically updated buffer when returning from the execution of the Intel ArBB call-operator.<br /><br /><strong>Memory Mapping or Range Interface<br /></strong>Dense containers with an initial size given at construction time are subject of being used together with the memory mapping interface. Since there are no host-side buffers explicitly bound to such dense containers, there is no need to keep such buffers updated automatically. Dense containers constructed with an initial size are correctly aligned in memory. The memory mapping interface (which is also called the "range interface") consists of the same three methods (write_only_range, read_only_range, read_write_range) which are already described in the above section (bind interface section).</p></div></div></div>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/soa-17891/language/en?query">SOA</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/webinar-18588/language/en?query">webinar</a> </li>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/bind-21768/language/en?query">bind</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/alignment-23025/language/en?query">alignment</a> </li>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/jit-17515/language/en?query">JIT</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/aos-22793/language/en?query">AOS</a> </li>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/code-tips-23026/language/en?query">code tips</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/range-23027/language/en?query">range</a> </li>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/copy-in-23028/language/en?query">copy-in</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/copy-out-23029/language/en?query">copy-out</a> </li>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/stride-23030/language/en?query">stride</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/pitch-23031/language/en?query">pitch</a> </li>
<li class="field-item even" rel="dc:subject">
<a href="/en-us/search/site/field_tags/memory-mapping-23032/language/en?query">memory mapping</a> </li>
<li class="field-item odd" rel="dc:subject">
<a href="/en-us/search/site/field_tags/call-operator-23033/language/en?query">call-operator</a> </li>
<li class="field-item even">
<a href="/en-us/search/site/language/en?query=WhatIf%20Software">WhatIf Software</a> </li>
<li class="field-item even">
<a href="/en-us/search/site/language/en?query=Optimization">Optimization</a> </li>
<li class="field-item odd">
<a href="/en-us/search/site/language/en?query=Parallel%20Computing">Parallel Computing</a> </li>
<section class="field field-name-field-theme-zone field-type-list-text field-label-above"><h2 class="field-label">Theme Zone:&nbsp;</h2><div class="field-items"><div class="field-item even">IDZone</div></div></section>Thu, 08 Mar 2012 04:30:17 +0000mad\hpabst182625 at https://software.intel.com