Wednesday, November 2, 2011

Macbook Air 11" vs Samsung Series 7 Slate

I surfed websites but it is not easy to find a page which compares MBA 11" and Series 7 in a chart.

So I've just made it.


Samsung Series 7 Slate Macbook Air 11” Macbook Air 13” CTO
Size 184 x 296.1 x 12.9 192 x 300 x 17 227 x 325 x 17
Screen resolution 1366 x 768 1366 x 768 1440 x 900
weight 2.14 (0.97kg) 2.38 (1.08kg) 2.96 (1.35kg)
CPU Core i5 Core i5 Core i7
Storage 64G SSD 128G SSD 256G SSD
Memory 4G 4G 4G

The size and the weight of Samsung Series 7 Slate are without keyboard. It doesn't have a attached keyboard but has a bluetooth wireless keyboard and a touch screen with a pen.

Monday, July 25, 2011

C++ 0x on Mac

Introduction
I was trying to convert my MSVC project into Qt Project so that it may compiled both on Windows and on Mac. But the problem is I used some of C++ 0x features in the project such as auto keyword, r-value reference and move constructor. Because my Qt on Windows uses MSVC 2010 compiler, there was no problem compiling it but the problem was on Mac which doesn't have C++ 0x feature yet.

What is special on Mac?
gcc 4.4 or later versions support C++ 0x standard but the version of gcc included in XCode 4.0 is still 4.2. Because I didn't have an excellent Mac specific knowledge, was thinking that it would be very easy to upgrade gcc into 4.4 or higher so that I may use C++ 0x standard on Mac. But it was not! The gcc compiler provided with XCode is not a normal gcc compiler but a special version which has been modified by Apple. Here I introduce how to use C++ 0x features with Qt Creator. May be I can try it also on XCode but I gave up because got a very dangerous feeling about switching XCode's default compiler.

Installation of gcc4.5
First, I installed gcc4.5 on my Mac by using of fink command 'fink install gcc45'. The command is very simple but the installation process took about 5 hours! Please note that if you are about to install a new version of gcc compiler via fink command on Friday afternoon and you got an date that night, you should give up one of beween date and gcc installation.

Qt Configuration
Now, launch your Qt Creator to modify the setting so that you may use gcc 4.5 compiler on your Qt Creator.
1. add gcc 4.5 into Tool Chains

Open preference window then choose Tool Chains on the tab on the left side of the preference window.
Click "add" button and choose "GCC" on the popup menu. Rename it into a new name such as "GCC4.5" to avoid confusing between other GCC compilers by double clicking the name.
Then set the compiler path , debugger, and ABI values. The gcc4.5 binary is usually located in /sw/bin/ and  its name is g++-4 or G++-4.5.
2. Create qmakespec for gcc4.x
There are differences between Apple's gcc compiler and gnu version of gcc compiler. Among these differences, in this time, -arch and -Xarch flag are the things to be cared. Qt's qmake predefined specification data is using -arch and Xarch flag to specify architecture values such as intel 32bit, intel 64bit, PPC 32bit, and PPC 64bit. We should make it work with our gcc compiler by switching these flags into -m32 or -m64.
Here is an example.
Go to your mkspecs directory of Qt. You can find out the location by checking Qt4 tab on Preferences.

Then make a copy of macx-g++ with a new name such as macx-gnu-g++. When you open qmake.conf file, you can see a line like below at the end of file.
include(../common/mac-g++.conf)
Most of environment values for qmakeconfig are stored in the file, ../common/mac-g++.conf. Let's change it into a new file name such as ../common/mac-gnu-g++.conf.
Go to common directory then copy mac-g++.conf file with a new name mac-gnu-g++.conf.

QMAKE_CFLAGS_X86_64     += -m64 -mmacosx-version-min=10.5
QMAKE_OBJECTIVE_CFLAGS_X86_64  += -m64 -mmacosx-version-min=10.5
....
QMAKE_CXXFLAGS_X86_64   += -m64  -mmacosx-version-min=10.5
QMAKE_CXXFLAGS_X86      += -m32

QMAKE_CC         = gcc-4
QMAKE_CXX        = g++-4

3. Modify Build Setting
Now, almost done! Select "Projects" tab on left side of the Qt Creator, then you will see "Build Settings". Go to the second section, "Build Steps" then put the value "-spec mac-gnu-g++" into "Additional Arguments".

Finished!
In my case, I can compile most of Qt projects by doing above things. But depending on the projects, especially depended libraries, there could be some more things to do.
Thank you.

Sunday, July 24, 2011

Why we are making software?

About six years ago, my company launched a video chat software which had excellent performance but was not so popular at the beginning. Just right after releasing the first version, I was visiting the users feedback pages every day and identifying what kind of problem my software had. Most of the feedbacks were dissatisfactions because most of users had never used video chatting software before and didn't know how to use their web cams and adjust their microphones. One day, I found an unusual title, "Thank you." I opened the post with curious and thrill. The author of the poster was a handicap in his eyes. His vision was very poor and should approach his head to the monitor within 2 or 3 inches space to read the text on the screen. According to the posting, he has a very young son who lives very far from him because of his work. He wanted to see his son but it was very difficult. When the video chat software was released, he decided to use it to see the face of his son. Even though he needed to stick his head into the monitor to see his son, he was very happy whenever he saw his son. So he decided to leave a message on the feedback board that he was using this software very usefully and if the video window is bigger, he will be happier because he can see the face of his son more clearly. While reading the post, I was very impressed and reconsidered the meaning of what I'm doing.


After then, I decided that I should put the full-screen video chat function into the program and suggested it to my UX and planning team. They agreed about the requirement and I volunteered to make the function. When the full screen function was released, I notified him about it and he sent me a thank you mail. 
It was one of my impressive things among my entire software development life.


We are developing softwares and it is sometimes very successful but sometimes it is not. But beyond the success of our projects, we should know that we are making software to help our neighbors. 

Friday, July 22, 2011

C++ books

Introduction
There are many C++ related books in bookstores but it is not so easy to find a book for mid-senior C++ programmers. Usual C++ books are for the beginners and with the title like "Complete C++ in 45 days". I am interviewing many candidates for C++ development engineer positions at my company who, of course, mentioned C++ on their resumes. But most of them are not really good at C++ programming and cannot explain how virtual destructor works, why we should worry about "self assignment", differences of const keywords by their positions.
I introduce some good C++ books here and I have no relationship with these authors. (But I'm translating some parts of C++ FAQ web version into Korean)

Effective C++, More Effective C++, and Effective STL
Effective Series are very famous books for who are want to know more about C++ and how to use it more effectively. I use to read these effective books these days even though I used C++ more than 10 years now.









C++ FAQs


Even though Effective C++ series are very good books but these books are not covering entire thins. You can find more about C++ that you are usually curious while using C++ such as pointers to member functions, why it is not safe to delete the same pointer twice, and etc.
There are two versions of C++ FAQs. One is named C++ FAQs lite and you can read it via web site at http://www.parashift.com/c++-faq-lite/ for free. and the other is book version of C++ FAQ. You can find out the differences between these two version at http://www.parashift.com/c++-faq-lite/faq-book.html.

An Implementation of inter-thread communication between UI thread and Worker threads with WTL

Introduction
The basic concept of this implementation is explained on my previous post.



Implementation
Class Diagram



Event Object
class WtlEventConnector:public CWindowImpl
{
public:
 static WtlEventConnector& GetInstance()
 {
     static WtlEventConnector instance;
  return instance;
 }

 void Initialize()
 {
  if (m_hWnd)
        {
   return;
        }

  HWND hWnd = Create(GetDesktopWindow(), 0, 0, WS_POPUPWINDOW);
  if (!hWnd)
  {
   throw std::runtime_error("WtlEventHandler Window Creation failed");
  }
 }

 bool FireEvent(int nValue, BaseEventHandler* pHandler)
 {
  if (!m_hWnd)
  {
   return false;
  }
  PostMessage(WM_FIRE, nValue, reinterpret_cast(pHandler));
  return true;
 }

 BEGIN_MSG_MAP ( WtlEventHandler )
 MESSAGE_HANDLER ( WM_FIRE, OnFire )
 END_MSG_MAP()

protected:

 LRESULT OnFire(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bHandled)
 {
  WtlEventTrigger* pHandler;
  pHandler = reinterpret_cast(lParam);
  pHandler->onMainThread(wParam);
  bHandled = TRUE;
  return 0L;
 }

private:
 WtlEventConnector()
 {
 }

 ~WtlEventConnector()
 {
  if (m_hWnd)
  {
   DestroyWindow();
  }
 }
};


WtlEventTrigger::WtlEventTrigger()
{
 CPortalNetThreadChangerWTL::GetInstance().Initialize();
}

void WtlEventTrigger::fire(int value) // NS

{
 WtlEventConnector::GetInstance().FireEvent(value, handler);
}

Saturday, July 16, 2011

An Implementation of inter-thread communication between UI thread and Worker threads with Qt

Introduction
The basic concept of this implementation is explained on my previous post.

Architecture

Implementation

Event Object
class QtITCEvent:public QEvent
{
public:
    QtITCEvent(BaseEventHandler& handler, int val)
        :QEvent(IPC_THREAD_EVENT),
        value(val),
        handler(receiver)
    {

    }
    int getValue() // NS
    {
        return value;
    }

    CPortalNetThreadChanger& getHandler() // NS
    {
        return handler;
    }

private:
    int value;
    BaseEventHandler& handler;
};

class QtEventHandler:public QObject, BaseEventHandler
{
public:
    static BaseEventHandler& getInstance() // NS
    {
        static QtEventHandler instance;
        return &instance;
    }

protected:
    virtual bool event ( QEvent * e ) // NS
    {
        if (e->type() == IPC_THREAD_EVENT)
        {
            QtITCEvent* myEvent = dynamic_cast(e);
            if (!myEvent)
            {
                return false;
            }
            myEvent->getHandler().onHandleEvent(myEvent->getValue());
            return true;
        }
        return false;

    }
private:
    QtEventHandler()
    {

    }
    QtEventHandler(QtEventHandler&);
    void operator=(QtEventHandler&);


};

QtEventTrigger::QtEventTrigger()
{
    if (IPC_THREAD_EVENT == QEvent::None)
    {
        IPC_THREAD_EVENT = static_cast(QEvent::registerEventType());
    }
}

QtEventTrigger::~QtEventTrigger()
{

}

void QtEventTrigger::fire(int value) // NS
{
    QtITCEvent * event = new QtITCEvent(this, value);
    QCoreApplication::postEvent(QtEventHandler::getInstance(), event);
}

Tuesday, July 12, 2011

Performance Enhancement with Core Technologies

Introduction
When I was a 10 year old boy, I made a shooting game running on Z-80a processor. It was mostly written in BASIC and little bit in Assembly. I designed all the game scenario, bitmaps pixels for the game characters displayed on the graphic unit, V9938D and sound effects played through the PSG sound device. It was my first programming.

As I remember, the the Z-80a processor had a clock rate 4.77 MHz. Since then the processor speed had incredibly upgraded. In 2002, an Intel Pentium 4 model was introduced as the first CPU with a clock rate of 3 GHz. But recently it seems that the clock rate almost reached to its limit because it is hard to see any CPU faster then 3.5 GHz today even though the highest clock speed microprocessor ever sold commercially to date is found inside IBM's zEnterprise 196 mainframe, introduced in July, 2010. The z196's cores run continuously at 5.2 GHz.

To avoid the limit of the clock rate, CPU manufactories are approaching to SIMD and multi-core technologies and now we even have dual core smart phones.


SIMD extension

Single instruction, multiple data (SIMD), is a class of parallel computers in Flynn's taxonomy. It describes computers with multiple processing elements that perform the same operation on multiple data simultaneously. Thus, such machines exploit data level parallelism. from WikiPedia
Flynn's Taxonomy of a SImD design: single instruction, multiple data. Each "PU" (processing unit) does not necessarily correspond to a processor, just some functional unit that can perform processing. The PU's are indicated as such to show relationship between instructions, data, and the processing of the data.
SIMD extension is a very useful technology when it is applied to multimedia processing. I have done some of multimedia related software development and have experienced the advantage of SIMD extension. You can see an example of my SIMD extension related work here.


Parallel Processing
As I mentioned above, The clock rate has reached almost its limit thus microprocessor manufactures are finding their solution in multi-core technology.
OpenMP is one of famous parallel processing library and Microsoft recently introduced parallel pattens library in Visual Studio 2010. I introduce these two libraries here.

OpenMP
The OpenMP Application Program Interface (API) supports multi-platform shared-memory parallel programming in C/C++ and Fortran on all architectures, including Unix platforms and Windows NT platforms. Jointly defined by a group of major computer hardware and software vendors, OpenMP is a portable, scalable model that gives shared-memory parallel programmers a simple and flexible interface for developing parallel applications for platforms ranging from the desktop to the supercomputer.

int main(int argc, char *argv[])
 {
   #pragma omp parallel  
   printf("Hello, world.\n");
   return 0;
 }

You can see more detail about OpenMP and download it at http://openmp.org/

Microsoft Parallel Patterns Library
The PPL introduces a set of task-oriented parallelism constructs as well as a number of parallel algorithms similar to what is available with OpenMP today. The PPL algorithms are, however, written using C++ templates rather than pragma directives and, as a result, are far more expressive and flexible. The PPL is, however, fundamentally different from OpenMP in the sense that the PPL promotes a set of primitives and algorithms that are more compassable and reusable as a set of patterns. Meanwhile, OpenMP is inherently more declarative and explicit in matters such as scheduling and ultimately is not part of C++ proper. The PPL is also built on top of the Concurrency Runtime, allowing for greater potential interoperability with other libraries based on the same runtime. Let's look at the PPL algorithms and then see how you can use the underlying functionality directly for task-oriented parallelism.


 - writing in progress.... to be finished soon...