Diagnosis of KPilot/Palm’s messy text

Desktop, Gentoo November 29th, 2006

It is a pain of ass that Palm does not support Unicode, definitely a big design flaw. It is also a pity that CJKOS would not support the Unicode either, we lost the last chance to patch the system by third party hack. I have to use the GBK encoding in Palm before the legendary PalmOS Garnet or Access Linux Platform available. Unfortunately, the KPilot fails to synchronize the name of the contacts from the KAddressbook, for example, 钟章环 becomes 章&, ^. It is quite curious that part of the string is encoded correctly. Later, I dig into the code, and found this code snippet:

if (!text.isEmpty())
        {
                fAddressInfo.entry[field] = (char *) malloc(text.length() + 1);
                strlcpy(fAddressInfo.entry[field], codec()->fromUnicode(text), text.length() + 1);
        }

The bug results in that the length of the UTF8 encoded string is not the same as the GBK encoded string. A workaround is like this:

if (!text.isEmpty())
        {
                QCString locale = codec()->fromUnicode(text);
                fAddressInfo.entry[field] = (char *) malloc(locale.length() + 1);
                strlcpy(fAddressInfo.entry[field], locale, locale.length() + 1);
        }

It has been submitted to the KDE Bugzilla, Bug 138108.

Glimpse of SC2006: Acceleration

HPC November 22nd, 2006

It is more cost-effective to plug one acceleration board into the desktop to achieve better float-point performance by migrating to the PC cluster or commercial supercomputer for medium-scale applications. In SC2006, there are at least four techniques:

GPGPU

GPU is dedicated ASIC for multimedia, gaming applications with optimized texture/render pipeline architecture. Generic Purpose GPU is based upon vendors’ API to boost the float-point performance. PeakStream unleashes the power of ATI GPU via ATI proprietary interface, other platforms are in development. RapidMind trade off the performance for portability by using OpenGL interface.

CELL

CELL may be the first generic purpose CPU designed for the multimedia application. There have been some commercial products available in the market besides Sony’s PS3, for example, the acceleration board from mercury.

Clearspeed

Clearspeed acceleration board had made a big buzz in the SC2005. It is quite impressive for the computing capacity and power consumption.

ClearSpeed board


FPGA based reconfigure computing

This exotic technology has been around for a few year, the main barrier for its popularity is the steep learning curve for the software developers to implement the functionalities in Hardware Description Language(HDL). Some high level programming language either lacks the expressiveness of parallelism or performance.

The main barrier for the co-processor architecture is the memory bandwidth, PCI Express is still the bottleneck for transportation of CPU and acceleration board. Maybe one day, AMD would embed the GPU to the CPU to replace the float-point unit if they could figure out the power consumption and manufacture.

Another challenge comes from the programming language and library. The new programming language designers fall into the dilemma: How could we hide the low-level detail to make it more expressive and intuitive to the programmer and exploit the low-level features to enhance the performance at the same time? We must trade off between them, but where is the turning point?

Glimpse of SC2006: Visualization

HPC November 22nd, 2006

Boston University visualization demonstration

Data visualization is quite impressive to the novice audience. For example, the demonstration of Boston University made a big buzz in the attendee. The photo shows the snapshot of the interaction of solar wind and magnetic field of earth is simulated and then visualized via opendx, two virtual cameras are placed to generate the 3D effects. Audience need to wear 3D glasses as in the Universal Studio.

NIST visualization demonstration

Another example comes from NIST. This application is used in the medical image processing. The ghost image is more clearer in the simple spirals.

Sun visualization architecture

Data visualization is so essential that Sun develops the distributed environment: a very thin client(left) and dedicated rendering server(right). The user stores the working environment and data in the smart card, once it is plugged in, the server authenticates the user and bring the last environment back. The rendering server is equipped with dedicated nVidia GPUs for the sake of power efficiency.

Prime time for Python in HPC?

Development, HPC, Python November 21st, 2006

Python is a powerful, flexible and elegant dynamic programming language, pervasively used from system administration to web applications. However, due to the lame performance, that is the price we pay for the versatility, Python is seldom used in the high performance computing.

Things have been changed recently. GPGPU, Cell, Clearspeed have emerged to our horizon as the new candidates for their outstanding performance/power ratio. They all work in the accelerate board manner, aka, the host(processor) prepares the data, pushes it to the co-processor, does some trivial work, and waits until the slaves return results. Python and other dynamic languages may glue the different pieces. Here are some approaches on the go:

StarP Parallel Framework

StarP targets to the scientist who demand high performance but reluctant to parallelize their code. The framework plays the magic to hide all the parallel diagram by attaching suffix *p to the variables. The job is decomposed in the client to basic linear algebra operations and distribute it to the server, then fetch the result if necessary. Here is the exploration of StarP magic in Python.

The essential problem for parallel computing is how to decompose the job to different work space and how to minimize the communication between the threads. StarP provides some built-in distribution and give the users options. Anyway, there is no silver bullet in this field.

Global Array with Python binding

Global Array is another approach, It sits on MPI, but provides PGAS programming model by using a set of API. Although it is too MPI-Fotran-like, it still may arouse the interest in the python community to implement a PGAS programming model without introducing new language constructs.

What is next ?

Current PGAS implementations(UPC, CAF and Titanium) share the same communication backbone, GASNet, is it possible to build a GASNet python binding and take the same approach as Global Array to construct a python PGAS library?

Debugging Web(1) – Live HTTP Headers

Web November 21st, 2006

This problem has been bothered me for quite a long time. Although only 5.4% of my blog readers use MSIE, and I always promote Mozilla Firefox, their browsing experience should not be disregarded by all means.

Here is a good tool to analyzes the underlying HTTP traffic, Live HTTP Headers, if you think WireShark is overkill. This add-on captures all the HTTP header requests and status codes, like this:

Live HTTP Headers in action


Surprisingly, I found that there is also a 404 error in Firefox when accessing /nitfyCorner.css after all the elements are loaded. It is possible that Firefox and other browsers(Konqueror, Opera) just simply ignore the missing style sheet while MSIE refuses to render the whole page at all. I dived into the niftycube.js and found the following code snippet:

var oldonload=window.onload;
if(typeof(NiftyLoad)!=‘function’) NiftyLoad=function(){};
if(typeof(oldonload)==‘function’)
   window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

Once the niftycube.js is referenced, the script hacks the windows.onload to add the CSS to the header, however, the hardcoded target is wrong. Since I manually added the style sheet in the header, it always takes effect regardless whether AddCss works or not. After I fixed this bug, MSIE shows the gallery without any problem.

Here arouses another question: how comes MSIE manages to render the blog with the same bug?