-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable dynamic-sized RegisterBits #515
Conversation
Hey Zen! Yes, BTW, there' s a test: https://github.com/sparcians/map/blame/master/sparta/test/Register/reg_bit_test.cpp that you can build by hand to test it. I forgot to hook it up to regression. |
This reverts commit a954891.
Will do!
std::vector version was down ~2% simulation performance on generating a 50M trace, that was a shame. I came up with another way to keep std::array, but dynamically allocate memory when the size > 64B ... testing it ... If my trick works, that might be a good idea to shrink the std::array data to 8B as generally registers are 64-bit. |
Look forward to your trick. :) |
Done! The new version was measured 6.8% faster than the master build on generating a 10M+50M instruction trace 🚀 Register tests are also passed, which are also a good coverage on testing >64-bit RegisterBits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a memory leak here.
const uint8_t * remote_data_ = nullptr; //!< Remove data; points to local_data_ if no remote | ||
const uint64_t num_bytes_ = 0; //!< Number of bytse | ||
std::array<uint8_t, 8> local_storage_; //!< Local storage | ||
std::unique_ptr<uint8_t> local_storage_alt_; //!< Alternative local storage when register size > 64B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant std::unique_ptr<uint8_t[]>
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry -- My “C” brain thought I could use that as a uint8_t pointer!
I thought I trained that out of you! 🤣 |
I'll take a look at the regressions to see why it's failing. It's another irritant, I think. |
Huh it’s like on me. Weird -- I passed it on my Apple Silicon box.
I remember I saw a different CI failure previously though. I’ll also take a look at this one tomorrow. |
I ran |
Thank you! Will do! |
Done! That one was tricky ... Valgrind rocks!! Regressions still fail but that seems a Cython compilation issue on Argos ... @klingaard would you help take a look at it? |
if(!isPowerOf2(def->bytes)) { | ||
return RegisterBits(nullptr); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to just throw a SpartaException or keep this as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The write mask is initialized by Class initializer list, but the legal register size is later checked by the constructor ...
However an odd size would cause illegal access here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, that’s much better
Sigh... will take a look |
…p into zhenw/dynamic-register-bits
I'm going to remove helios/pipeview from the regression build. It's broken and we're re-writing it, so I don't care as much |
{ | ||
if(num_bytes_ <= local_storage_.size()) { | ||
local_storage_ = orig.local_storage_; | ||
local_data_ = orig.local_data_ == nullptr ? nullptr : local_storage_.data(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, when can num_bytes_
be <= local storage size and the original still have its local_data_ pointer set to nullptr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does this happen?
Actually I don’t know 😂 I just follow the same logics but take care of the original storage and alternative storage here.
Curious, when can num_bytes_ be <= local storage size and the original still have its local_data_ pointer set to nullptr?
There can be a scenario that RegisterBits is initialized by a raw pointer, which could be nullptr. That’s the only case I can think of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if it has > 0 bytes, will it ever be nullptr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, local_data_
could be nullptr
if RegisterBits
is initialized by a const uint8
pointer. In that case, only remote_data_
pointer is initialized. local_data_
is nullptr
until the value is changed.
* Enable dynamic-sized RegisterBits * Revert "Enable dynamic-sized RegisterBits" This reverts commit a954891. * Keep 64B array but use heap when registers > 64B * Enable register bit tests * Downsize preallocated RegisterBits data space * Fixed smart pointer type * Fixed illegal access caused by illegal RegDef * Fixed uninitialized values * Remove large register from bad test * Moved CI forward; see what happens * Do not build helios anymore * Throw the exception in the initialze function --------- Co-authored-by: Knute Lingaard <[email protected]> ce6b9dc
I merged this into the |
I haven't documented the release process fully, but in a nutshell (I will documented this officially 😄 ):
|
I am glad I do it right so far! Would we need a process to release a tag? I haven’t done it and filed a discussion here: #519 |
Hello Knute,
In some vector processors, we may need registers longer than 512-bit. Was
std::array
used for considering C++ performance? It might work if I just upsize it to 1024-bit, but I think there could be larger ones in the future. Usestd::vector
instead could be once and for all.Let me know your thoughts! I tried to make
64
as template parameter by default -- But Registerbits seems to be used heavily as return value type, and class template argument deduction can’t work for that case.