<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">It is an efficiency issue. It requires copying entire array into the block descriptor.<div>- Fariborz</div><div><br><div><div>On Jun 19, 2013, at 2:53 AM, "Adler, Arik" <<a href="mailto:arik.adler@intel.com">arik.adler@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="blue" vlink="purple" style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">I am now testing blocks usage in OpenCL.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">I noticed that Clang forbids using an arrays within blocks (Clang forbid array capturing)<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">For Example, the following code will fail to compile because there is a reference to an array within a block.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">But if the line referring to block will comment out and the line with reference to integer pointer ('j') will comment in, the code will pass.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">void</span><span style="font-size: 9.5pt; font-family: Consolas;"><span class="Apple-converted-space"> </span>block_arr()<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span><span style="color: blue;">int</span><span class="Apple-converted-space"> </span>res = 0;<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span><span style="color: blue;">int</span><span class="Apple-converted-space"> </span>i[4] = { 3, 4, 4, 1 };<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span><span style="color: blue;">int</span>* j = i;<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> <o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">int</span><span class="Apple-converted-space"> </span>(^test_block )(<span style="color: blue;">int</span>) = ^(<span style="color: blue;">int</span><span class="Apple-converted-space"> </span>num)<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> {<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span><span style="color: blue;">return</span><span class="Apple-converted-space"> </span>num + i[1]; <span class="Apple-converted-space"> </span><span style="color: green;">// This is an error: "error: cannot refer to declaration with an array type inside block"</span><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// return num + j[1]; // This would work</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> };<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> </span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;"> res = test_block(7);<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt 1in; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">Do you know what is the reason behind this limitation?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">And why it is possible to use a regular pointers but arrays are forbidden?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);"> </span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">Thanks,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; text-align: left; direction: ltr; unicode-bidi: embed; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(31, 73, 125);">Arik<o:p></o:p></span></div></div><p>---------------------------------------------------------------------<br>Intel Israel (74) Limited</p><p>This e-mail and any attachments may contain confidential material for<br>the sole use of the intended recipient(s). Any review or distribution<br>by others is strictly prohibited. If you are not the intended<br>recipient, please contact the sender and delete all copies.</p>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu" style="color: purple; text-decoration: underline;">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" style="color: purple; text-decoration: underline;">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></div></blockquote></div><br></div></body></html>