# Beginner: how to optimize my code with mmx/sse

## Beginner: how to optimize my code with mmx/sse

Dear all,

I have just download the evaluation copy of Intel C++ Compiler to see ifmmx/sse could be used to optimized my code in my work.

I am quite new to this area. I would appreciate if anyone can
help or direct me to the correct newsgroup/discussion boards.

THis is what I want to do
===========================
ln 1 : define typedef rect{
ln 2 : int* p0;
ln 3 : int* p1;
ln 4 : int* p2;
ln 5 : int* p3; //four corner of a rectangle
ln 6 : }
ln 7 :
ln 8 : void myFunction(){
ln 9 :
ln10 : int* image = new int[width*height];
ln11 : ... //read image data
ln12 :
ln13 : rect rectList[noOfRects];
ln14 :
ln15 : ... //initialise rectList
ln16 : //for (all i in noOfRects) {
ln17 : // rectList[i].p0=&image[ x1_i + y1_i*width];
ln18 : // rectList[i].p1=&image[ x2_i + y1_i*width];
ln19 : // rectList[i].p2=&image[ x1_i + y2_i*width];
ln20 : // rectList[i].p3=&image[ x2_i + y2_i*width];
ln21 : // }
ln22 : //
ln23 : // (x1_i,y1_i) and (x2_i,y2_i) are the coordinates of the
ln24 : // upper-left and lower-right coordinates of the i-th rectangle in the image
ln25 :
ln26 : //Now i want to shift the rectangles ...
ln27 ://for (all (x,y) in image) {
ln28 : offset = x + y*width;
ln29 : float sumOfPixelsInAllRecs=0.0F;
ln30 : // for (all i in noOfRects) {
ln31 : sumOfPixelsInOneRec=rectList[i].p0[offset] - rectList[i].p1[offset] - rectList[i].p2[offset] + rectList[i].p3[offset];
ln32 : sumOfPixelsInAllRecs+=sumOfPixelsInOneRec;
ln33 : }
ln34 : }
ln35 :
ln36 : }

Questions
=========
1) I think the code from ln26 to ln34 can be optimized. I want to get the results for sumOfPixelsInAllRecs fast.

THank you and have a good day!

With Best Regards
HENG CHER KENG

Message Edited by hengck23 on 07-17-200412:31 AM

Message Edited by hengck23 on 07-17-2004 12:31 AM

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.