Monday, February 19, 2007
Al Franken, Minnesota Politics, and System i

Al Franken was in Rochester today. He is a DFL candidate for a seat in the U.S. Senate.
In Minnesota, the Democratic party calls itself the Democratic-Farmer-Labor Party, or DFL for short. Until recently, the Republicans called themselves the Independent-Republican Party, or IR for short.
Leave it to Minnesota to be different. Is it any wonder that a computer system designed and developed here would also be different? I'm glad that in this case, different is good.
Saturday, February 17, 2007
Unlocking Hidden Optimizations
The C compiler for System i provides a packed decimal data type, but not a zoned decimal data type. When working with a data base or exchanging data with RPG or COBOL, it is sometimes necessary to convert between the zoned representation of decimal data and other data types such as packed decimal, floating point, and integer.
The common technique for converting between zoned and another data type in a C or C++ program is to use the cpynv function described in "ILE C/C++ for AS/400 MI Library Reference". For example, the following code snippet shows how to convert from packed(30,9) to zoned(7,0):
#include <mih/cpynv.h>
: : :
char znd[7];
_Decimal pkd(30, 9);
cpynv( NUM_DESCR(_T_ZONED, 7, 0), znd,
NUM_DESCR(_T_PACKED, 30, 9), (char*)&pkd );
There is an important usage note in the description of cpynv in the "ILE C/C++ for AS/400 MI Library Reference". The note reads as follows:
- zoned to packed, float, signed integer, or unsigned integer
- packed to zoned
- signed integer to zoned
- unsigned integer to zoned
The built-in function _CPYNV also provides access to the equivalent MI instruction. When using the _CPYNV instruction, you must specify literal constants for the receiver and source descriptor values. _CPYNV is considerably faster than _LBCPYNV (and cpynv) for the following conversions:
The code snippet above uses the NUM_DESCR macro to build the first and third argument values, which describe the attributes (data type and length) of the destination and source locations. The usage note tells us that if both attribute arguments are literal values (rather than variables whose values are not determined until runtime), the compiler will attempt to optimize the conversion by decoding the attribute values and generating code to perform the conversion more directly, which may perform significantly faster. Unfortunately, however, when the NUM_DESCR macro is used to generate the attribute value, the resulting argument value is a complicated expression that the compiler cannot evaluate at compile time. As a result, the macro inhibits the optimization to perform the conversion more directly.
To enable the optimization, NUM_DESCR must be replaced by a constant attribute value that is pre-calculated (by you). The attribute is a 4 byte value with this encoding:
TTFFLL00
where:
TT- is a 1-byte code for the data type
FF- is a 1-byte code for the fractional digits (the 3rd argument to NUM_DESCR for packed and zoned data types)
LL- is a 1-byte code for the total number of digits (the 2nd argument to NUM_DESCR for packed and zoned data types)
00- the last byte must be zero
The data type values are defined in <mih/micptcom.h> (use the command "strseu qsysinc/mih micptcom" to browse). Some example attribute values are shown below:
NUM_DESCR(_T_PACKED, 7, 0) is equivalent to0x03000700
NUM_DESCR(_T_ZONED, 7, 0) is equivalent to0x02000700
NUM_DESCR(_T_PACKED, 30, 9) is equivalent to0x03091E00
Using this information, the original call to cpynv should be replaced with this call to _CPYNV, which will generate the most efficient code to convert from packed to zoned:
_CPYNV( 0x02000700, znd,
0x03091E00, (char*)&pkd );
Tuesday, February 13, 2007
i5: The Romantic Side
Sunday, February 11, 2007
Yahoo! Pipes Fuels Need For Feeds
Yahoo! Pipes provides a visual editor for remixing feeds in clever and useful ways. The resulting pipes can then be added to your start page or other web pages. I currently have several pipes defined and added to my netvibes-based start page.
Prior to tools like netvibes, Google desktop, and pageflakes, I had little need or interest in feeds. Instead I used news aggregators like Daily Rotation.
The ability to customize and tailor my browsing environment with pipes and netvibes is driving my need for more sites with feeds. Over time, I suspect that I will stop visiting those sites that do not provide feeds.
Actually, what would be nice is the ability to extend Yahoo! Pipes with "adaptors" that would allow me to add my own function for converting an arbitrary url to rss output.
The Landscape of Parallel Computing Research
"The Landscape of Parallel Computing Research: A View from Berkeley"
is the title of an interesting paper referenced on Slashdot that discusses recent hardware trends and their impacts to programming models and operating systems, especially wrt supporting parallel computing. Nothing radical -- in fact, it reinforces much of what has been written and discussed on the subject -- but impressive because it incorporates the conclusions of a dozen authors.
The slashdot discussion is here:
http://developers.slashdot.org/article.pl?sid=07/02/10/2014255&from=rss
The paper is here:
http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-183.html
Labels: hardware, programming, software
Tuesday, February 06, 2007
Mark Shearer
The System i Network has a 10 second survey to let you "characterize Mark Shearer's leadership of the System i Division" (see http://www.systeminetwork.com/article/w/1001/n/5054/i/6275/a/54003/index.html)
From an IBMer's perspective, Mark is the most visible product manager that we've ever had. He's convinced me of his commitment to System i.
I gave him an excellent rating.
