-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect more optimizable cases for initializing arrays with memset, wh…
…ich gives a 5x speedup for make-u8vector
- Loading branch information
Showing
1 changed file
with
40 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8aec26d
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.
Thanks! This speeds initializing a u1-storage-class in SRFI 231 whether it’s initialized with 1 or 0.
8aec26d
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 the initialization of u8vectors and s8vectors with the C
memset
function is straightforward. The code also detects when wider homogeneous vectors are initialized and all the bytes are the same. This means initializing to 0 and -1 and 0.0 are all done withmemset
which can be quite a bit faster than a plain for loop. I wonder if##bignum.make
could similarly be optimized...8aec26d
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 answer is "yes" for the "left fill" of the new bignum (which might be the entire bignum if there is no bignum argument passed to copy or to complement).
I wonder if that might speed up small bignum addition, etc.
8aec26d
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 looked at the code, and don't know how to set up the
memset
call in the middle of the body of the bignum.