Friday, February 28, 2014

Translating Traditional Program Logic to OpenCL

If you just started to look at OpenCL and see the example of the code, it can be quite confusing on how it got that way from its traditional program logic counterpart. Take a look at an example of comparison below taken from PDF Overview on OpenCL site :

You can see that the calculation is intact but you can't seem to find where the for loop counterpart is.

It is because, the logic has been separated between host (your main program) and kernel (that will be sent to device). So, you need to look at both of them to get the whole picture. There is some data partitioning done that you can take a look at the code at the host. Together with the batch processing happen in kernel code you can start to see the implied loop there.






Due to its parallelism and batch processing nature, the logic in OpenCL can look more declarative and more separated compare to traditional one. So, the logic that you expect to find will probably be implied somewhere in host and kernel code. This could help if you try to read the existing code.

Thursday, February 27, 2014

Getting Started with OpenCL

I started working with OpenCL recently on the project at work. It's quite exhausting to learn initially since OpenCL has quite steep learning curve. However, once you have started to picked up some of the core concept, it could be quite interesting. Also, you will add another valuable tool to your programming arsenal, especially in the aspect of performance and speedup. You will start to be able to exploit not just CPU but also any other computing device that exist on the system like GPU quite conveniently.

Here's summary and pointers of how to get started with it from what I note so far.

Overview

You can get an initial overview from the surces below :

 As for its Wikipedia Page, I don't find it really informative at the moment, at least if you want to get an overview of what OpenCL is and its relevance.

As usual, google search and some blog entries would not hurt too. However, it's better not to take too much time researching things online since I think your time is better spend reading the book below.

Book : OpenCL in Action

There is not many technical book that you can enjoy reading cover to cover. This one is one of them. It's better you read from beginning to end serially. It build up from chapter to chapter. Also, it does not cross reference things too much between materials which could be annoying on some technical books. The materials coverage is very good, from the history, introduction to advanced topics.

If you have some questions on your mind from reading other sources previously, there is a good chance that you will start to piece things together when reading this book. It gives a good foundation for understanding why OpenCL is the way it is. OpenCL syntax and functions will still be quite overwhelming even after you finished with the book but knowing the concept behind will make it much more manageable.

I find the highlights of the book is its use of analogies that helps a lot in explaining the abstract concept and architecture of OpenCL.

Revisit Specification and Reference Card

If you have skimmed the specification and reference card above, it's time to revisit it again. You will now find it much more clearer now and they are starting to be more useful. It will also add more details from what is covered on the book. Personally, I really like the layout on reference card which help in getting a good high level picture of different parts of OpenCL with it's colorful boxes and groupings.

At this point, you can start to work on your specific issues and continue learning from there. As usual, after the initial learning, the actual work is where we will learn most. This is especially true in complex technology like OpenCL.

Thursday, February 20, 2014

Migrating to Android from iPhone

My iPhone4 got the "people can't hear me" problem. I've exhausted all the possible trick to solve it that does not require opening up the hardware. There is little-used s3-mini laying around so I decided to try to migrate to it and see what happen.

I expected some limitations when moving to Android from iOS since I have been accumulating many apps and it has quite integrated to my daily workflow. However, after sometime, I can say that the migration is quite seamless. Most of my usage can be transferred to Android plus some more Android-specific goodies (I think widget is cool). More about this below.

The Apps

At this point, almost all the well-known apps have both iOS and Android version. So, for apps like Evernote, Springpad, Pocket, Feedly etc. I don't have any problem at all. There is slight differences here and there but for my personal usage there is nothing significant that I find missing.

For less well-known apps I usually can find the comparable counterpart. I have to say though, the apps on iOS feels more "elegant" somehow. However, if you care mostly for the function, it's quite negligible since Android now has large number of well-written apps.

Surprising Finding on Navigation Apps Department

I have Garmin Indonesia on my iPhone and it is sad to see that there is none of it on Google Play Store. I have searched for the alternatives on several occasion with no luck until I stumble upon Polnav EasyDriving app. It's quite "hidden" from my previous search, probably because it's google playstore page uses non-latin characters mostly.

Surprisingly, it works really well. I used Indonesian map from navigasi.net (which is a really great crowdsourced map, BTW) and it is loaded very nicely. The navigation screen is clear, fluidly updated and give me several notification when getting close to turn to make sure I don't get past it. Really cool!. And what is even more surprising is that is free which is quite unusual for offline gps navigation app nowadays.

The search for address is really good but somehow there is no POI-based search that I can find. This is quite unfortunate and hopefully it will be there on future versions. Aside from that, I have no complain for it.

What is Missing

One thing that I miss quite a lot is a good freeplane-compatible mindmapping app. There is iThoughts in iOS but none that comparable to it on Android. Fortunately, I have been "flattening" my data recently and many has been migrated as Evernote or Springpad data. Some of it are still on freeplane format though and for those I still have iThougts on iPad. So it's not really a critical issue actually but it will be nice if I can still accessing my mindmaps on the smartphone too.

My iPhone4 is not going to retire soon though, I still have it laying around and use the apps on it occasionally. It basically now function more as and iPod than an iPhone. For example, I still use Garmin on it although I already have Polnav on Android as mentioned above. It is still useful to use GPS on separate device on some circumstances.

So far I quite enjoy the migration and I can't say it's better or worse. It just different, I guess.

Tuesday, February 04, 2014

Import Existing Repository to Bitbucket using TortoiseGit

When you want to import an existing local Git repository to bitbucket you can follow this official guide. However, one of the section involving steps with git command line as below :


I am used to using TortoiseGit on Windows and rely on it for all my Git command needs. So, I find it unpleasant to go to the shell to just do all the above. It feels like a leaky abstraction happening. I am sure there is more convenient way to do it using TortoiseGit instead. So, below  are the above steps done using TortoiseGit :
  • Right click on the folder->TortoiseGit -> Settings
  • Git->Remote and enter remote origin value as pictured below
 
  •  Right click on the folder->TortoiseGit ->Push
It looks more wordy but it is actually more pleasant to do in GUI-based environment.