how to measure power consumed by algorithms
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: how to measure power consumed by algorithms

  1. #1
    Join Date
    Sep 2009
    Location
    Pune, India
    Posts
    14

    how to measure power consumed by algorithms

    i've to make a program in c/c++ through which we can find out the power consumed by any algorithm(basically a c/c++ program).... here we are assuming we know the specific processor we are working on....can u please tell me the functions or commands that can be used to do so and the logic behind it.... if there's any paper or website where info of this sort is available please let me kno...if theres no way to measure power consumption for any generic processor then we can take intel pentium 4 as the processor on which we have to measure the power consumed..

  2. #2
    Join Date
    Nov 2007
    Location
    Birmingham, England
    Posts
    157

    Re: how to measure power consumed by algorithms

    I'm not certain how possible it is to predict the CPU time without actually running it on the processor. If running it, then asking windows how long it took is sufficient then there's a functiona available then look into the windows api function:
    GetThreadTimes

    If you need to be able to predict it and you have a lot of development time available then you could possibly look up the processor timings in the intel manuals for each processor instruction. If you are considdering this then then be sure that you're not going to be stopped by the Halting problem before you start development.

    Hope this is of some help
    Signature
    Please use: [ code ][/ code ] tags and reasonably correct tabbing. They really help us read your code
    End Signature

  3. #3
    Join Date
    Sep 2009
    Location
    Pune, India
    Posts
    14

    Re: how to measure power consumed by algorithms

    thanks for replying..... I will actually run the program on the processor to determine the power consumption..... Assuming if I know the number of cpu clock ticks that were taken to execute the program... How will we proceed further to determine the power consumed...

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,091

    Re: how to measure power consumed by algorithms

    Quote Originally Posted by shivamskn View Post
    thanks for replying..... I will actually run the program on the processor to determine the power consumption..... Assuming if I know the number of cpu clock ticks that were taken to execute the program... How will we proceed further to determine the power consumed...
    I don't believe algorithms consume power. The cpu is running whether you're giving it anything to do. Moving disc heads around would consume more electricity than when the disc is idle, but to the best of my knowledge, cpu power consumption would be constant.

    Why is that a concern anyway?

  5. #5
    Join Date
    Sep 2009
    Location
    Pune, India
    Posts
    14

    Re: how to measure power consumed by algorithms

    my college project requires me to do so..... I've to basically run an algorithm on a computer using c/c++ and then the same algorithm is to be executed using an fpga and then I've have to compare the amount of power consumption using the 2 methods and determine which was better... As per me there will be some power consumption dependent on the amount of resources of the processor utilised

  6. #6
    Join Date
    Nov 2007
    Location
    Birmingham, England
    Posts
    157

    Re: how to measure power consumed by algorithms

    Thats going to be dificult.

    My best guess would be to see if you can determine the power usage of the PC per second then just multiply the CPU time of the process by the power usage of your computer.

    Beyond that its very hard to define because even when your process isnt running then your OS will be sitting there in a loop saying
    have I got anything else to do yet? ... no...
    have I got anything else to do yet? ... no...

    and unless this part of the OS knows how to throttle down your CPU then it will take about as much power as your algorithm.
    Signature
    Please use: [ code ][/ code ] tags and reasonably correct tabbing. They really help us read your code
    End Signature

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: how to measure power consumed by algorithms

    Most OSes are interrupt-driven these days; but yeah, there's always going to be *some* power consumption even when the processor isn't doing anything.

    Typically power problems are addressed by finding a processor which uses little enough power, and then figuring out how to write code that will work with its limitations.

  8. #8
    Join Date
    May 2007
    Posts
    800

    Re: how to measure power consumed by algorithms

    Quote Originally Posted by shivamskn View Post
    my college project requires me to do so..... I've to basically run an algorithm on a computer using c/c++ and then the same algorithm is to be executed using an fpga and then I've have to compare the amount of power consumption using the 2 methods and determine which was better... As per me there will be some power consumption dependent on the amount of resources of the processor utilised
    Are you sure that it's not asking about big(O) notation?

  9. #9
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: how to measure power consumed by algorithms

    No, given that he mentioned an FPGA, I don't think that's a misinterpretation. It probably is an actual power issue.

  10. #10
    Join Date
    Aug 2005
    Location
    San Diego, CA
    Posts
    1,054

    Re: how to measure power consumed by algorithms

    Yeah, I too was wondering whether the word "power" was being misused in the title. Are we really talking about measuring electrical power as in "watts" or is this about CPU utilization?

  11. #11
    Join Date
    Sep 2009
    Location
    Pune, India
    Posts
    14

    Re: how to measure power consumed by algorithms

    nah we are actually talking abt power consumed.... the project has got something to do with adaptive systems.... does any1 of u kno wat is the per cycle power consumption of a p4 processor without ht technology....

  12. #12
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,013

    Re: how to measure power consumed by algorithms

    Quote Originally Posted by shivamskn View Post
    nah we are actually talking abt power consumed.... the project has got something to do with adaptive systems.... does any1 of u kno wat is the per cycle power consumption of a p4 processor without ht technology....
    You can find long lists of power consumption on the Intel website, but AFAIK those are fairly theoretical values - typically idle and maximum power consumption. I don't think you'll get any sensible values about power consumption without actually measuring power consumption.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center