Thursday, June 07, 2007

What happened to google search?

Google search is acting really weired recently. First off, my homepage disappeared from the search results by using keywords "Pan Yu homepage" (without the quote marks), which used to be the second results on the first page, but now totally disappeared (I haven't found within the first 10+ pages). Instead, lots of other web pages which neither contain consecutive "Pan Yu" nor are homepages of any sort are listed. At the beginning, I was wondering whether this is caused by the "personalized search" just launched, though I don't remember enabling it. I logged out my google account, searched again, nothing changed. Then I asked my labmate Edward to try the same thing for his homepage. This time, more counter-intuitive thing happened. When he typed "edward sim", his homepage appeared at the end of the first result page, however, trying "edward sim homepage" returned irrelevant stuff as what happened to me.

I know google has integrated news results to the normal search results a moment ago, but apparently what listed for our homepage search are not news. Google is acquiring a lot of companies and participating lots of other services outside the search world. While it used to move cautiously, it is more aggressive nowadays. I'm a little worried about google because it used to be based on pure technologies and people are really admire the objectiveness and spirit behind this. Growing into an empire that dominate the web may not be bad, since a lot of innovations and good services really benefit everybody and change the world. But except all those services and the so called google operating system, I really hope the heart of google can always be the same, being dependable and reliable, moving solid moves.

Wednesday, June 06, 2007

Web 2.0 services, my online office.

Blogging is surely one of the pioneers of Web2.0, and also the first one I started to participate. In fact, the concept of wiki was before blogging, and I also started to search in wikipedia before writing my blogs, but I've never contributed anything to wiki except for "using" it. Below is a sketch of Web2.0 services I'm using currently:
Half of them are google services. In fact, from day one google launched gmail, the light of personal online office had turned on based on the large storage available for each account. Google had acquired a lot of Web2.0 companies and integrated their services under a universal account for each gmail user. An era of online office has come, just open your arms and brace it!

Wednesday, May 30, 2007

A bug

A stupid bug in my program:

vector < a > content;
vector < a* > cp_array; // content pointer array

Constructing content and cp_array at the same time, using cp_array[x] = &content[y]. Later I found some pointers in cp_array didn't point to the correct content element. I doubted the logic of my program first, and then looked for all pointer assignments, but all seemed to be correct. After step by step debugging and printing intermediate array values (damn, it's hard to debug stl using gdb even though none optimizations were switched on), I found the content cp_array pointed to changed after a content.push_back(a), it is the push_back operation that caused content to reallocate memory and then what cp_array pointed to was nullified because the address of content vector was changed.

What I've learned: Do not use pointers on dynamically allocatable content, use indices instead.

Wednesday, March 28, 2007

Get fonts right in pdf formated papers

I was struggling with font problem in my paper these days, and finally got done with it. I use winedt/MikTex companions under windows XP since 3-4 years ago. And PowerPoint for the figures, since I can directly print to pdf-printer (feature of acrobat) to get pdf figures nowadays. All these tools works efficiently. However, they didn't comply with ACM's strict requirement of fonts in publications, which restricts to the use of "type 1" and "embedded" fonts ONLY. Now, I have two problems. First one, I always have "truetype" font in my figures, since I don't have any "type 1" font installed on my windows. Second one, there are several "type 1" fonts cannot be embedded, such as "times", "courier" and etc.

================================================================

For the first problem, I need to install and use the "type 1" font corresponding to the "truetype" font I used in PowerPoint, so that the pdf figures generated contain "type 1". The free way of getting "type 1" font is to convert from existing truetype font (under \WINDOWS\Fonts). There are two ways of doing this:

First, use fft2pt1 (truetype to type 1 converter) to convert the truetype font (from a .fft file to a .pfb file and a .afm file), then use afm2pfm to convert the .afm to a .pfm file that windows recognizes, and finally drag the .pfm file to \WINDOWS\Fonts folder to get it installed. Note that if you're NOT using windows XP or 2000, you need to install Adobe Type Manager (ATM) to install the type 1 font. For now, if you're lucky, you can see and use the type 1 font in the PowerPoint font box (I cannot for some reason I don't know).

The second way to do this is to use FontLab (a commercial software) to generate the type 1 font. Just open the .ttf font, go to File->Font Info to give it a different font name (first page), go to File->Generate font, and choose to generate the "type 1 binary file (*.pfb)". Then install the font by dragging the .pfm file to \WINDOWS\Fonts folder. I managed to see the font in PowerPoint using this second method.

In PowerPoint, substitute all the fonts with the type 1 fonts you generated. When printing to the pdf printer, make sure to set the options of pdf printer to embed all the fonts (for my case, under "conversion settings->fonts->embedding" and add all the fonts to the "always embed" list). When the pdf file is produced, open it with acrobat, press CTRL+D to see the fonts. Most likely, you'll have all the fonts embedded.

An exception may occur if you use a non-English version of PowerPoint. For me, Chinese version. The default font is Sim-Sun. Some times, even all the places you can touch is set to non Sim-Sun font, it will still be included in the pdf file. In this case, open a new PowerPoint file, copy and paste you figure part by part to the new file. Produce a pdf file and check the font to see where Sim-Sun is introduced, and then try to modify or remove them. For me, I found starting spaces (by accident) introduces Sim-Sun, so I removed them.

==================================================================

For the second problem, the cannot-be-embedded fonts are from the text compiled with pdflatex, which are assumed (by whom?) to be available on all systems (but not true), and referred as Base14 fonts.

To embed them, the simplest way is to install the latest version of MikTex (2.5) and ensure the pdfeTex version is above 1.20. By default, Base14 fonts are embedded. If you're using Tex system under Linux, similarly you need to ensure the pdfeTex (or pdfTex, or pdflatex) is above version 1.20. And then edit "/web2c/updmap.cfg" to ensure the following options is set to true: pdftexDownloadBase14, dvipdfmDownloadBase14. Finally, run updmap as root to update the configuration.

Another way of doing this is save your pdf document with the not-yet-embedded fonts as a PS file, using "save as..." in acrobat. Then use the command "ps2pdf14 -dPDFSETTINGS=/prepress -dEmbedAllFonts=true mydoc.ps" to generate the pdf file with fonts embedded.

I compared the results of the above two approaches, i.e., the direct pdflatex generating approach and the pdf->ps->pdf approach. It seems to me that the former approach is better in the following aspects. It includes less redundant fonts, so the file size is smaller. The graphs looks more original, and scrolls faster especially when complex patterns are used (pdf->ps->pdf approach converts 2 times, and may introduce some distortions and more fragments to the vector graph, thus show up slowly).

We're done.

Monday, March 19, 2007

Tips

Do not try to compile a large program not compatible with your current version of gcc, instead, compile a version of gcc compatible with the program, and then use the gcc to compile it. (however, newest gcc does not even compile the old versions. In this case, compile a not-that-old version which compiles the old version to compile the old version. What a mess!)

Installing Fedora Core 6 on VMWare 5.5

Since the up-to-date VMWare still doesn't support FC linux officially, you need to pay some effort installing and configuring FC6. I assume the readers have successful installation experience of other linux under VMware before, so only key points related to FC6 installation will be addressed.

1. Create a VM:
Open VM's "New Virtual Machine Wizard", make sure you choose the following options: "Custom" -> New - Workstation 5 -> "Other Linux with 2.6.x kernel" -> ... -> LSI Logic (for SCSI Adaptor) -> ... -> SCSI (recommended).

The above options will make sure FC6 installation wizard find your virtual disk properly.

2. Install VMWare Tools:
Make sure you have kernel-devel corresponding your running kernel installed, which provides the kernel headers needed by VMWare Tools. By default, you need to download and install kernel-devel by yourself. Note that the version of kernel-devel must match your running kernel exactly (for example, "2.6.18-1.2798.fc6xen.i686" does not match with "2.6.18-1.2798.fc6.i686), so if you cannot find a kernel-devel matches the kernel, you need to install a kernel that matches the kernel-devel. I don't recommend using yum to update the kernel and kernel-devel, because they don't always match (and you may not be able to find a co-existing pair). So we go the traditional rpm way.

To check your current running kernel, use "uname -r".

To download kernel-devel, goto "http://fedora.redhat.com/download/mirrors.html", find a mirror site close to your place, and download the rpm package of kernel-devel. For example, I would go to "ftp://ftp.oss.eznetsols.org/linux/fedora/6/i386/os/Fedora/RPMS/" in Singapore, and download "kernel-devel-2.6.18-1.2798.fc6.i686.rpm", and install it by "rpm -ivh kernel-devel-2.6.18-1.2798.fc6.i686.rpm".

You may need to download and install the kernel matches the kernel-devel as well. Similarly, download kernel-2.6.18-1.2798.fc6.i686.rpm and install it. Then reboot your linux. Stroke "enter" at boot up to choose the newly installed kernel. Or you can modify the grub configuration file "/etc/grub.conf", change the "default=" parameter (0 for the first kernel, 1 for the second kernel) for the new kernel.

Now you can locate the kernel headers under, for example, /usr/src/kernels/2.6.18-1.2798.fc6-i686/include.

Then mount your VMWare Tools iso, and run "vmware-install.pl". Key in the above kernel headers when asked. You should be able to install it successfully now.

3. Configure resolution of your X.
Edit "/etc/X11/xorg.conf" with root. Add the following section at the beginning of the file.

Section "Monitor"
Identifier "vmware"
HorizSync 1.0 - 10000.0
VertRefresh 1.0 - 10000.0
EndSection

Add a line "DefaultDepth 24" after "Mornitor "vmware"" line in "Screen" section (assuming you have a OK graphic card). Then change the "Modes" line under Depth 24 to your desired resolution. For example "Modes 1280x800". Then startX.

Reference
http://www.thoughtpolice.co.uk/vmware/howto/fedora-core-6-vmware-tools-install.html
http://www.linuxquestions.org/questions/showthread.php?t=503651
http://www.lowlevel.cz/log/pivot/entry.php?id=80

Saturday, March 17, 2007

My Must-have Firefox Addons

As a IT guy, switching among different OS and migrating from systems to systems (e.g., my desktop and a few of my laptops) is not uncommon. Whenever this happens, the first thing I would make sure is the up-to-date Firefox is installed with the following must-have addons:
  1. Del.icio.us Bookmarks: for online bookmarking service, sharing bookmark links with others or myself (so that i don't need to synchronize the bookmarks from 3, 4 computers I use).
  2. GUtil: grants me instant access to various google services I'm using (i.e., gmail, reader, docs, calendar, blogger, album) with button click.
  3. ScrapBook: great substitution for "save page as..." function, which allows you to capture (and capture certain parts), organize, comment and edit on interesting web pages. The only problem is that it's not an online thing, and you need to export/import among different systems you have.
  4. Google Toolbar for Firefox: this is actually with Firefox package, but I remind you to click on the "G" icon with the downward arrow, you will find it's not only for googling (i.g., I need Webster for English words that doesn't recognize me).
  5. Session Manager: resume the tabs I was reading last time after restarting Firefox.
  6. FireFTP: for lazy guys.

Thursday, March 15, 2007

How to add custom instructions (ISE) to Trimaran

This guide is incomplete at the moment. With the project evolving, more comprehensive and detailed instructions will be gradually patched. Currently, only custom instructions up to 4 inputs and 4 outputs are supported, with minimum modification to the original Trimaran code.

1. Generate custom instructions in Elcor.
This step involves adding an extra stage to Elcor, before instruction scheduling and register allocation stages, in order to identify suitable subgraphs for custom instructions, and then replace the subgraphs with custom operations.

ISE identification code is under elcor/src/ISE.


Other files to be modified:
elcor/src/Graph:
opcode.h: define the opcode. In enum type IR_ROOT_OPCODE, define a new root opcode:
ROOT_CUSTOM32 = 191,
In enum type Opcode, define a new opcode in terms of root opcode:
CUSTOM32_W = ROOT_CUSTOM32,
opcode.cpp: Instruction name (a string) and its opcode (a macro value) should be bounded in two maps el_string_to_opcode_map and el_opcode_to_string_map, in one of the map initialization functions. Here, we add custom instruction bounding in el_init_elcor_opcode_maps_arithmetic():
el_string_to_opcode_map.bind("CUSTOM32_W", CUSTOM32_W);
el_opcode_to_string_map.bind(CUSTOM32_W, "CUSTOM32_W");

elcor/src/Main:
el_driver_init.cpp: insert a global switch variable "El_do_custom_instruction = 1;" to turn on/off ISE phase.
processor_function.cpp: Insert "#include "ise_main.h" " at the beginning, which provides definitions of functions of the ISE code.
Insert a call to "ise_main(f);" before instruction scheduling function "El_collect_pre_processing_stats(f);" to enter the ISE phase.


Modify GNUmakdfile under elcor/src in order to find the ISE code and produce corresponding libraries for ISE.

Modify elcor/includes/makelinks, add links to header files of the ISE code. Any changes on existence of header files require executing "makelinks" manually again.

After adding or removing files to Elcor source (mainly we refer to elcor/ISE) and modifying corresponding places in GNUmakefile, "make depend" need to be issued in order to generate dependency files under each source directory (".dependences"), otherwise, modifying the new .cpp file won't cause recompilation.

2. Append new machine description (mdes) sections for the custom instructions.

Machine description defines the format, resource usage, and timing for each instruction (operation and operands), and is the information database where Trimaran instruction scheduler refers to. Note that you do not need to define the detailed semantics of a custom instruction in the machine description file. Instead, you define "Scheduling_Alternative" which groups instructions with the same semantics but different resource usages (e.g., encoding, reservation table, timing); "Scheduling_Alternative" is used by the instruction scheduler to choose an appropriate instruction for an operation to minimize the schedule length. In most cases, a custom operation corresponds to only one custom instruction, i.e., only one "Scheduling_Alternative". Execution semantics of a custom instruction is defined in the Simu (Simulator).
High level machine description file (*.hmdes) need to be compiled using "hc" compiler to low level correspondence (*.lmdes).

3. Generate Rebel form.
The Simu uses Rebel form to simulate execution of test programs.

4. Modify Simu.

(a). Define the semantics of custom instructions in "PD_ops.h" and "PD_int_arith_ops.c" (if you want to put the function definition there). The simulator actually calls the functions defined here to "execute" the instructions. If you observe the "binary" generated from Elcor to Simulatable source code (the "urbenchmark.O_el.simu.c.tbls" file), the function name appears in the fifth field of each instruction.
(b). Add custom instructions in "PD_ops.list" for the dissembler (if you ever want to use it).
Step (a) and (b) assure the Simulator understand how to execute a custom instruction, but yet we are not able to convert the Rebel form to the Simulatable source code. Step (c) fills this code gen gap.
(c). Modify "opcode.h" and "opcode.cpp" under elcor/src/Graph directory. In "opcode.h", add custom instruction opcode (digit) to IR_ROOT_OPCODE and Op_code section. In "opcode.cpp", bind custom instruction opcode with corresponding custom instruction name in function "el_init_elcor_opcode_maps_arithmatic()" (if u want, in this function...). This binding will let the code gen recognize the custom instructions appearing in the Rebel form.