Giter VIP home page Giter VIP logo

Comments (9)

ravenrd avatar ravenrd commented on September 2, 2024

Was this issue not finished by your commit on August 1?

from drampower.

Sv3n avatar Sv3n commented on September 2, 2024

Mainly because there are still some residual casts to double, and because the MemCommand class still uses doubles internally to store time (https://github.com/ravenrd/DRAMPower/blob/master/src/MemCommand.cc#L55).

from drampower.

Sv3n avatar Sv3n commented on September 2, 2024

We don't rely on double's anymore to represent time. I propose to remove the getTime() function from MemCommand in favor of the int64_t getTimeInt64() const; function we now use.

https://github.com/ravenrd/DRAMPower/blob/master/src/MemCommand.h#L117

Any objections? If not, then I'll make this change and close the issue in 2 days.

from drampower.

myzinsky avatar myzinsky commented on September 2, 2024

I think that is totally valid. @efzulian, what do you think?

from drampower.

efzulian avatar efzulian commented on September 2, 2024

Hi guys, just wondering why not to use unsigned timestamps (uint64_t instead of int64_t). :)

from drampower.

Sv3n avatar Sv3n commented on September 2, 2024

Using unsigned numbers creates a few interesting opportunities for failure:

// If all of these variables are unsigned, then we might end up with
// an unexpectedly large value for 'a'
uint64_t a = max(zero, c-d);

The google style guide also agrees to some extent:
https://google.github.io/styleguide/cppguide.html#Integer_Types

from drampower.

myzinsky avatar myzinsky commented on September 2, 2024

Since we had this afternoon some discussions about using double or int for representing time in SystemC for DRAMSys, I'm curious to know: @Sv3n what is your motivation to represent time in int instead of double?

from drampower.

Sv3n avatar Sv3n commented on September 2, 2024

The input to DRAMPower is commands, which happen at integer multiples of the clock period. Expressing time as an integer number of clock cycles allows us to write down exactly when a command happens. Arithmetic on these clock cycles is guaranteed to produce an output that is another integer multiple of the clock period. With doubles you cannot guarantee that:

// Assuming the clock period is '1'
double now  = current_time_cycles_to_double(0);
double eight_cycles_ago = now - 8;
double four_cycles_ago =  now - 4;

// Now any of these expressions might be true, depending
// on the particular value of 'now':
eight_cycles_ago + 4 == four_cycles_ago;
eight_cycles_ago + 4 > four_cycles_ago;
eight_cycles_ago + 4 < four_cycles_ago;

At extremely large values, certain integer values can no longer be expressed in a double, and they will alias to other integers. For a demonstration of the effect (with less waiting time), you can use the smaller 'float' type:

for (float i = 0; i < 0xFFFFFFFF; i++) {
   // This will never finish. It halts at the first point where
   // the closest number expressible as a float for i + 1 == i
}

from drampower.

myzinsky avatar myzinsky commented on September 2, 2024

Thank you for that nice explanation. I had similar concerns, especially the rounding in the high dynamic ranges.

from drampower.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.