Saturday, December 31, 2005

AMD64 3400+ is faster than Pentium EE?

I just realized that my AMD 6400+ laptop was actually faster than Intel's Pentium Extreme Edition 3.72 GHz CPU after reading the following link:

http://www.tomshardware.com/2005/11/21/the_mother_of_all_cpu_charts_2005/page24.html

Wednesday, December 28, 2005

Connecting Holux GM-210 GPS Receiver to Laptop

I bought my portable GPS receiver a few years ago. It was designed to connect to my Sony CLIE NX80V PDA. Somehow, since then I almost never used it. Perhaps because it was too cumbersome to put in my card. I thought I could connect to my laptop, but no it couldn't, because the connector is different.

Now, somebody has posted a way to connect it.

http://astro1.panet.utoledo.edu/~igor/GPS2Clie.html

Some Optimization Flags on GCC

Yesterday, I was playing around with some optimizations options supplied by GCC (ver 4.0.2) on my AMD64 laptop. I created a very small code to compute sin(x) * cos (x). As we know, Pentium and newer processors support a FP machine code to compute these two functions simulatenously in single mnemonic code: FSINCOS.

the code is as follow:

#include

inline double fsincos(double x)
{
return sin(x)*cos(x);
}

First, I compiled it to assembly source with no optimization enabled, just using defaults as follow:

> gcc -c -S fsincos.c -o fsincos.s

and then open the generated assembly code in fsincos.s. Overthere I saw somewhere it called internal library functions for sin and cos trigonometry functions as I expected. I then recompiled it with full optimization flags enabled:

> gcc -c -S -mtune=athlon64 -mfpmath=sse -msse3 -ffast-math -m64 -O3 fsincos.c -o fsincos64.s

Suprisingly, it still called GNU's "sin" and "cos" math functions!. What? I said (not loud, though). I checked again the gcc man page, nothing special about these things. Hm....let's try to add "387" in the mfpmath, I said in my mind.

So, the command is now as follow:

gcc -c -S -mtune=athlon64 -mfpmath=387,sse -msse3 -ffast-math -m64 -O3 fsincos.c -o fsincos64.s

Voila! now the assembly code called inline FP code "fsincos" in it. Since then, I add an environment variable in the enviroment as follow:

export CFLAGS="-mtune=athlon64 -mfpmath=387,sse -msse3 -ffast-math -m64"
export CPPFLAGS=$CFLAGS

X86_64 Assembly Nightmare

A few days ago I was trying to compile mpg123 application. It is a command-line MP3 player. I begin with command:

make help

It gave some options. First I tried "make linux", still failed to compile with a bunch of errors. I then tried "make linux-3dnow", or "make linux-3dnow-alsa". All of them failed to compile at some assembly files (*.s). I look at one of the assembly-code files, and saw that the codes were designed for 32bit platform, while my laptop was running x86_64 Suse v10.0 (64-bit Linux). I did change "pushl %ebp" etc. to "push %rbp" etc., the compiled went OK, but when I tried to run the program, it crashed with segmentation fault message.

Hmm...I then went to AMD website and download all the documentation. These PDF documents are huge (each PDF file has more than 300 pages). I started reading one of them. Will post any progress later.

Stay tuned!

64-Bit Power Struggle Heats Up

AMD still is the winner, at least for now.

http://www.eweek.com/print_article2/0,1217,a=167278,00.asp

Sunday, December 18, 2005

Fixes on FFTW for 64bit

I just downloaded FFTW library from http://www.fftw.org and tried to compile it with full optimizations and 64bit-enable flag. Many files were compiled OK, but when GCC tried to compile sse2.c, it failed with complaints:

Error: suffix or operands invalid for `push'
Error: suffix or operands invalid for `pop'
When I digged into the code I saw that it was using 32bit register ebx. I then changed it to rbx (64bit version of BX) and recompile it, it works.

Still need to test it rigorously whether the would inadvertent effect with all the optimizations. By the way, here is my optimization flags to GCC compiler:

CFLAGS="-mtune=athlon64 -msse2 -mfpmath=sse -ffast-math -m64 -O3"

I am in 64bit Now!

A few days ago, I did installed SUSE ver 10.0 64-bit edition to my Compaq Presario R3000z laptop. After backing up all the data to my new SEAGATE external hard drive (its 200 GB, so has plenty of space), I resized the Linux (reiserfs) partition from 15 GB to 25 GB, plus I added an extra 5 GB FAT32 partition to share files between Linux and Windows XP (in case I use Windows :-).

The standard SUSE does not came with NVIDIA's binary-only enhanced driver, so the graphic was standard. I then downloaded the 64bit driver from nvidia.com, but had problem installing it. Somehow downloading the 64bit driver from YaST worked out. I don't know what was the problem, but anyway it work OK so I could change the resolution to 1680x1050 and the graphic was fine.

Another problem was the wireless device. Linux 64bit does not like 32bit driver, so the old Broadcom driver for WinXP did not work. After googling up, I found the driver for Win 64bit (somebody posted it at www.planetamd64.com. You must register to the site to be able to download it, but it is free registration). Yet, the ndiswrapper still could not load the driver. From dmesg result, I saw there was one error saying "ntoskernel.exe: RtlZeroMemory" was an undefined function. Hm...

One problem was that the *.conf under /etc/ndiswrapper/bcmwl5 had different devid. I checked again using lspci -n showed a different devid. I just created a symbolic link to the existing conf file, but the link file name is now has the correct devid. Still ndiswrapper failed to load the driver. Oh yeah, I forgot to mention that I always set the environment variable CFLAGS="-mtune=athlon64 -msse2 -mfpmath=sse -ffast-math -m64", as well as CPPFLAGS.

I googled again, and found one posted message with the same problem. The guy later on said that he then upgraded the ndiswrapper to the latest one and it worked. I then gave it a shot. You know what? It was working!

The next tasks for me is to recompile xine (the one that comes in SUSE Linux does not support reading DCSS-encryption to read commercial DVD movies), also I need to recompile some others to the 64-bit.

Thanks to Google, I had successfuly make my laptop wireless work! I am getting more in love into Linux now. I rarely boot my laptop to Windows anymore. Only when I need to run "Age of Empir

Friday, December 2, 2005

It is now Era of Parallel Computing!

Everything is now done in parallel! AMD and Intel are pacing to get first to the market with their dual-core, quad-core or even octa-core processors, although I believe AMD won the 64bit and dual-core in the first cycle. Xbox360 which was released a few weeks ago (and still hard to find in the stores!) also use parallel processing capabilities. Sony's PS3 even will go farther by using 8 cores [well, it may not really like 8-cores in conventional processor. See http://www.ps3land.com/ps3specs.php].

The hardwares have come! Now it is turn for sofware developers to use this parallel computing power or not. That's the biggest concern now, especially on PC world. Many developers, many of them are making business sofwares, are still thinking parallel processing is overkill for most of softwares people use in the offices or homes. To edit documents, browsing or reading/sending emails, we do not need parallel computation. That may be true. But for power home users who do video editing, transcoding media files (e.g. from WAV to MP3 or MP3 to OGG format, or DVD to DivX/MPEG4 format), or doing 3D related processing (games, vector-based applications, CAD, raytracing etc.), parallel processing is a big deal.

Programming parallel computation is not an easy task. It is very complex and mindsqueezing task. First, we have to decompose computation process/function from serial to parallel into "grains" (the smallest part of computation that cannot be decomposed anymore) and maximize independences between each grains. Then, these grains have to be distributed to each processing unit. We need also to consider communication and processing time for each processing unit, especially if we want to load-balance the task. To make the story short, it is non-easy-at-all job for software developers.

A few weeks ago I read on some magazine (forgot, may be E-Weeks or InfoWeek), Microsoft now turning its eyes into parallel computation. In one conference, Bill Gates told the forum about it. This is a totally new world for Microsoft, as this is mostly dominated by UNIX-based Operating systems (including Linux). Even the fastest supercomputer, IBM's Bluegene, runs on a custom-tailored Linux O/S.

If you are a software developer, learn parallel programming now to grab this new job opportunity! Google, Microsoft, Intel, AMD, Sun, IBM, Nanotechnology companies, research labs, BioTech/pharmaceutical companies, game studios and many other companies are looking for the talents to start coding their parallel-processing computers/system. Remember Folding@HOME or SETI? these are a few of the parallel-programming tasks you need to master.

64bit or 32bit?

Novell's SUSE has released its Linux distribution to the latest 10.0 (and 10.1 is underway in the development). At opensuse.org, I saw there is also ISO file available for Linux for 64bit processors. A few weeks ago I downloaded 5 ISO files for installation CDS from opensuse.org (and just recently converted them to a single DVD. Just follow instructions in http://www.opensuse.org/Making_a_DVD_from_CDs).

I booted up my AMD64 laptop with the DVD, but then I changed my mind. Not to upgrade my Linux now and stayed with the older version (SUSE 9.3). One of the reasons is that, my Linux partition is too small for the 64bit (I have only 12 GB out of 80GB HD of my hard drive for Linux, the rest is for WinXP). I searched the internet and found some discussions saying this 64bit requires almost double as much space as 32bit version. This is because there is /lib64 and /usr/lib64, in addition to /lib or /usr/lib, for 64bit so we can run applications with both versions. Also, 64bit files are generally larger than 32bit, because some of the processor's instructions require extra bytes to handle 64bit operations.

Sometime ago, I read on the Internet that ndiswrapper might not work in 64bit environment. But I saw there was 64bit version of it on the CD, so I believe it is now supported. This was another reason I was scared to upgrade it in the beginning. Also, NVIDIA and ATI now support 64bit version of their graphic processors. The remaining issues are minors, I guess.

What are the benefits of using 64bit system? OK, first of all, it can handle huge memory space (hundreds of terabytes, instead of just 4 GB as on 32bit version). Another thing is, theoritically it should be faster. Why, you might ask? Because the processor can transfer data as twice as much in the same duration than the 32bit system. Also, security gets a big benefit because now it can directly handle long integer computation directly down to the machine code. I recall, with 32bit environment, we need to handle large integer computation manually using some algorithms.

Anyway, this is just my hypothesis. I have not tested it yet nor benchmarked it. I will do it soon, but I need to get my Seagate's 200 GB external Hard drive first to backup all my data before doing this. Will post it here as soon as I've done it.