4 Replies Latest reply on Jul 15, 2016 2:50 PM by xbolshe

    HOW MANY MIPS CAN GALILEO DO?

    JMVM

      Hi,

       

      I know Intel Galileo Boards (Gen1 and Gen2) run at speed of 400 MHz.

       

      I uploaded this code with Arduino IDE to my Galileo Board.

       

      ______________________________________________________________

      //variables

      long i,j,k;

      unsigned long num1=0;

       

       

      void setup() {

        // put your setup code here, to run once:

        Serial.begin(115200);

        delay(5000);

        pinMode(13,OUTPUT);

        Serial.println("Hello!");

        for (i=0;i<20;i++)

        {

          digitalWrite(13,LOW);

          delay(100);

          digitalWrite(13,HIGH);

          delay(100);

        }

        ////

        Serial.println("Start!");

        digitalWrite(13,LOW);

       

       

        ///

        for (i=0;i<3730;i++)

        {

          for (j=0;j<1050;j++)

          {

            for(k=0;k<1080;k++)

            {

              num1=num1+1;

            }

          }

        }

       

       

        digitalWrite(13,HIGH);

        Serial.println("End");

        Serial.println(num1);

      }

       

       

      void loop() {

        // put your main code here, to run repeatedly:

        digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)

        delay(1000);              // wait for a second

        digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

        delay(1000);              // wait for a second

      }

       

      ___________________________________________________________________

      The code does this:

      1-Begins Serial Communication and waits for 5 seconds.

      2-Blinks the LED with a frequency of 10Hz for 2 seconds and then turns it off. (this tells you when is going to start)

      3-Makes lots of operations.

      4-Tells you when has finished.

      5-And finally, blinks a LED again.

       

       

      You could try it, it is going to take only 1 second to do those operations.

      It does 3 730*1 050*1 080=4 229 820 000 operations in long format. (The result is able to be save in an unsigned long variable  C Data Types  ).

      So it means the Galileo Board does approximately 4 230 MIPS.

       

      RESULT.jpg

       

      How can it be possible if Galileo Board use an Intel® Quark™ SoC X1000 at speed of 400 MHz?

       

      It is amazing!

       

      Thank you.

        • 1. Re: HOW MANY MIPS CAN GALILEO DO?
          FGT

          Hi JMVM,

           

          I think there is something odd/strange... how are you measuring time?

           

          Fernando.

          • 2. Re: HOW MANY MIPS CAN GALILEO DO?
            JMVM

            Hi FGT.

             

            I invite you to upload the code to the Galileo Board, you can look it by yourself, it is going to take approximately a second.

            I measured the time looking from the moment the LED turns off (after blinking twenty times) until it turns on again.

            If you read the code, between those lines (the off and on of the LED) the Galileo Board does those operations. So, this gives me an aproximate time for the Galileo to do the operations.

             

            JMVM.

            • 3. Re: HOW MANY MIPS CAN GALILEO DO?
              FGT

              JMVM wrote:

               

              Hi FGT.

               

              I invite you to upload the code to the Galileo Board, you can look it by yourself, it is going to take approximately a second.

              I measured the time looking from the moment the LED turns off (after blinking twenty times) until it turns on again.

              If you read the code, between those lines (the off and on of the LED) the Galileo Board does those operations. So, this gives me an aproximate time for the Galileo to do the operations.

               

              JMVM.

               

              I see... Actually, I used the following "method" which I think shows there is something odd/strange or, at least, something I do not have an explanation for...

               

              //variables

              unsigned long i,j,k;

              unsigned long num1=0;

               

              void setup() {

                long int time1, eltime;

               

                // put your setup code here, to run once:

                Serial.begin(115200);

                delay(3000);

                pinMode(13,OUTPUT);

                Serial.println("Hello!");

               

                ////

                Serial.println("Start!");

                digitalWrite(13,LOW);

               

                time1 = millis();

                ///

                for (i=0;i<1000;i++)

                {

                  for (j=0;j<1000;j++)

                  {

                    for(k=0;k<1000;k++)

                    {

                      num1=num1+1;

                    }

                  }

                }

                eltime = millis() - time1;

               

                digitalWrite(13,HIGH);

                Serial.print("End (ms): ");

                Serial.println(eltime);

                Serial.println(num1);

              }

               

              void loop() {

                // put your main code here, to run repeatedly:

                digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)

                delay(1000);              // wait for a second

                digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW

                delay(1000);              // wait for a second

              }

               

              And the output:

              Hello!

              Start!

              End (ms): 22

              1000000000

               

              i.e. 22 ms for 10^9 instructions... which, unless my math is failing, determines more than 45000 MIPS and this is what I think is really odd in (Intel® Galileo Gen 2 Development Board—Empower Your Prototype):

              "

              Intel® Quark™ SoC X1000 application processor, a 32-bit, single-core, single-thread, Intel® Pentium® processor instruction set architecture (ISA)-compatible, operating at speeds up to 400 MHz.

              "

              since it would imply more than 100 instructions per cycle... and that is odd. I'm pretty sure I'm missing and/or misunderstanding something (or a loooot of things, actually). And I'm not taking into account instructions related to i, j, and k...

               

              I do not see my mistake...

               

              Fernando.

              • 4. Re: HOW MANY MIPS CAN GALILEO DO?
                xbolshe

                Hi,

                 

                here is my result and code:

                mips.png

                 

                //variables
                unsigned long i,j,k;
                unsigned long num1=0;
                long long start, finish;
                
                long long rdtsc(){
                    unsigned int a=0, d=0;
                    __asm __volatile("rdtsc" : "=a"(a), "=d"(d) );
                    return ((long long)a) | (((long long)d) << 32);
                }
                
                void setup() {
                  long int time1, eltime;
                
                // put your setup code here, to run once:
                  Serial.begin(115200);
                  delay(3000);
                  pinMode(13,OUTPUT);
                  Serial.println("Hello!");
                
                  ////
                  Serial.println("Start!");
                  digitalWrite(13,LOW);
                  time1 = millis();
                  start = rdtsc();
                  ///
                  for (i=0;i<1000;i++)
                  {
                    for (j=0;j<1000;j++)
                    {
                      for(k=0;k<1000;k++)
                      {
                        num1=num1+1;
                      }
                    }
                  }
                  finish = rdtsc();
                  eltime = millis() - time1;
                
                  digitalWrite(13,HIGH);
                  Serial.print("Time for code execution (ms): ");
                  Serial.println(eltime);
                  Serial.println(num1);
                  Serial.print("Total cycles for code execution: ");
                  num1=(finish-start);
                  Serial.println(num1);
                  Serial.print("Start,Finish : ");
                  num1=start;
                  Serial.print(num1);
                  Serial.print(",");
                  num1=finish;
                  Serial.println(num1);
                  Serial.print("Calculated MIPS: ");
                  num1=(finish-start)/(eltime*1000);
                  Serial.println(num1);
                }
                
                void loop() {
                  // put your main code here, to run repeatedly:
                  digitalWrite(13, HIGH);  // turn the LED on (HIGH is the voltage level)
                  delay(1000);              // wait for a second
                  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
                  delay(1000);              // wait for a second
                }
                

                 

                "The mistake" is in a result of compilation.

                I have disassembed my compiled sketch and translated to a close high level code:

                 

                  for (i=0;i<1000;i++)
                  {
                    for (j=0;j<1000;j++)
                    {
                        k=1000;
                    }
                    num1=num1+1000000;
                  }
                

                 

                The real code execution takes some more than 10^6 instructions.

                The picture above shows about 8*10^6. It is a difference between assembler and C instructions for this sketch.

                 

                So, GCC compiler used by Arduino IDE makes miracles

                 

                BR,

                xbolshe

                1 of 1 people found this helpful