<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Intel Software Network Blogs &#187; Software Engineering</title>
	<atom:link href="http://software.intel.com/en-us/blogs/category/software-engineering/feed/" rel="self" type="application/rss+xml" />
	<link>http://software.intel.com/en-us/blogs</link>
	<description></description>
	<pubDate>Wed, 25 Nov 2009 17:07:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>Issues of 64-bit code in real programs: virtual functions</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/23/issues-of-64-bit-code-in-real-programs-virtual-functions/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/23/issues-of-64-bit-code-in-real-programs-virtual-functions/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 00:03:15 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[64-bit migration]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[PVS-Studio]]></category>

		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/23/issues-of-64-bit-code-in-real-programs-virtual-functions/</guid>
		<description><![CDATA[So, if you download the demo-version of this library, install it and search the word "WinHelp" through .h-files… you will see that everywhere this function is supposedly overlapped, DWORD parameter is used instead of DWORD_PTR. And this means that Help system in these classes will behave incorrectly on a 64-bit system.]]></description>
			<content:encoded><![CDATA[<p>We have already written in our articles about one of the problems of code migration to 64-bit systems relating to incorrect overload of virtual functions. For example, our article "<a href="http://www.viva64.com/art-1-2-599168895.html">20 issues of porting C++ code on the 64-bit platform</a>" was published in March, 2007 (although is still relevant). It described the issue of virtual functions. The point of the problem consists in the following. There is CWinApp class in MFC library which has WinHelp function:<br />
class CWinApp {<br />
...<br />
virtual void WinHelp(DWORD dwData, UINT nCmd);<br />
};</p>
<p>This function must be overlapped to allow showing its own Help in a user application:<br />
class CSampleApp : public CWinApp {<br />
...<br />
virtual void WinHelp(DWORD dwData, UINT nCmd);<br />
};</p>
<p>Everything went alright until 64-bit systems appeared. And MFC developers had to change the interface of WinHelp function (and some other functions) in this way:<br />
class CWinApp {<br />
...<br />
virtual void WinHelp(DWORD_PTR dwData, UINT nCmd);<br />
};</p>
<p>In 32-bit mode DWORD_PTR and DWORD types coincided but in 64-bit one... Of course developers of user applications, too, had to change the type to DWORD_PTR for correct overload but the compiler did not inform about this and the error appeared only at the stage of testing when Help system began to behave "mysteriously". To learn the details I refer you to the article mentioned above.</p>
<p>What made me recall this error? The fact that now, in the end of 2009, this error is still present in the code of real applications. You doubt?</p>
<p>There is an excellent component library <a href="http://www.bcgsoft.com/bcgcontrolbarpro.htm">BCGControlBar</a>. You must have heard about it because the components by BCGSoft Ltd are included into Microsoft Visual Studio 2008 Feature Pack. So, if you download the demo-version of this library, install it and search the word "WinHelp" through .h-files... you will see that everywhere this function is supposedly overlapped, DWORD parameter is used instead of DWORD_PTR. And this means that Help system in these classes will behave incorrectly on a 64-bit system.</p>
<p>Can it really be true that this error is still in the code of such a popular library? I think the point is that the company's clients have access to source codes of this library and they can always introduce some corrections into it. Besides, WinHelp function is used very rarely nowadays. HtmlHelp is much more popular. And it does have the right parameter DWORD_PTR in BCGControlBar. But the fact remains: there is an error in a real code and the compiler will not detect it.</p>
<p>P.S. Analyzer PVS-Studio (Viva64) has been able to detect such errors from its very appearance, and Help system includes a detailed example (see description of error <a href="http://www.viva64.com/content/PVS-Studio-help-en/V301.html">V301</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/23/issues-of-64-bit-code-in-real-programs-virtual-functions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Magic constants and malloc() function</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/17/magic-constants-and-malloc-function/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/17/magic-constants-and-malloc-function/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 19:15:39 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Parallel Programming]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[64-bit migration]]></category>

		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/17/magic-constants-and-malloc-function/</guid>
		<description><![CDATA[Once again I would like to discuss the issue of using magic constants in code. We can eternally repeat that one should use sizeof() operator for correct calculation of the size of memory being allocated. But both this knowledge and correct writing of a new code will not help you detect an error already existing in the maze of the old code in large projects.]]></description>
			<content:encoded><![CDATA[<p>Once again I would like to discuss the issue of using magic constants in code. We can eternally repeat that one should use sizeof() operator for correct calculation of the size of memory being allocated. But both this knowledge and correct writing of a new code will not help you detect an error already existing in the maze of the old code in large projects. Let’s consider a typical example of an error:</p>
<pre>size_t nCount = 10;
int **poinerArray = (int **)malloc(nCount * 4);</pre>
<p>The code is incorrect but in a 32-bit system it will work correctly. The error can occur when adapting the program to a different software/hardware environment. It has become very urgent and important to detect such a code because of mass migration of software on 64-bit systems. Changing of the sizes of some base types makes a code like this very dangerous. Viva64 analyzer included into <a href="http://www.viva64.com/pvs-studio/">PVS-Studio</a> will show a warning about using magic constant “4″ on the code given above and an error will be detected when viewing the diagnostic warnings. But a code can be more complicated:</p>
<pre>#define N_COUNT 100
#define POINTER_SIZE 4
#define NSIZE (N_COUNT * POINTER_SIZE)

int **pArray = (int **)malloc(NSIZE);</pre>
<p>It is more difficult to diagnose an error in such a code written in C style with the use of #define. Although the code contains constant 4 defined by a macro, Viva64 analyzer is deliberately set so as to avoid showing warnings on such constructions. The analyzer ignores magic constants defined by macros (#define) due to two reasons. First, if a programmer defines constants through macros, he is likely to know what he is doing and a false response is very likely to occur. Second, if we react to constants which are dangerous from the viewpoint of a constant’s 64-bit mode (4, 8, 32 etc) we will have too many false responses relating to using Windows API. Let’s consider a harmless code as an example:</p>
<pre>MessageBox("Are you sure ?",
           "Some question",
           MB_YESNO | MB_ICONQUESTION);</pre>
<p>If we analyze the magic numbers hidden behind MB_YESNO and MB_ICONQUESTION macros there should be two warnings on using magic constants 4 and 32 on this line. Of course, it is too great a level of false responses. When analyzing malloc() function we can print all information about all dangerous magic constants without paying attention if it is a macro or not. But that is not enough anyway for the next case:</p>
<pre>int **pArray = (int **)malloc(400);</pre>
<p>If we go further and consider any number used in the expression for malloc() function unsafe it will cause false responses on a correct code:</p>
<pre>int **pArray = (int **)malloc(400 * sizeof(int *));</pre>
<p>On examining the situation, we have decided to introduce a new rule to verify applications whose result is transferred into malloc() function. At present, this rule reads as follows:</p>
<p><em>You should consider unsafe using numeric literals in the expression transferred into malloc() function. Exceptions:<br />
1) The expression contains sizeof() operator<br />
2) All the numeric literals divide by four with a remainder</em></p>
<p>Thanks to this rule we can warn about an error in the following code:<br />
1) The first example:</p>
<pre>void *p = malloc(nCount * 4);</pre>
<p>2) The second example:</p>
<pre>#define N_COUNT 100
#define POINTER_SIZE 4
#define NSIZE (N_COUNT * POINTER_SIZE)
int **pArray = (int **)malloc(NSIZE);</pre>
<p>And also avoid showing a false warning on the code like:<br />
1) The first example:</p>
<pre>void *p = malloc(sizeof(double) * 4);</pre>
<p>2) The second example:</p>
<pre>#define N_COUNT 100
#define POINTER_SIZE sizeof(int *)
#define NSIZE (N_COUNT * POINTER_SIZE)
int **pArray = (int **)malloc(NSIZE);</pre>
<p>This new diagnostic rule is most likely to appear in the next version of PVS-Studio 3.30. Let’s now consider another situation also relating to malloc() function and incorrect suggestion about data alignment. It is not quite relative to magic constants but the problem is similar. Let’s consider an example of code:</p>
<pre>struct MyBigStruct {
  unsigned m_numberOfPointers;
  void *m_Pointers[1];
};
unsigned n = 10000;
void *ptr = malloc(sizeof(unsigned) +
                   n * sizeof(void *));</pre>
<p>Although this code does not use magic numbers and the size of the types is defined by sizeof() the code is still incorrect. It does not take into account changing of the data alignment method different for 32-bit and 64-bit systems. The following code will be correct:</p>
<pre>void *ptr = malloc(
  offsetof(MyBigStruct, m_Pointers) +
  n * sizeof(void *));</pre>
<p>To warn the user about a possible error we are planning to introduce one more rule:</p>
<p><em>You should consider unsafe using more than one sizeof() operator in the expression transferred into malloc function. Perhaps, changing of alignment is not considered when calculating the structure’s size. With that, the parts of an expression split by the comparison or division operator are considered independently.</em></p>
<p>In some cases this rule will cause false responses but such places must be checked thoroughly anyway.<br />
The dangerous expressions with magic constants described above are topical not only for malloc() function but for a class of such functions as fread, fwrite etc. But these functions must be studied separately and we will perform their analysis later when diagnosis relating to malloc() function is completely worked out.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/17/magic-constants-and-malloc-function/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Microsoft PDC 2009 - Patterns of Parallel Programming Workshop</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/16/microsoft-pdc-2009-patterns-of-parallel-programming-workshop/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/16/microsoft-pdc-2009-patterns-of-parallel-programming-workshop/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 01:35:46 +0000</pubDate>
		<dc:creator>Doug Holland (Intel)</dc:creator>
		
		<category><![CDATA[Parallel Programming]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/16/microsoft-pdc-2009-patterns-of-parallel-programming-workshop/</guid>
		<description><![CDATA[
I'm presently attending the Microsoft PDC 2009 conference and I am today in the Patterns of Parallel Programming workshop.
It appeared that the workshop was being recorded and so I sent an e-mail to some of the PDC 2009 organizers and can confirm that the Patterns of Parallel Programming workshop recording will be available to all attendees.
Richard [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.microsoftpdc.com"><img class="alignnone size-full wp-image-12030" src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/pdc09bling_workshops_handsdirty_136.jpg" alt="" width="136" height="186" /></a></p>
<p>I'm presently attending the <a href="http://www.microsoftpdc.com">Microsoft PDC 2009</a> conference and I am today in the Patterns of Parallel Programming workshop.</p>
<p>It appeared that the workshop was being recorded and so I sent an e-mail to some of the <a href="http://www.microsoftpdc.com" target="_blank">PDC 2009</a> organizers and can confirm that the <a href="http://microsoftpdc.com/Sessions/Patterns-of-Parallel-Programming" target="_blank">Patterns of Parallel Programming</a> workshop recording will be available to all attendees.</p>
<p><a class="speaker" href="http://software.intel.com/Speakers/Richard-Ciapala">Richard Ciapala</a>, <a class="speaker" href="http://software.intel.com/Speakers/Ade-Miller">Ade Miller</a>, <a class="speaker" href="http://software.intel.com/Speakers/Herb-Sutter">Herb Sutter</a>, and <a class="speaker" href="http://software.intel.com/Speakers/Stephen-Toub">Stephen Toub</a> presented an excellent session on where we are with the parallelism today and where the Microsoft platform can take you in the parallel future.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/16/microsoft-pdc-2009-patterns-of-parallel-programming-workshop/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Macraigor Systems* usb2Demon Support for Intel® Atom™ processor system debugging</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/12/macraigor-systems-usb2demon-support-for-intel-atom-processor-system-debugging/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/12/macraigor-systems-usb2demon-support-for-intel-atom-processor-system-debugging/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 16:19:48 +0000</pubDate>
		<dc:creator>Robert MuellerAlbrecht (Intel)</dc:creator>
		
		<category><![CDATA[Intel® Atom™ Developer Program]]></category>

		<category><![CDATA[Mobility]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[embedded]]></category>

		<category><![CDATA[Intel® Atom™]]></category>

		<category><![CDATA[system software]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/12/macraigor-systems-usb2demon-support-for-intel-atom-processor-system-debugging/</guid>
		<description><![CDATA[With the Intel(R) Embedded Software Development Tool Suite 2.1.008 update release from early November  Intel started supporting the Macraigor Systems* usb2Demon device (check out their website at http://www.macraigor.com/intel/). This low cost JTAG system debug device supporting the Intel(R) Atom(TM) processor z5xx and N2xx platforms for embedded and custom platform operating system and software stack [...]]]></description>
			<content:encoded><![CDATA[<p>With the Intel(R) Embedded Software Development Tool Suite 2.1.008 update release from early November  Intel started supporting the Macraigor Systems* usb2Demon device (check out their website at http://www.macraigor.com/intel/). This low cost JTAG system debug device supporting the Intel(R) Atom(TM) processor z5xx and N2xx platforms for embedded and custom platform operating system and software stack bringup simplifies and streamlines development of embedded Intel(R) Atom(TM) processor based platforms.</p>
<p>Combining these capabilities with the Eclipse RCP based fully GUI driven Intel(R) JTAG Debugger and the whole Intel(R) Embedded Software Development Tool Suite available at http://www.intel.com/software/products/atomtools delivers a concise yet complete solution for Linux* hosted Intel(R) Atom(TM) processor targeted system development.</p>
<p>Please feel free to check it out :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/12/macraigor-systems-usb2demon-support-for-intel-atom-processor-system-debugging/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Are "64-bit errors" real?</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/11/are-64-bit-errors-real/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/11/are-64-bit-errors-real/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:51:44 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[64-bit migration]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/11/are-64-bit-errors-real/</guid>
		<description><![CDATA[I often hear in various interpretations the phrase: "The given examples show not the code incorrect from the viewpoint of porting to x64 systems, but the code incorrect in itself". I would like to discuss and theorize a bit on this point in the blog. Please, take this note with a bit of humor.]]></description>
			<content:encoded><![CDATA[<p>I often hear in various interpretations the phrase: "The given examples show not the code incorrect from the viewpoint of porting to <a href="http://www.viva64.com/terminology/x64.html">x64</a> systems, but the code incorrect in itself". I would like to discuss and theorize a bit on this point in the blog. Please, take this note with a bit of humor.</p>
<p>First, let's begin with saying that any code written in C++ is incorrect by itself. Only that code will be correct which consists of the empty function main, yet I'm not sure about it. It is impossible to write an ideal correct program in C/C++. For you should consider that the program should work on a 12-, 16-, 32-, 64-, ...-bit system. The program, if possible, shouldn't allocate memory dynamically because somewhere it is missing. Also, it shouldn't use functions like scanf for you may need to place the program into a controller where there is no input device. The program mustn't use type conversions. Any type conversion is a potential error on some platform. And perhaps it is better to write the program with the help of trigraphs - you never know... :)</p>
<p>Well, I mean that there are no ideally correct programs in C/C++. You can seek to create such a program but you will never create it. In reality, when writing programs an admissible level of correctness and supposition about the execution environment is chosen and the program is written within the framework of this model.</p>
<p>So, any code is incorrect by itself from the viewpoint of an ideal programmer with golden hands living in vacuum. But we can suppose that a particular code be correct in some particular conditions. When the conditions (the environment) change the code may become incorrect. In what way it becomes incorrect depends on the external changes. Search of errors occurring when the execution environment changes can be arranged in a group and successfully diagnosed, while the approach "everything in the program is incorrect" is irrational.</p>
<p>Let's consider an example. We have a program to port into a controller which won't have a console. The program has some number of cout, cin, printf, scanf. We should find and "deactivate" these functions. Suppose that input be performed through the ports connected to some handle on the device's case. There is no sense in saying that the code is bad, the programmer who wrote it is bad only because he hadn't foreseen that there can be no console and one cannot disable all these sections by one pressure. It won't help us. And there is no sense in trying to perform an ideal refactoring to create an ideal program. We should only find and fix the necessary fragments. One can invent a static analyzer of "input-output issues in controllers"-diagnosis kind. And it will be helpful! But, honestly, all this is due to imperfect code of course :-)</p>
<p>The example above is exaggerated but I just want to show that when one is writing code one cannot foresee everything. One doesn't know that in five years this code will be placed into a controller, ported on a 64-bit system or adapted to a submarine. It is rather difficult to foresee some things.</p>
<p>Programmers have and maintain that code which they have. It can contain a lot of magic numbers, THOUSANDS of expressions where signed and unsigned types are used together, where many warnings may be disabled because one has to use LARGE old third-party libraries. And no one will bother to perform total refactoring of such projects to make them more beautiful, portable etc. And if one insists on this - this person should be fired. :) In reality, you should solve real tasks. You should add new functionality, organize maintenance on existing systems. If necessary, you should port the code on 64-bits. But when you port the code on a 64-bit system, it is this task that will be solved and not the task of how to make the code maximum portable. And here we face the practical task of detecting particular magic numbers (but not all of them), unsafe expressions with signed and unsigned types (but not all of them).</p>
<p>My position may seem wrong to many people as if I'm urging to write bad code and then use various crutches (which I sell myself) to fix it in some places. I am simply a practitioner. And also I call many things by their names. :)</p>
<p>Mostly, program code is BAD. And it works more or less well because it is lucky. Unfortunately, programmers are persistent in not admitting it. Any "code-shaking" (changing of the compiler, execution environment etc) reveals a layer of particular types of errors. I understand that there are no "64-bit" errors. There are just errors in code. They are always present in code. But some errors will occur on a 64-bit system. I tell developers about these errors and hope it will help them. And it is these errors that I call "64-bit errors".</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/11/are-64-bit-errors-real/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Problems of 64-bit code in real programs: magic constants</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/10/problems-of-64-bit-code-in-real-programs-magic-constants/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/10/problems-of-64-bit-code-in-real-programs-magic-constants/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 00:37:59 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[64-bit migration]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/10/problems-of-64-bit-code-in-real-programs-magic-constants/</guid>
		<description><![CDATA[The error described deserves attention because of its simplicity or even ingenuousness. It has been recommended in all the books for many years not to use magic constants in code. Everyone knows about it and mentions it in coding standards. But in practice magic numbers appear in various code sections again and again.]]></description>
			<content:encoded><![CDATA[<p>I would like to tell you about one more <a href="http://viva64.com/terminology/64-bit_rus.html">64-bit</a> error we have found in some program. It becomes a good tradition to publish information about interesting and specific programming errors for 64-bit systems and we will try to follow it.</p>
<p>The error described deserves attention because of its simplicity or even ingenuousness. It has been recommended in all the books for many years not to use magic constants in code. Everyone knows about it and mentions it in coding standards. But in practice magic numbers appear in various code sections again and again.</p>
<p>Let's consider an example of CreateFileMapping function's call in some application:</p>
<pre>hFileMapping = CreateFileMapping (
    (HANDLE) 0xFFFFFFFF,
    NULL,
    PAGE_READWRITE,
    (DWORD) 0,
    (DWORD) (szBufIm),
    (LPCTSTR) &amp;FileShareNameMap[0]);</pre>
<p>Right - you have guessed it. The error is in using constant 0xFFFFFFFF. The first argument of CreateFileMapping function may have value INVALID_HANDLE_VALUE defined in the following way:</p>
<pre>#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)</pre>
<p>As a result, INVALID_HANDLE_VALUE does coincide with 0xFFFFFFFF value in a 32-bit system. But in a 64-bit system 0×00000000FFFFFFFF value will be put into CreateFileMapping function and as a result the system will consider the argument incorrect and return the errors' code. The cause is that 0xFFFFFFFF value has UNSIGNED type (unsigned int). 0xFFFFFFFF value does not fit into int type and that's why has unsigned type. It is a subtle point you should pay attention to when performing migration on 64-bit systems. Let's illustrate it by an example:</p>
<pre>void foo(void *ptr)
{
   cout &lt;&lt; ptr &lt;&lt; endl;
}
int _tmain(int, _TCHAR *[])
{
   cout &lt;&lt; "-1\t\t";
   foo((void *)-1);
   cout &lt;&lt; "0xFFFFFFFF\t";
   foo((void *)0xFFFFFFFF);
}</pre>
<p>The result in the 32-bit version of the program:</p>
<pre>-1                     FFFFFFFF
0xFFFFFFFF      FFFFFFFF</pre>
<p>The result in the 64-bit version of the program:</p>
<pre>-1                     FFFFFFFFFFFFFFFF
0xFFFFFFFF      00000000FFFFFFFF</pre>
<p>See also: <a href="http://www.viva64.com/content/PVS-Studio-help-en/V112.html">V112. Dangerous magic number used</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/10/problems-of-64-bit-code-in-real-programs-magic-constants/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Testing of Linux-applications with the help of PVS-Studio in Windows</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/10/testing-of-linux-applications-with-the-help-of-pvs-studio-in-windows/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/10/testing-of-linux-applications-with-the-help-of-pvs-studio-in-windows/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 00:37:38 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[64-bit migration]]></category>

		<category><![CDATA[LLP64]]></category>

		<category><![CDATA[LP64]]></category>

		<category><![CDATA[PVS-Studio]]></category>

		<category><![CDATA[Viva64]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/10/testing-of-linux-applications-with-the-help-of-pvs-studio-in-windows/</guid>
		<description><![CDATA[By default, Viva64 code analyzer (and now PVS-Studio) is oriented on LLP64 data model being intended for operation in Windows environment. Roughly speaking, it means that it searches incorrect shared use of size_t-types and int-types. To test the code on correctness in 64-bit Linux-environment you need to search incorrect shared use of long-types and int-types as well.]]></description>
			<content:encoded><![CDATA[<p>Quite recently we have released a new program product <a href="http://www.viva64.com/pvs-studio/">PVS-Studio</a> which united our two analyzers Viva64 and VivaMP. When Viva64 analyzer intended for developers of 64-bit applications was a separate product yet, we were asked this question: "Is there a version of Viva64 for Linux?". And although it is possible to create such a version (as development of a separate solution for a particular client) there is no Linux-version of the analyzer for the moment.</p>
<p>But sometimes you can test the code of Linux-applications in 64-bit Linux environment in Windows system. It is this possibility our engineers are working at. In this note I will tell you how it works.</p>
<p>From the viewpoint of developing 64-bit applications Windows and Linux operation systems differ in the <a href="http://www.viva64.com/terminology/Data_model.html">data model</a> being used. This is a correlation between the sizes of basic data types in a particular system. In the 64-bit Windows-version <a href="http://viva64.com/terminology/LLP64.html">LLP64</a> data model is used. In this data model the types have the following sizes: int - 32 bits, long - 32 bits, long long - 64 bits, size_t - 64 bits, pointer - 64 bits. In the 64-bit Linux-version <a href="http://viva64.com/terminology/LP64.html">LP64</a> data model is used. In it the data types' sizes are the following: int - 32 bits, long - 64 bits, long long - 64 bits, size_t - 64 bits, pointer - 64 bits. For 64-bit Linux and Windows systems such types as long double are also different but it is not relevant here. As you can see, the basic difference is in the size of long type - in 64-bit Windows it is 32 bits and in 64-bit Linux it is 64 bits.</p>
<p>By default, Viva64 code analyzer (and now PVS-Studio) is oriented on LLP64 data model being intended for operation in Windows environment. Roughly speaking, it means that it searches incorrect shared use of size_t-types and int-types. To test the code on correctness in 64-bit Linux-environment you need to search incorrect shared use of long-types and int-types as well.</p>
<p>We plan to add the possibility of searching incorrect shared use of long-types into the new version of PVS-Studio 3.10. It will be a special operation mode, the so called "Linux-like mode". The analyzer of 64-bit problems will operate in this mode in the same way as it would operate in Linux-environment. It will allow you to partly test the code of applications operating in Linux in Windows system with the help of PVS-Studio.</p>
<p>So, to test a 64-bit Linux-application you will need to have its version compiled into Visual Studio. That is, such testing is reasonable for cross-platform applications which are built both in Windows and Linux.</p>
<p>Of course, testing of an application on 64-bit code correctness in the mode of imitating Linux-environment cannot be considered full and guarantee its efficiency in real Linux-world. Besides, there can be more false responses. But in some cases this testing variant will help you find a lot of errors which would occur in 64-bit Linux-systems.</p>
<p>The disadvantage of this approach is code sections which are not built for Windows. For example, it can be interface parts of a program. You cannot test them in Windows because you cannot compile them. But, for example, you can test the core of a program which operates both in Windows and Linux.</p>
<p>You should also keep in mind that in Linux-like data model only user code is tested. The code included into system include-files in Windows will still be the same as for LLP64 memory model. For all the files are processed by the preprocessor before analysis and of course it does not know about LP64 model.</p>
<p>To demonstrate the peculiarities of using PVS-Studio in "Linux-like mode" I will give some examples.</p>
<pre>void foo(ptrdiff_t delta);

int i = -2;
unsigned k = 1;
foo(i + k);</pre>
<p>This code will be potentially unsafe both for Windows and Linux systems. An incorrect result occurs at implicit extension of the actual argument having the value 0xFFFFFFFF of unsigned type to ptrdiff_t type. In this case the warning will be shown independently from the mode being used.</p>
<pre>void *ptr;
long np = (long)(ptr);</pre>
<p>This code diagnosed as incorrect in 64-bit Windows programs will be correct for 64-bit Linux-systems.</p>
<p>Vice versa, the next example shows the code correct for Windows systems and incorrect for Linux ones:</p>
<pre>long array[4] = { 1, 2, 3, 4 };
enum ENumbers { ZERO, ONE, TWO, THREE, FOUR };

int *intPtr = (int *)(array);
cout &lt;&lt; intPtr[1] &lt;&lt; endl;</pre>
<p>As the sizes of int and long in 64-bit Linux systems do not coincide, the analyzer will show the corresponding diagnostic warning.</p>
<p>The last two examples demonstrate the limitations of the new operation mode:</p>
<pre>#ifdef _WINDOWS
  typedef long MY_SIGNED_32;
#else //Linux
  typedef int MY_SIGNED_32;
#endif</pre>
<p>As the preprocessor will choose the branch "typedef long MY_SIGNED_32;" all the code constructions containing MY_SIGNED_32 type will be incorrect from the viewpoint of Linux systems.</p>
<p>And finally we can give a simpler example when the code we need to analyze will not be analyzed:</p>
<pre>#ifdef LINUX_64
   // there is too much code here
#endif</pre>
<p>Despite the limitations we have listed, the ability of working both with the Windows-traditional LLP64 data model and Linux-traditional LP64 data model will help you broaden the scope of use of our code analyzer. You should just understand how this option operates and what it can and cannot provide.</p>
<p>By default, the new mode will be switched off and those users for whom operation in Linux-environment is not relevant, can forget about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/10/testing-of-linux-applications-with-the-help-of-pvs-studio-in-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PVS-Studio and testing Loki</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/09/pvs-studio-and-testing-loki/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/09/pvs-studio-and-testing-loki/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 16:40:24 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[64-bit migration]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[Loki]]></category>

		<category><![CDATA[PVS-Studio]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/09/pvs-studio-and-testing-loki/</guid>
		<description><![CDATA[In PVS-Studio 3.10, support parsing of complex constructions based on templates will be improved what will allow you to efficiently search errors even in the code of those programs which use complex template libraries such as Loki.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.viva64.com/pvs-studio/">PVS-Studio 3.10</a>, support parsing of complex constructions based on templates will be improved what will allow you to efficiently search errors even in the code of those programs which use complex template libraries such as Loki. But let's start with the beginning.</p>
<p>Not so long ago, when our product for testing <a href="http://www.viva64.com/terminology/64-bit.html">64-bit</a> code was called Viva64, we were addressed by the manager of the open library Loki* with an offer to check compatibility of the library with 64-bit Windows systems. For that moment the Windows-version of this library was represented only in 32-bit mode. We agreed and set about the new task bating our breath. The point is that compiler developers often use Loki library as a perfect testing model allowing you to estimate compatibility with C++ standard. We were not sure that we would be lucky. So, we consider it a great achievement that our analyzer did not hang on it, did not crash with a critical error and was able to provide normal diagnosing.</p>
<p>But the results of the diagnosing showed a great disadvantage of Viva64 analyzer: it cannot instantiate templates and cannot detect many errors in them. Here is an example to make it clear:</p>
<pre> 01 template &lt;class T, class M&gt;
02 class TemplateClass
03 {
04 public:
05   char m_char;
06   T *m_t;
07   M m_m;
08   T Get(int index) { return m_t[index]; }
09   void Set(int value) { m_t[m_m] = value; }
10 };
11
12 TemplateClass &lt;char, int&gt; A;</pre>
<p>Only one potential error in line 8 was detected. In this line a variable of int type is used as an array index and it is potentially dangerous when working with large data arrays. When diagnosing this error it does not matter what relates to T type. But two other errors we will describe further have never been detected by Viva64 analyzer. One can say that Viva64 checks the code of templates rather superficially and detects only those errors which are present in it independently from the arguments with which an array will be instantiated.</p>
<p>This disadvantage arises from <a href="http://www.viva64.com/terminology/OpenC++.html">OpenCxx library</a> on whose basis <a href="http://www.viva64.com/terminology/VivaCore.html">VivaCore library</a> has been created being the base of Viva64 analyzer. The reason is very simple - OpenCxx simply cannot instantiate templates. It looks rather strange for it restricts abilities of the library. But we have a suspicion that there had been support of template instantiating in OpenCxx library but then was deliberately removed before the project became open and accessible. Some strange stubs and near-empty classes relating to template processing are an indirect evidence of this.</p>
<p>We have known about this drawback and its effects on diagnostics for a long time but it was Loki library that urged us to engage into implementing a mechanism for testing instantiated templates. We have created a mechanism which instantiates a template and analyzes it again on the basis of new knowledge about types. Implementation is not very good yet and needs to be improved but it already allows us to detect many new errors. Let's discuss it on the basis of the example given above.</p>
<p>After implementing the instantiating mechanism the analyzer immediately gave three diagnostic messages:</p>
<p>Line 3: error V401: Instantiate TemplateClass &lt;char, int&gt;: The structure's size can be decreased via changing the fields' order. The size can be reduced from 24 to 16 bytes.</p>
<p>Line 8: error V108: Incorrect index type for "m_t". Use memsize type instead.</p>
<p>Line 9: error V108: Instantiate TemplateClass &lt;char, int&gt;: Incorrect index type for "m_t". Use memsize type instead.</p>
<p>Having met the line "TemplateClass &lt;char, int&gt; A;" the analyzer instantiated this template and analyzed it possessing the information about T and M types. As a result, it warned that the data structure in the class is non-optimal (V401) and the size of this class in a 64-bit system can be reduced from 24 bytes to 16. For this we need to rearrange the members of the class. Pay attention that this diagnostics is possible only when you know what types the members have. For there can be no warning if, for example, m_m members have <a href="http://www.viva64.com/terminology/size_t.html">size_t</a> type. In this case field rearranging will not help reduce the class' size.</p>
<p>The error in line 8 is detected as before because knowledge about T and M types does not matter here.</p>
<p>The last error in line 9 also relates to indexing of the array with the use of a variable of int type. Here information about M type does play an important role and is used by the analyzer.</p>
<p>The improvements made enabled us to perform fuller testing of Loki library. You may learn more about this work in the article "64-bit Loki" at which we are working together with the library's manager Rich Sposato.</p>
<p>Analysis of Loki has been performed by a special research version of Viva64. But now we decided to integrate the new abilities into the new version PVS-Studio 3.10 ** which will be released in the near future. Users will be able to use a new option DoTemplateInstantiate which enables the mode of deep template analysis.</p>
<p>*Note. Loki library for C++ programming language was written by Andrei Alexandrescu as part of the book "Modern C++ Design: Generic Programming and Design Patterns Applied". The library is built on template meta-programming and actively uses C++ abilities for generalized programming. (<a href="http://en.wikipedia.org/wiki/Loki_(C%2B%2B)">Wikipedia. Loki.</a>)</p>
<p>**Note. PVS-Studio is a program product uniting and extending abilities of Viva64 and VivaMP static analyzers. Numbering of PVS-Studio begins with the version 3.00 to emphasize that this is evolution of the existing tools. In 3.00 version we did not hurry to implement template instantiating support but decided to introduce this ability in PVS-Studio 3.10.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/09/pvs-studio-and-testing-loki/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TechEd 2009 Europe</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/05/teched-2009-europe/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/05/teched-2009-europe/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 01:05:03 +0000</pubDate>
		<dc:creator>Asaf Shelly</dc:creator>
		
		<category><![CDATA[Academic]]></category>

		<category><![CDATA[Events]]></category>

		<category><![CDATA[Intel® Software Network 2.0]]></category>

		<category><![CDATA[Mobility]]></category>

		<category><![CDATA[Parallel Programming]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[guest blogger]]></category>

		<category><![CDATA[Parallel Prog. &amp; Multi-Core]]></category>

		<category><![CDATA[TechEd]]></category>

		<category><![CDATA[www.AsyncOp.com]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/05/teched-2009-europe/</guid>
		<description><![CDATA[Hi All,
If you are going to the event next week in Berlin then let me know about it. Maybe we can meet face to face and if there are enough of us perhaps even a gourp community meeting. This can be a good opportunity to meet the experts.
In any case, you are all welcome to [...]]]></description>
			<content:encoded><![CDATA[<p>Hi All,</p>
<p>If you are going to the event next week in Berlin then let me know about it. Maybe we can meet face to face and if there are enough of us perhaps even a gourp community meeting. This can be a good opportunity to meet the experts.</p>
<p>In any case, you are all welcome to join my session titled "Parallel Programming for Embedded". I will be presenting on Friday 10:45 - 12:00.</p>
<p>At the basis of this presentation is the fact that the hardware has always been parallel. This also caused the kernel drivers to live in a parallel environment, so even though embedded devices were late to adopt Multi-Core CPUs, the people who are working with the lower levels have always been working in parallel environments.</p>
<p>The session speaks of parallel systems in general side by side with embedded systems and infrastructure environemnts.</p>
<p>The goal of this session is to open the eyes and show the systems that have always been working in parallel and name the principles used with these systems.</p>
<p>You can read my previous blogs to learn more about this approach. For example these:</p>
<p><a href="http://software.intel.com/en-us/blogs/2008/10/29/is-dos-the-ideal-parallel-environment-part-iv/">is dos the ideal parallel environment part iv</a></p>
<p><a href="http://software.intel.com/en-us/blogs/2009/07/27/stateful-programming-a-case-study/">stateful programming a case study</a></p>
<p>Here are a few slides from this presentation.</p>
<div id="attachment_11631" class="wp-caption alignnone" style="width: 310px"><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/parallel-programming-for-embedded-slide-2.jpg"><img class="size-medium wp-image-11631" src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/parallel-programming-for-embedded-slide-2-300x225.jpg" alt="Parallel Programming for Embedded TechEd 2009" width="300" height="225" /></a><p class="wp-caption-text">Parallel Programming for Embedded TechEd 2009</p></div>
<div id="attachment_11632" class="wp-caption alignnone" style="width: 310px"><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/parallel-programming-for-embedded-slide-56.jpg"><img class="size-medium wp-image-11632" src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/parallel-programming-for-embedded-slide-56-300x225.jpg" alt="USB Ping Pong" width="300" height="225" /></a><p class="wp-caption-text">USB Ping Pong</p></div>
<p><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/parallel-programming-for-embedded-slide-71.jpg"><img class="alignnone size-medium wp-image-11634" src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/11/parallel-programming-for-embedded-slide-71-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Hope to see you all there,<br />
Asaf</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/05/teched-2009-europe/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Change of type alignment and the consequences</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/05/change-of-type-alignment-and-the-consequences/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/05/change-of-type-alignment-and-the-consequences/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 22:56:36 +0000</pubDate>
		<dc:creator>Andrey Karpov</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[64-bit]]></category>

		<category><![CDATA[64-bit Coding]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[Data Alignment]]></category>

		<category><![CDATA[Viva64]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/05/change-of-type-alignment-and-the-consequences/</guid>
		<description><![CDATA[When porting software one of the task a developer faces is to change types' sizes and rules of their alignments. Not so long ago we provided support of the diagnosing rule allowing you to detect data structures which use memory on 64-bit inefficiently in Viva64 analyzer. But there is still some research work to be [...]]]></description>
			<content:encoded><![CDATA[<p>When porting software one of the task a developer faces is to change types' sizes and rules of their alignments. Not so long ago we provided support of the diagnosing rule allowing you to detect data structures which use memory on <a href="http://viva64.com/terminology/64-bit.html">64-bit</a> inefficiently in <a href="http://viva64.com/terminology/Viva64.html">Viva64</a> analyzer. But there is still some research work to be carried out in this field and I look through the messages concerning this topic in forums with attention.</p>
<p>This time my attention was attracted by a message in RSDN "<a href="http://www.viva64.com/go.php?url=218">Alignment on 64-bit architectures</a>" running as follows:</p>
<p><i>Today I have faced a problem in Linux. There is a data structure consisting of several fields: 64-bit double, 8 unsigned char and one 32-bit int. Altogether it is 20 bytes (8 + 8*1 + 4). On 32-bit systems sizeof is 20 bytes and everything is OK. But on the 64-bit Linux sizeof returns 24 bytes. That is, an alignment at the 64-bit border takes place.</i></p>
<p>After that the author dwells upon data compatibility and asks for advice how to pack data in the structure. But at the moment we are not interested in this. What we are interested in is that there is a new type of errors which can occur when porting applications on a 64-bit system.</p>
<p>It is clear and common that when sizes of fields in a structure change, the size of the structure itself changes too because of this. But this is a different case. The size of the fields remains the same but the size of the structure will change too due to different <a href="http://viva64.com/terminology/Data_alignment.html">alignment</a> rules. This behavior can lead to various errors, for example, incompatibility of the formats of the data being saved.</p>
<p>Linux systems are not supported by Viva64 yet, but I decided to find out if such an error can occur in Windows systems. For this purpose I took an example of the code printing types' sizes and alignment from the article "<a href="http://www.viva64.com/go.php?url=219">C++ data alignment and portability</a>". I've modified it a bit for Visual Studio and got this program:</p>
<pre>#include &lt;iostream&gt;
using namespace std;

template &lt;typename T&gt;
void print (char const* name)
{
  cerr &lt;&lt; name
       &lt;&lt; " sizeof = " &lt;&lt; sizeof (T)
       &lt;&lt; " alignof = " &lt;&lt; __alignof (T)
       &lt;&lt; endl;
}

int _tmain(int, _TCHAR *[])
{
  print&lt;bool&gt;        ("bool          ");
  print&lt;wchar_t&gt;     ("wchar_t       ");
  print&lt;short&gt;       ("short int     ");
  print&lt;int&gt;         ("int           ");
  print&lt;long&gt;        ("long int      ");
  print&lt;long long&gt;   ("long long int ");
  print&lt;float&gt;       ("float         ");
  print&lt;double&gt;      ("double        ");
  print&lt;long double&gt; ("long double   ");
  print&lt;void*&gt;       ("void*         ");
}
</pre>
<p>I compared the data I'd got with the data described in the article "C++ data alignment and portability" for GNU/Linux systems and now give them in Table 1.</p>
<p><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/blog-aligment.png"><img src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/blog-aligment-246x300.png" alt="" width="246" height="300" class="alignnone size-medium wp-image-10977" /></a><br />
Table 1. Types' sizes and alignment.</p>
<p>Let's study this table. Pay attention to the marked cells relating to long int and double. These types' sizes don't depend on the architecture's size and therefore don't change. Both on 32-bit and 64-bit systems their size is 8 byte. But alignment is different for 32-bit and 64-bit systems. It can cause change of the structure's size. When we implement Viva64 for Linux we'll take into consideration the possible errors relating to this.</p>
<p>In Windows systems, there are no such problems with alignment change. Pay attention that alignment of all the types doesn't change or changes together with the type's size. That is good - Windows developers have one potential problem off.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/05/change-of-type-alignment-and-the-consequences/feed/</wfw:commentRss>
		</item>
		<item>
		<title>In the company of friends</title>
		<link>http://software.intel.com/en-us/blogs/2009/11/04/in-the-company-of-friends/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/11/04/in-the-company-of-friends/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 20:57:19 +0000</pubDate>
		<dc:creator>wolfmurphy</dc:creator>
		
		<category><![CDATA[Academic]]></category>

		<category><![CDATA[Parallel Programming]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[panel discussion]]></category>

		<category><![CDATA[SC09]]></category>

		<category><![CDATA[tee shirts]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/11/04/in-the-company-of-friends/</guid>
		<description><![CDATA[




You are hereby invited to a gathering on November 17 at 5:30 pm in room C124 of the Oregon Convention Center in Portland. We are having a panel discussion focused on incorporating parallelism into the Computer Science curriculum. Of course, you might need to purchase a day pass to SC09 to attend, if you are [...]]]></description>
			<content:encoded><![CDATA[<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"></p>
<p><html><br />
<head></p>
<p></head></p>
<p><body><br />
You are hereby invited to a gathering on November 17 at 5:30 pm in room C124<img src="http://software.intel.com/file/23528" alt="room circled on floorplan" /> of the Oregon Convention Center in Portland. We are having a panel discussion focused on incorporating parallelism into the Computer Science curriculum. Of course, you might need to purchase a day pass to <a href="http://sc09.supercomputing.org/">SC09</a> to attend, if you are not otherwise attending.</p>
<p>We generally all believe it is a good idea to weave parallelism throughout the CS curriculum. There are a variety of paths to get there, roughly corresponding to number of panelists, of which I will be the moderator and facilitator. The panel held last year at SC08, had a standing-room-only animated crowd. It happens to be available in 15 minute chunks: part <a href="http://software.intel.com/en-us/videos/stop-teaching-sequential-programming-forum-at-super-computing-08-education-forum-pt1/">1</a>, <a href="http://software.intel.com/en-us/videos/sequential-programming-is-no-more-why-are-we-still-teaching-it-panel-super-computing-08-education-forum-pt2/">2</a>, <a href="http://software.intel.com/en-us/videos/sequential-programming-is-no-more-why-are-we-still-teaching-it-panel-super-computing-08-education-forum-pt3/">3</a>, <a href="http://software.intel.com/en-us/videos/sequential-programming-is-no-more-why-are-we-still-teaching-it-panel-super-computing-08-education-forum-pt4/">4</a>, <a href="http://software.intel.com/en-us/videos/sequential-programming-is-no-more-why-are-we-still-teaching-it-panel-super-computing-08-education-forum-pt5/">5</a>, <a href="http://software.intel.com/en-us/videos/sequential-programming-is-no-more-why-are-we-still-teaching-it-panel-super-computing-08-education-forum-pt6/">6</a>, and <a href="http://software.intel.com/en-us/videos/sequential-programming-is-no-more-why-are-we-still-teaching-it-panel-super-computing-08-education-forum-pt7/">7</a>. I expect similar festivities this year.</p>
<p>Our distinguished panel is composed of</p>
<ul>
<li><strong>Wen-mei Hwu</strong>, University of Illinois at Urbana-Champaign, who believes key computer architecture concepts, some performance optimization concepts, some program analysis concepts, some program transformation concepts, effective parallel programming patterns and algorithms, and fundamental parallelism concepts are required to train a successful undergraduate CS major.
</li>
</p>
<li> <strong>James Larus</strong>, Microsoft Research, who believes parallelism must be woven into the general series of courses, but sees the dilemma of the current awkward and crude tools imposing awareness of the underlying architecture on the student. He longs for a more elegant toolchain for use with students.
</li>
</p>
<li>
<strong>Simon McIntosh-Smith</strong>, University of Bristol, who has succumbed to the "Snow White" syndrome of advocating the dwarves parallel patterns from UCB. He also sees the utility of teaching the current prevalent tools: MPI and OpenMP, while remaining sensitive to the emerging potential standards: CUDA, OpenCL, Ct, map-reduce, etc.
</li>
</p>
<li> <strong>Bob Chesebrough</strong>, Intel, who sees the trouble in River City of a late introduction of parallelism to students, and of course recommends the "Think Method", in this case the "Think Parallel" method. Parallelism is all around and the key concepts can be conveyed without a computer.
</li>
</p>
<li>
<strong>Steve Parker</strong>, nVidia, who believes and has done many things. There needs to be a teaser to get you to come to the event. This is it.
</li>
</p>
<li>
<strong>Charlie Peck</strong>, Earlham College, who sees faculty education as key activity to get right, since many CS faculty have limited first hand experience with the myriad faces of parallelism. Involving students is a key part of this, for a unique form of learning takes place via an apprenticeship model of student involvement.
</li>
</ul>
<p>For several years now, we have been a parallel education working group composed of broad representation from industry, colleges/universities, hardware manufactures, and labs We are about to call ourselves something like "The Educational Alliance for a Parallel Future." I now know first hand what is involved in morphing from a working group to an alliance. When you are getting ready to make a tee-shirt, alliance ends up sounding sounding way cooler, and actually better reflects who we are. We will also be releasing a parallel crossword puzzle. This is not one solved in parallel, though it might be if someone is looking over your shoulder. The subject matter is of many things parallel. Stay tuned, we'll point you to it, once it debuts at SC09.</p>
<p></body><br />
</html></p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/11/04/in-the-company-of-friends/feed/</wfw:commentRss>
		</item>
		<item>
		<title>api and widget demo: cpu power connection mashed with video</title>
		<link>http://software.intel.com/en-us/blogs/2009/10/28/api-and-widget-demo-cpu-power-connection-mashed-with-video/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/10/28/api-and-widget-demo-cpu-power-connection-mashed-with-video/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 23:49:38 +0000</pubDate>
		<dc:creator>Andy Idsinga (Intel)</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Mashup]]></category>

		<category><![CDATA[video]]></category>

		<category><![CDATA[web]]></category>

		<category><![CDATA[web api]]></category>

		<category><![CDATA[web developer]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/10/28/api-and-widget-demo-cpu-power-connection-mashed-with-video/</guid>
		<description><![CDATA[Andy shares video versions of web API presentations he been making to web developers.]]></description>
			<content:encoded><![CDATA[<p>Here are a couple of presentations I've been making a lot lately - about our work to expose platform/device capabilities to web developers.</p>
<p>After you look at the technology, think about the kinds of device capabilities, hardware and software, that would make your web application better. Then share them with us - we're listening.<br />
If you need some food for thought <a href="http://software.intel.com/en-us/blogs/2009/10/22/api-drafts-posted-at-w3c-web-developer-comments-welcome/">take a look at this blog post</a> - where I list several API drafts we recently submitted to the <a href="http://www.w3.org/2009/dap/">W3C Device API working group</a>.</p>
<p>"The story" gives you the context. "The Technology" dives a little deeper into the details.</p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/l05oJqo4C-A&#038;hl=en&#038;fs=1&#038;rel=0&#038;color1=0x3a3a3a&#038;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/l05oJqo4C-A&#038;hl=en&#038;fs=1&#038;rel=0&#038;color1=0x3a3a3a&#038;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/E-aFxj1MnKM&#038;hl=en&#038;fs=1&#038;rel=0&#038;color1=0x3a3a3a&#038;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/E-aFxj1MnKM&#038;hl=en&#038;fs=1&#038;rel=0&#038;color1=0x3a3a3a&#038;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/10/28/api-and-widget-demo-cpu-power-connection-mashed-with-video/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Memory management challenges in parallel applications</title>
		<link>http://software.intel.com/en-us/blogs/2009/10/28/memory-management-challenges-in-parallel-applications/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/10/28/memory-management-challenges-in-parallel-applications/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 14:18:00 +0000</pubDate>
		<dc:creator>Roman Lygin (Intel)</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Threading Building Blocks]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/10/28/memory-management-challenges-in-parallel-applications/</guid>
		<description><![CDATA[Let me share some recent practical experience with memory management issues when developing a multi-threaded application. This can probably be a rather common case (as recent post by Roman Dementiev and its follow up discussion demonstrates), and I’d be happy if my experience were helpful for others.
Working on CAD Exchanger I am designing one of [...]]]></description>
			<content:encoded><![CDATA[<p>Let me share some recent practical experience with memory management issues when developing a multi-threaded application. This can probably be a rather common case (as <a href="http://software.intel.com/en-us/blogs/2009/08/21/is-your-memory-management-multi-core-ready/">recent post by Roman Dementiev</a> and its follow up discussion demonstrates), and I’d be happy if my experience were helpful for others.</p>
<p>Working on <a href="http://www.cadexchanger.com">CAD Exchanger</a> I am designing one of its plugin to convert 3D CAD data between ACIS and Open CASCADE (two modeling kernels) to be parallel. Depending on a model size, the converter has to deal with multiple small objects allocated on a heap (e.g. 20,000+ objects each taking 48bytes + additional object data such as lists, strings, etc).</p>
<p>The translation works just fine and concurrency analysis with <a href="http://www.intel.com/go/parallel">Intel Parallel Amplifier</a> indicates high concurrency levels. So far, so good. However I had noticed that when translating the same ACIS file over and over again in the same test harness session translation took longer and longer. Why could it be ?</p>
<p>So I launched the Amplifier to collect hotspots and here is what I saw:</p>
<p><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-hostpot3.png"><img src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-hostpot3-300x87.png" alt="" width="300" height="87" class="aligncenter size-medium wp-image-11266" /></a></p>
<p>These two top hotspots relate to the memory manager layer (Standard_MMgrRaw class) which simply forwards calls to malloc/free and new/delete. Trying to root-cause the problem I had to switch to the mode to see direct OS functions (toggling off the button on the Amplifier toolbar) and here is a new screenshot:</p>
<p><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-hostpot4a.png"><img src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-hostpot4a-300x92.png" alt="" width="300" height="92" class="aligncenter size-medium wp-image-11264" /></a></p>
<p>It shows that hotspots are two system functions – RtlpFindAndCommitPages() and ZwWaitForSingleObject() – which are called from memory allocation / deallocation routines. It also shows that the nearest hotspot related to my code (BSplCLib::Bohm()) is just 1/4 of the time consumed by ZwWaitForSingleObject() (0.47s vs 1.81s).</p>
<p>After experimenting with several runs, analyzing how the hotspot profile changes with growing number of runs, I concluded that the first hotspot is explained by the fact that the ACIS converter creates multiple tiny objects with different size with short life span (they are destroyed after every conversion). This seems to cause strong memory fragmentation which forces the system to constantly look for new memory chunks.</p>
<p>The second hotspot (ZwWaitForSingleObject()) which goes through critical section is caused by the default mechanism of memory management on Windows <a href="http://msdn.microsoft.com/en-us/library/ms683476(VS.85).aspx">which uses a lock</a>.</p>
<p>The execution of locks&amp;waits analysis also proves that memory management lock is the greatest one adversely affecting concurrency.</p>
<p><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-lw2.png"><img src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-lw2-300x175.png" alt="" width="300" height="175" class="aligncenter size-medium wp-image-11265" /></a></p>
<p>All this is caused by the direct use of calloc/malloc/free, and new/delete called dozens of thousands times. It’s worth mentioning that such hotspots did not exist when I used serial implementation and popped up only when I started using parallel one. The former used a memory manager (in a 3rd party lib) that allocated memory blocks and did not return them to the system reusing them when the application requested new blocks. I couldn’t reuse this memory manager because it was not thread-safe and therefore had to switch to another manager that simply forwarded to malloc/free.</p>
<p>So I almost was forced to write my own memory manager that would implement a previous behavior and would be thread-safe and … fast ! Challenges are good but not when you need to re-write low-level components what can take a lot of time and require diligent thorough testing delaying progress in your project which already receives very limited attention.</p>
<p>So, I approached my colleagues from the Threading Build Blocks team to check if there is anything TBB could help with. What was my surprise when they suggested me trying a new release 2.2. Version 2.2 offers a mechanism to seamlessly replace the system memory manager with the tbb allocator. ‘Seamlessly’ really means it – everything I had to is to add a single line of code into a C++ file:</p>
<p>#include "tbb/tbbmalloc_proxy.h"</p>
<p>The outcome was immediate. Not only did the hotspot profile change completely removing the OS hotspots (see the comparison mode screenshot below) but the overall speed up (on entire test case) was about 25%! One line of code, no need of re-writing anything on my own saved hours of coding, with such a return! Just incredible, the least I could say. Recently released 2.2 Update 1 includes further improvements which my app now benefits from (more reliable processing of realloc(), bug fixes for debug mode, etc).</p>
<p><a href="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-hostpot3.png"><img src="http://software.intel.com/en-us/blogs/wordpress/wp-content/uploads/2009/10/mm-hostpot3-300x87.png" alt="" width="300" height="87" class="aligncenter size-medium wp-image-11266" /></a></p>
<p>The colleagues later explained me that the TBB allocator runs concurrently (seemingly without any locks inside) and with a similar fashion of reusing previously allocated blocks. Thus, it was the entire application (not only its parallel part) which benefited from this substitution. </p>
<p>So, if you are migrating from serial to parallel implementation you may encounter something unexpected – memory bottlenecks. If you got accustomed to use some nice single-threaded memory manager you can be forced to consider migration to something alternative. If this is the case you may want to give a try to tbb allocator and see if it helps in your case.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/10/28/memory-management-challenges-in-parallel-applications/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Check out this McCool event in December at UPCRC</title>
		<link>http://software.intel.com/en-us/blogs/2009/10/22/check-out-this-mccool-event-in-december-at-upcrc/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/10/22/check-out-this-mccool-event-in-december-at-upcrc/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 07:09:12 +0000</pubDate>
		<dc:creator>Rita Turkowski (Intel)</dc:creator>
		
		<category><![CDATA[Academic]]></category>

		<category><![CDATA[Cool Software]]></category>

		<category><![CDATA[Events]]></category>

		<category><![CDATA[Parallel Programming]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/10/22/check-out-this-mccool-event-in-december-at-upcrc/</guid>
		<description><![CDATA[December 3rd at 4PM CST
12/3 &#124; 4PM &#124; 2405 Siebel Center for Computer Science
UPCRC Illinois Research Seminar: A Structured, Unified Approach to Multi-Core and Many-Core Computing - with Applications by Michael McCool, Intel &#38; U of Waterloo
]]></description>
			<content:encoded><![CDATA[<p><strong><span style="#17365d;">December 3rd at 4PM CST</span></strong></p>
<p class="MsoNormal"><strong><span style="x-small;"><span style="bold;">12/3 | 4PM | 2405 Siebel Center for Computer Science</span></span></strong></p>
<p class="MsoNormal"><span style="x-small;"><span style="9.5pt;"><a title="http://illinois.edu/calendar/Calendar?calId=2238&amp;eventId=144589&amp;ACTION=VIEW_EVENT" href="http://illinois.edu/calendar/Calendar?calId=2238&amp;eventId=144589&amp;ACTION=VIEW_EVENT"><span style="#0d0d0d;"><span style="#0d0d0d;" title="http://illinois.edu/calendar/Calendar?calId=2238&amp;eventId=144589&amp;ACTION=VIEW_EVENT"><span title="http://illinois.edu/calendar/Calendar?calId=2238&amp;eventId=144589&amp;ACTION=VIEW_EVENT">UPCRC Illinois Research Seminar: A Structured, Unified Approach to Multi-Core and Many-Core Computing - with Applications by Michael McCool, Intel &amp; U of Waterloo</span></span></span></a></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/10/22/check-out-this-mccool-event-in-december-at-upcrc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>API drafts posted at W3C - web developer comments welcome!</title>
		<link>http://software.intel.com/en-us/blogs/2009/10/22/api-drafts-posted-at-w3c-web-developer-comments-welcome/</link>
		<comments>http://software.intel.com/en-us/blogs/2009/10/22/api-drafts-posted-at-w3c-web-developer-comments-welcome/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 19:16:06 +0000</pubDate>
		<dc:creator>Andy Idsinga (Intel)</dc:creator>
		
		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[standards]]></category>

		<category><![CDATA[web]]></category>

		<category><![CDATA[web api]]></category>

		<category><![CDATA[web developer]]></category>

		<guid isPermaLink="false">http://software.intel.com/en-us/blogs/2009/10/22/api-drafts-posted-at-w3c-web-developer-comments-welcome/</guid>
		<description><![CDATA[Andy lists a set of device capability APIs that were posted at the WC3's Device API and Policy Working Group. These APIs are all about bringing better access to device hardware capabilities to web developers.]]></description>
			<content:encoded><![CDATA[<p>The other day ago our team, including <a href="http://software.intel.com/en-us/blogs/author/clayne-robison/">Clayne Robison</a> who also has a blog here on ISN, posted some <a href="http://dev.w3.org/2009/dap/system-info/Overview.html">API drafts</a> to the W3C's <a href="http://www.w3.org/2009/dap/">Device API and Policy Working Group</a>.</p>
<p>In a <a href="http://software.intel.com/en-us/blogs/2009/10/07/conversationstart-enabling-web-developers/">previous post</a> I kicked off a conversation with web developers about exposing device capabilities as javascript APIs and widgets in the browser.</p>
<p>Here's your chance to comment and help inform our web developer enabling activities. Tell us about how having better access to the device's hardware capabilities would make your web app implementation easier. Maybe you have a use case you would like to share?</p>
<p>Here is a list of APIs for device capabilities we proposed. </p>
<table rules="rows" cellpadding="1" style="width:95%;text-align:left;">
<tr style="border:1px dotted #cccccc;">
<th style="width:15%;">API</th>
<th style="width:85%;">Description</th>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Compass
    </td>
<td>
      Allows web apps to make use of a device's compass. The app can detect the<br />
      current orientation and receive asynchronous updates when the<br />
      orientation changes.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Power
    </td>
<td>
      Allows web apps to learn about the device's power state.<br />
      The app can detect the current power level, time remaining and receive<br />
      asynchronous updates about power level changes.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    CPU
    </td>
<td>
      Allows web apps to learn about the device's CPU - number of processors,<br />
      frequency, cpu usage levels.<br />
      The app can detect the current cpu usage and receive asynchronous<br />
      updates about cpu usage.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Display
    </td>
<td>
      Allows web apps to learn about the device's display capabilities - dots per inch,<br />
      supported orientations, brightness etc.<br />
      The app can detect the current orientation and brightness and receive<br />
      asynchronous updates about display orientation and brightness changes.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Connection
    </td>
<td>
      Allows web apps to learn about the device's network status and ability to<br />
      connect to services over the current network.<br />
      The app can detect check if an URL is reachable and check the latency<br />
      to and URL.<br />
      The app can receive asynchronous updates about network and service changes.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Thermal
    </td>
<td>
      Allows web apps to learn about thermometers connected to the device.<br />
      The app can detect the current temperature and receive asynchronous updates<br />
      about temperature changes.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Audio
    </td>
<td>
      Allows web apps to learn about the device's audio capabilities.<br />
      The app can determine which audio codecs are installed. The app can<br />
      also learn about speakers, microphones, lines in and lines out.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Video
    </td>
<td>
      Allows web apps to learn about the device's video capabilities.<br />
      The app can determine which video codecs are installed and what formats<br />
      and profiles they support. The app can also determine if codecs support<br />
      hardware acceleration.
    </td>
</tr>
<tr style="border:1px dotted #cccccc;">
<td>
    Input
    </td>
<td>
      Allows web apps to learn about the device's user input capabilities.<br />
      The app can determine if the device has a touch screen, if it<br />
      has multi-touch support, if a physical keyboard is present or if a software<br />
      keyboard is visible. The app can receive asynchronous updates about<br />
      physical keyboard attach / detach. The app can receive asynchronous updates<br />
      about physical pointer attach / detach.
    </td>
</tr>
</table>
<p>You can see the detailed API specs and example use cases at the <a href="http://dev.w3.org/2009/dap/system-info/Overview.html">WC3's site</a>.<br />
<strong>This is only the beginning</strong>. Stay tuned to the blog, or <a href="http://twitter.com/andyidsinga">my tweets</a>, for more API, widget and mashup proposals coming in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.intel.com/en-us/blogs/2009/10/22/api-drafts-posted-at-w3c-web-developer-comments-welcome/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
