Results 1 to 17 of 17

Thread: does a Qt application run faster on a windows 64 bit machine?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Location
    US, Washington State
    Posts
    54
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: does a Qt application run faster on a windows 64 bit maschine?

    In the code you have these macros defined
    Qt Code:
    1. #define Drc Data[r][c]
    2. #define DrcOutlet Data[r_outlet][c_outlet]
    3. #define MV(r,c) IS_MV_REAL4(&Mask->Data[r][c])
    4. #define FOR_ROW_COL_MV for (int r = 0; r < nrRows; r++)\
    5. for (int c = 0; c < nrCols; c++)\
    6. if(!IS_MV_REAL4(&Mask->Data[r][c]))
    7.  
    8. #define FOR_ROW_COL_MV_CH for (int r = 0; r < nrRows; r++)\
    9. for (int c = 0; c < nrCols; c++)\
    10. if(!IS_MV_REAL4(& ChannelMask->Data[r][c]))
    To copy to clipboard, switch view to plain text mode 
    Normally, not a big fan of macros, but in this circumstance they work well.

    With the exception of any code that relies on variables r and c directly (looked like only a few), the macros can be changed and loops simplified (flattened). How much of a speed up is unknown. I'd change a few functions and benchmark to see if the effort is worth it.

    Qt Code:
    1. // return the row and col index, computed from input idx and nCols
    2. void RowColFromIndex(int & row, int & col, int idx, int nCols)
    3. {
    4. row = idx / nCols;
    5. col = idx % nCols;
    6. }
    7.  
    8. // return the flat index computed from inputs row, col, nCols
    9. int IndexFromRowCol(int row, int col, int nCols)
    10. {
    11. return row * nCols + col;
    12. }
    13.  
    14. #define DrcIdx Data[rIdx][cIdx]
    15. #define FOR_ROW_COL_MV for (int idx = 0; idx < nrRows * nrCols; ++idx)\
    16. int rIdx, cIdx; \
    17. RowColFromIndex(rIdx, cIdx, idx, nrCols); \
    18. if(!IS_MV_REAL4(&Mask->Data[rIdx][cIdx]))
    19.  
    20. #define FOR_ROW_COL_MV_CH for (int idx = 0; idx < nrRows * nrCols; ++idx)\
    21. int rIdx, cIdx; \
    22. RowColFromIndex(rIdx, cIdx, idx, nrCols); \
    23. if(!IS_MV_REAL4(& ChannelMask->Data[rIdx][cIdx]))
    To copy to clipboard, switch view to plain text mode 
    So, basically anywhere variable r and c are used need to be changed to rIdx and cIdx (using rIdx and cIdx helps find errors while porting).

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: does a Qt application run faster on a windows 64 bit maschine?

    All those loops can be easy paralellized. These that don't depend on the order of calculations can be done with QtConcurrent or with a simple OpenCL kernel. Those that depend on the order of execution are a bit more tricky but I'm sure they can be sped up as well. If you use OpenCL you can get a speed-up in the magnitude of 10-50x. With QtConcurrent the speed-up depends on the number of cpu cores (so it's probably around 2-4x max). There is also a possibility to use SIMD optimizations available in your CPU such as SSE.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Location
    US, Washington State
    Posts
    54
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: does a Qt application run faster on a windows 64 bit maschine?

    Quote Originally Posted by wysota View Post
    All those loops can be easy paralellized. These that don't depend on the order of calculations can be done with QtConcurrent or with a simple OpenCL kernel. Those that depend on the order of execution are a bit more tricky but I'm sure they can be sped up as well. If you use OpenCL you can get a speed-up in the magnitude of 10-50x. With QtConcurrent the speed-up depends on the number of cpu cores (so it's probably around 2-4x max). There is also a possibility to use SIMD optimizations available in your CPU such as SSE.
    While technically true, there is no free lunch. "easy paralellized" "simple OpenCl kernel", again are dependent an the OP's capabilities and understanding of parallel programming issues.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: does a Qt application run faster on a windows 64 bit maschine?

    Quote Originally Posted by pkohut View Post
    While technically true, there is no free lunch. "easy paralellized" "simple OpenCl kernel", again are dependent an the OP's capabilities and understanding of parallel programming issues.
    It's not that bad. If you have a for loop such as the following:
    Qt Code:
    1. for(int r = 0; r < rows; ++r) {
    2. for(int c = 0; c < cols; ++c) {
    3. doSomething(r,c);
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 
    Can be rewritten as
    Qt Code:
    1. QFutureSynchronizer<void> waiter;
    2. for(int r = 0; r < rows; ++r) {
    3. for(int c = 0; c < cols; ++c) {
    4. waiter.addFuture(QtConcurrent::run(doSomething, r, c));
    5. }
    6. }
    7. waiter.waitForFinished(); // or do something else in the meantime
    To copy to clipboard, switch view to plain text mode 

    This doesn't require any skills and provided that doSomething() does more than just add two ints together, you will get a decent speed improvement on a multicore system. Of course there is a good chance the loop can be substituted with a flat call to QtConcurrent::mappedReduced(). OpenCL is more tricky although I see the OP's calculations are mostly simple vector operations (additions and multiplications) so the code doesn't need many changes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2009
    Posts
    92
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: does a Qt application run faster on a windows 64 bit maschine?

    thanks for the help and suggestions guys, I really apreciate it.

Similar Threads

  1. Replies: 7
    Last Post: 29th January 2009, 19:47
  2. Deploying application on Linux machine without Qt
    By will49 in forum Installation and Deployment
    Replies: 2
    Last Post: 10th July 2008, 22:41
  3. Replies: 8
    Last Post: 9th May 2008, 16:54
  4. Qt 4.3.0 on Windows in a Virtual Machine
    By Tux-Slack in forum Installation and Deployment
    Replies: 2
    Last Post: 12th July 2007, 22:52
  5. Porting my program to another windows machine !
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2007, 06:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.