Skip to main content

Sponsors

Work

Parallel Programming with SpeedGo Computing

Parallel programming is a new popular curriculum for graduate schools. As processors as in CPU, GPU, etc. are hitting their clock speed limit, higher core count is expected in modern processors instead of higher clock as before. There is no reason why one should hesitate to take up parallel programming course and workshop.

While you may think that there are no obvious applications that require the multiple cores settings, why should I bother? However, reality is cruel. Those standing still simply get obsolete. It's up to you to innovate! Innovating is the key to success.

Check out SpeedGo Computing blog and their website for more information about parallel programming.

Ideas for Supercomputing

Posted in

Not enough computers to run your compute intensive simulations? 3D graphics rendering? DNA sequencing?

There are a bunch of computers readily for use most of the time.

  • Cybercafe
  • School library
  • Office at night

Research institutes, 3D graphics studio, ... often run out of hardware resources. Can they simply pay those owners of idling computers and run their tasks on these computers?

Perhaps this can boost the revenue of cybercafe. :) It's a win-win situation for both parties.

Impulse C API in Brief

Posted in

DMA:

Prototype: co_memory co_memory_create(const char *name, const char *loc, size_t size);  
// "Name" is used by external application to identify this memory.
// Create 64 bytes memory from the heap. loc is architecture dependent.
co_memory_create("name", "heap0", 64);

Prototype: void co_memory_readblock(co_memory mem, unsigned int offset, void *buf, size_t buffersize);
Prototype: void co_memory_writeblock(co_memory mem, unsigned int offset, void *buf, size_t buffersize);
Prototype: void *co_memory_ptr(co_memory mem); // Return a C pointer to the buffer of the shared memory.

Fixed-Point Arithmetic:
Example of format specification - 1s8.23 => 1 sign bit, 8 bit integer, 23 bit fraction.
We can choose several modes: saturation, floor, ceil.

co_int16 a = (co_int16) FXCONST16(96,7); // a <- 96 in 1s8.7 format.
c = FXADD16(a,b,8); // Add a and b in 1s7.8 format.
c = FXMUL32(a,b,8); // Multiply a and b in 1s7.8 format.
c = FXDIV16(a,b,10); // c <- a/b in 1s6.9 format.

Macros: FXADD8(), FXADD16(), FXADD32(), FXMUL8(), FXMUL16(), FXMUL32(), ...

Benchmarking Yafray on AMD64 X2 4200+ and Pentium 4 HT 3GHz

Posted in

Did a benchmark on Yafray, a rendering software, recently on several cases. See the plot below,

Running in 64bit helps quite a bit in the performance. However, it's not clear if it is due to the use of different compilers.

For AMD64 running 64bit, I use GCC 4.1.1 64bit.
For AMD64 running 32bit, the compiler is unknown as I use the rpm provided by yafray.org.
For Pentium IV, I use GCC 4.1.1 32bit.

Overall, it should be fare enough to compare AMD64 64bit and Pentium IV 32bit since they are using the same compiler.

Compiling Yafray on AMD64 Running FC6

Posted in

After reading some documents and hacking on the scons .py codes. I found an easy way to compile Yafray in AMD64 FC6.

In the file SConstruct, merely edit the following line

common_env=Environment(ENV=os.environ, CXXFLAGS = config.cxxflags);

to

common_env=Environment(ENV=os.environ, CXXFLAGS = config.cxxflags, SHLINK = "g++", LINK = "g++");

The compilation will then use g++ as the linker with shared library.

If the compilation cannot find the 64bit OpenEXR library, edit the line in file linux-settings.py

def get_libpath(args): return [ exr.PATH + "/lib" ]

to

def get_libpath(args): return [ exr.PATH + "/lib64" ]

Then compile as usual: scons -j 2


Obsolete

Given yafray-0.0.9.tgz:

# Install scons as needed by yafray. Yafray no longer uses GNU make.
$ yum install scons
$ tar zxvf yafray-0.0.9.tgz
$ cd yafray

# Start compilations
$ scons
ld -shared -no_archive -o src/yafraycore/libyafraycore.so src/yafraycore/bound.os src/yafraycore/buffer.os src/yafraycore/yafsystem.os src/yafraycore/tools.os src/yafraycore/camera.os src/yafraycore/color.os src/yafraycore/filter.os src/yafraycore/matrix4.os src/yafraycore/object3d.os src/yafraycore/triangletools.os src/yafraycore/mesh.os src/yafraycore/kdtree.os src/yafraycore/triclip.os src/yafraycore/reference.os src/yafraycore/renderblock.os src/yafraycore/scene.os src/yafraycore/forkedscene.os src/yafraycore/threadedscene.os src/yafraycore/ipc.os src/yafraycore/ccthreads.os src/yafraycore/noise.os src/yafraycore/background.os src/yafraycore/sphere.os src/yafraycore/texture.os src/yafraycore/metashader.os src/yafraycore/targaIO.os src/yafraycore/triangle.os src/yafraycore/vector3d.os src/yafraycore/photon.os src/yafraycore/params.os src/yafraycore/HDR_io.os src/yafraycore/spectrum.os -lpthread
ld: /usr/lib64/libpthread.a(pthread_create.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib64/libpthread.a: could not read symbols: Bad value
scons: *** [src/yafraycore/libyafraycore.so] Error 1
scons: building terminated because of errors.

I recompile yafray with -fPIC does not help at all. Replace 'ld' by 'g++' solves the linking problem. But I dont know how to do that using scons! Even if I create libyafraycore.so manually, running scons will still try to ld!

Out of no choice, I use a quick and dirty workaround. Generate the list of commands with dry run option. Replace the 'ld' commands with 'g++'. Then execute the list of commands.

$ scons -n > run
$$ Edit run, replace 'ld ' by 'g++ '. Using vi, run ':%s/ld /g++ '
$$ Remove scons outputs and -no_archive in run if you dont like to see warning outputs.
$ chmod +x run
$ ./run
$ ls src/yafray

I got the 'yafray' executable file created. Installation is not done yet. We still have to install yafray .so library.

# You can install the .so into /usr/lib or /usr/local/lib.
$ mkdir /usr/local/lib/yafray
$ cp src/backgrounds/*.so src/lights/*.so src/shaders/*.so  /usr/local/lib/yafray/
$ cp src/yafraycore/*.so src/interface/*.so /usr/local/lib/
# Remember to add /usr/local/lib into ld.so.conf.d/
$ ldconfig
# You can install yafray into /usr/bin or /usr/local/bin
$ cp src/yafray /usr/local/bin

DONE!!! scons disappointed me.

Last Day in a Research Institute

Posted in

Have been working in a research institute for 3 years. Today is my last day of service in the institute. Now, .... relax ~~~ :) Misc work is off. Next Monday, I'll start a new challenge working on something new, yet my knowledge is directly applicable. :)

What I learn in these 3 years:

Use the right tools to solve the right problems ... if you find the right problems. Otherwise, just enjoy your life! ;)

FPGA Optimization

Posted in

C-level Optimization such as in Impulse C

  1. Limit the amount of hardware resources used by introducing loops.
  2. Split arrays for multiple storage accesses. Storage for each array can be constructed to stream directly into local computation unit, i.e. parallel local memory accesses. Note that register bank can be read by many sources in the same cycle. Thus, small & hot data should go into register.
  3. Improve communication performance by fully utilizing the CPU-FPGA bus width. Transfer more bits at a time matching the CPU-FPGA bus width. DMA is another feasible mechanism for communication. But it will hog the bus if you do it too frequently.
  4. Loop unrolling to realize higher parallelism using more gates in FPGA.
  5. Pipelining in main loop to close the communication gaps of different iterations due to data loading & flushing.

Reference: Optimizing Impulse C Code for Performance by Scott Thibault & David Pellerin.

Logic-level Optimization in Boolean Network model

  • Restructuring operations.
    • Reduce dependent inputs.
    • Factorize.
    • Substitute.
    • Eliminate.
  • Node minimization.
    • Minimize using dont-care inputs.
    • ...

Learn to GOOGLE

Posted in

Friends asking me when am I going back to KK :? . Friends also asking me what am I going to contribute to KK :? . ...... Frankly, ...... I dont know. Honestly, I never think of doing business since young. I just like to play this and that, have fun, not aiming to earn people's money. Tell you but you may not believe, I dont feel good when I win people's money during CNY :p , as a result, I always loss what I won, and a bit more from my pockets at the end.

I started reading The Google Story recently. Staffs are inline-roller-blading, cycling in their campus. Staffs are playing hockey, volley ball, ...... Staffs are no more than 100 feet from food. Staffs have 3 free meals a day. ...... One of their staff said, he is not use to eating outside anymore, that he has to PAY, in order to get food. :p ...... Yet they are earning billions dollars. If Yahoo!, AltaVista, ...... realized their potential early, they would have licensed the technology early. ...... :o Even the giants at that time missed the bonanza and get even richer.

It's interesting to see they initially just concentrated much on solving searching problem. Once they devised the ways to do it well, opened it for public try, they were getting popular even without doing advertisements :o . Their search engine became the default search engine for many Stanford professors, students ...... and now they diversify their work into many areas.

I dont know how much potential I have, or rather, do I have any potential at all. I shall not be greedy and think too much on how to earn people's money. I think I should just concentrate on solving problems, contribute to the society. Once we are able to do something extremely well, 'gold mine' will be following on the way by itself. I should spend more time innovating than spending time to think what makes money, what doesnt. :p Remember, even the BIG BOSS missed the bonanza.

OT at Saturday

Posted in

Saturday was a busy day eventhough it is weekend. I went back to company for the company event "HPCQuest: High Performance Computing Quest." Company organized the event for Junior College students to take part in the competition. What a busy day. Early in the morning, there a system down, the system couldnt boot up. .... aiiyak, not me who setup the system, I really dont know what's the problems.... job submitted but no return? **** tak tau! ... how come a simple program also cannot run? Segmentation fault. ***** tak tau! ... how come my plot doesnt give the contour you showed in the presentation slide? ****** tak tau! ...... What are the formulae for ah? :o (how come you never study physics 1 leh). ...... When will my submitted job being run ah? ****** tak tau, there are two more jobs before you! ...... how come cannot compile one ah? **** haiiya, use the C++ compiler lah, you are writing C++ program. ......

What a crappy day, being bombasted by a bunch of problems and questions. .... finally the event was done. After discussing with the judges, I quickly get off the company. waaah, it's 6:45pm++ already.

When I reached home, I real real tire. Sleep early, probably the earliest time I sleep few the last few months.

Professor of the Day - Day II

Posted in

MSN Nickname of the Day: "Professor of the Day -- Day II"

Today is not better than any other day, a sleepy day. Yesterday slept at 2:00am, luckily my handphone with flattening battery still managed to wake me up on time at 7:20am. Within two hours after I woke up, it was no more than basic routine work. On the way to my office, I was sleeping in the MRT perpendicular to the floor. Each time the train stopped at one station, there were just more people getting in, nobody getting out of the train. ("eii aunty, please dont get closer to me anymore, I have no space to step backwards :(. I can smell your hair with unknown shampoo branded X :?.") Luckily these didnt happen earlier. Some time earlier, the MRT operator kept announcing, "This train will be delayed due to the train fault, we apologize for causing any inconvenient." (Ops, train fault again? Which train is faulty? Hope it's another train, I dont want to get stucked in the sky. :o) Ha, probably the train fault (not the train I was in) caused large number of aunties uncles accumulated in the stations joined my train. "Clementi~~~, Clementi~~~", ah ha, time to get off. ("Aunty, please give way") I quickly got out of the train. Standing behind someone for so long, I could only remember she was not thin at all, not tall at all, with smelly hair, but I just couldnt remember the color of the shirt she weared. Ah ha, probably I had no eye to look in front.

Hmmm...I was late 8:50am to reach my office. ("Well, who cares, no one in the training room yet.") Today was a tough day. I was doing one-man-show at both morning and afternoon sessions. In a gloomy day, with moderate horse power aircon, and with my monotone signals, it was hard for the audiences not to fall asleep. I guessed so. Well, this looked familiar, my Chinese lessons during my high school time by Lao Lee!!! (Ha, time flies, as long as you have enough material to read off from the screen. Repeat some key points for many times. Ah ha, that's it. Yet another morning session has passed.) Today I have only 4 males vs 2 females attendees. The missing lady had to meet her supervisor today. Ok, but she didnt come in the afternoon either. Suppose she was not meeting her supervisor whole day wa. But, nvm. ..........

In the afternoon, it was a more relax session. With short lecture, then let them adventure with the type-run-seewhat-think hands-on exercise that I had prepared. Most of the time, they could only type-run-seewhat-ask. Haha, they even fell into the traps of the pre-written program codes. They applied the techniques discussed in the lecture blindly to the pre-written codes :?, and ran the programs, hoped to get the correct results. Hahahaha, suddenly I felt satisfied with the hands-on exercise I had prepared, simple yet they couldnt get it right at the first time. More importantly, they learned the lessons. They may blame the system today for being noisy and unstable. The system would anytime DutDutDutDutDut, and display 'Kernel .... Syslogd .... cr0 .... cr1 .... ', then the java program just hang without good reasons. You cant close the windows, the only way is to find out the process ID using 'top', and issue the command 'kill -9 processID'. It was just frustrating when these happened. Well, everyone was still quite patient with this situation. The session ended automatically at 4:45pm.

The end of the Second Day of the Processor of the Day.

Syndicate content